2 CLASS(Nexposee) EXTENDS(Container)
3 METHOD(Nexposee, draw, void(entity))
4 METHOD(Nexposee, keyDown, float(entity, float, float, float))
5 METHOD(Nexposee, keyUp, float(entity, float, float, float))
6 METHOD(Nexposee, mousePress, float(entity, vector))
7 METHOD(Nexposee, mouseMove, float(entity, vector))
8 METHOD(Nexposee, mouseRelease, float(entity, vector))
9 METHOD(Nexposee, mouseDrag, float(entity, vector))
10 METHOD(Nexposee, resizeNotify, void(entity, vector, vector, vector, vector))
11 METHOD(Nexposee, focusEnter, void(entity))
12 METHOD(Nexposee, close, void(entity))
14 ATTRIB(Nexposee, animationState, float, -1)
15 ATTRIB(Nexposee, animationFactor, float, 0)
16 ATTRIB(Nexposee, selectedChild, entity, NULL)
17 ATTRIB(Nexposee, mouseFocusedChild, entity, NULL)
18 METHOD(Nexposee, addItem, void(entity, entity, vector, vector, float))
19 METHOD(Nexposee, calc, void(entity))
20 METHOD(Nexposee, setNexposee, void(entity, entity, vector, float, float))
21 ATTRIB(Nexposee, mousePosition, vector, '0 0 0')
22 METHOD(Nexposee, pullNexposee, void(entity, entity, vector))
25 void ExposeeCloseButton_Click(entity button, entity other); // un-exposees the current state
29 // 0 = thumbnails seen
33 // animation factor: 0 = minimum theSize, 1 = maximum theSize
37 .vector Nexposee_initialSize;
38 .vector Nexposee_initialFontScale;
39 .vector Nexposee_initialOrigin;
40 .float Nexposee_initialAlpha;
42 .vector Nexposee_smallSize;
43 .vector Nexposee_smallOrigin;
44 .float Nexposee_smallAlpha;
45 .float Nexposee_mediumAlpha;
46 .vector Nexposee_scaleCenter;
47 .vector Nexposee_align;
48 .float Nexposee_animationFactor;
50 void Nexposee_close(entity me)
52 // user must override this
55 void ExposeeCloseButton_Click(entity button, entity other)
57 other.selectedChild = other.focusedChild;
58 other.setFocus(other, NULL);
59 other.animationState = 3;
62 void Nexposee_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
65 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize, Nexposee_initialFontScale);
68 void Nexposee_Calc_Scale(entity me, float scale)
71 for(e = me.firstChild; e; e = e.nextSibling)
73 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
74 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
75 if(e.Nexposee_align_x > 0)
76 e.Nexposee_smallOrigin_x = 1 - e.Nexposee_align_x * scale;
77 if(e.Nexposee_align_x < 0)
78 e.Nexposee_smallOrigin_x = -e.Nexposee_smallSize_x + e.Nexposee_align_x * scale;
79 if(e.Nexposee_align_y > 0)
80 e.Nexposee_smallOrigin_y = 1 - e.Nexposee_align_y * scale;
81 if(e.Nexposee_align_y < 0)
82 e.Nexposee_smallOrigin_y = -e.Nexposee_smallSize_y + e.Nexposee_align_y * scale;
86 void Nexposee_calc(entity me)
90 * can't put that here ;)
94 vector emins, emaxs, e2mins, e2maxs;
96 for(scale = 0.7;; scale *= 0.99)
98 Nexposee_Calc_Scale(me, scale);
100 for(e = me.firstChild; e; e = e.nextSibling)
102 emins = e.Nexposee_smallOrigin;
103 emaxs = emins + e.Nexposee_smallSize;
104 for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
106 e2mins = e2.Nexposee_smallOrigin;
107 e2maxs = e2mins + e2.Nexposee_smallSize;
109 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
110 // amins < bmins < amaxs < bmaxs
111 // for which suffices
114 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
115 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
128 Nexposee_Calc_Scale(me, scale);
131 void Nexposee_setNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
133 other.Nexposee_scaleCenter = scalecenter;
134 other.Nexposee_smallAlpha = a0;
135 me.setAlphaOf(me, other, a0);
136 other.Nexposee_mediumAlpha = a1;
139 void Nexposee_draw(entity me)
147 if(me.animationState == -1)
149 me.animationState = 0;
152 f = min(1, frametime * 5);
153 switch(me.animationState)
156 me.animationFactor = 0;
159 me.animationFactor += f;
160 if(me.animationFactor >= 1)
162 me.animationFactor = 1;
163 me.animationState = 2;
164 SUPER(Nexposee).setFocus(me, me.selectedChild);
168 me.animationFactor = 1;
171 me.animationFactor -= f;
172 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
173 if(me.animationFactor <= 0)
175 me.animationFactor = 0;
176 me.animationState = 0;
177 me.selectedChild = me.mouseFocusedChild;
182 f = min(1, frametime * 10);
183 for(e = me.firstChild; e; e = e.nextSibling)
185 if(e == me.selectedChild)
187 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
188 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
189 e.Nexposee_animationFactor = me.animationFactor;
190 a0 = e.Nexposee_mediumAlpha;
191 if(me.animationState == 3)
192 if(e != me.mouseFocusedChild)
193 a0 = e.Nexposee_smallAlpha;
194 a = a0 * (1 - me.animationFactor) + me.animationFactor;
198 // minimum theSize counts
199 e.Container_origin = e.Nexposee_smallOrigin;
200 e.Container_size = e.Nexposee_smallSize;
201 e.Nexposee_animationFactor = 0;
202 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
204 me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f);
206 fs = globalToBoxSize(e.Container_size, e.Nexposee_initialSize);
207 e.Container_fontscale_x = fs_x * e.Nexposee_initialFontScale_x;
208 e.Container_fontscale_y = fs_y * e.Nexposee_initialFontScale_y;
211 SUPER(Nexposee).draw(me);
214 float Nexposee_mousePress(entity me, vector pos)
216 if(me.animationState == 0)
218 me.mouseFocusedChild = NULL;
219 Nexposee_mouseMove(me, pos);
220 if(me.mouseFocusedChild)
222 me.animationState = 1;
223 SUPER(Nexposee).setFocus(me, NULL);
229 else if(me.animationState == 2)
231 if not(SUPER(Nexposee).mousePress(me, pos))
233 me.animationState = 3;
234 SUPER(Nexposee).setFocus(me, NULL);
241 float Nexposee_mouseRelease(entity me, vector pos)
243 if(me.animationState == 2)
244 return SUPER(Nexposee).mouseRelease(me, pos);
248 float Nexposee_mouseDrag(entity me, vector pos)
250 if(me.animationState == 2)
251 return SUPER(Nexposee).mouseDrag(me, pos);
255 float Nexposee_mouseMove(entity me, vector pos)
258 me.mousePosition = pos;
259 e = me.mouseFocusedChild;
260 me.mouseFocusedChild = me.itemFromPoint(me, pos);
261 if(me.animationState == 2)
262 return SUPER(Nexposee).mouseMove(me, pos);
263 if(me.animationState == 0)
265 if(me.mouseFocusedChild)
266 if(me.mouseFocusedChild != e)
267 me.selectedChild = me.mouseFocusedChild;
273 float Nexposee_keyUp(entity me, float scan, float ascii, float shift)
275 if(me.animationState == 2)
276 return SUPER(Nexposee).keyUp(me, scan, ascii, shift);
280 float Nexposee_keyDown(entity me, float scan, float ascii, float shift)
283 if(me.animationState == 2)
284 if(SUPER(Nexposee).keyDown(me, scan, ascii, shift))
288 if(me.animationState == 0)
293 me.selectedChild = me.selectedChild.prevSibling;
294 if not(me.selectedChild)
295 me.selectedChild = me.lastChild;
300 me.selectedChild = me.selectedChild.nextSibling;
301 if not(me.selectedChild)
302 me.selectedChild = me.firstChild;
306 switch(me.animationState)
310 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER) || (scan == K_KP_ENTER));
314 nexposeeKey = (scan == K_ESCAPE);
319 switch(me.animationState)
323 me.animationState = 1;
327 me.animationState = 3;
331 me.selectedChild = me.focusedChild;
332 if not(me.selectedChild)
333 me.animationState = 0;
334 SUPER(Nexposee).setFocus(me, NULL);
340 void Nexposee_addItem(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
342 SUPER(Nexposee).addItem(me, other, theOrigin, theSize, theAlpha);
343 other.Nexposee_initialFontScale = other.Container_fontscale;
344 other.Nexposee_initialSize = other.Container_size;
345 other.Nexposee_initialOrigin = other.Container_origin;
346 other.Nexposee_initialAlpha = other.Container_alpha;
347 if(other.Nexposee_initialFontScale == '0 0 0')
348 other.Nexposee_initialFontScale = '1 1 0';
351 void Nexposee_focusEnter(entity me)
353 if(me.animationState == 2)
354 SUPER(Nexposee).setFocus(me, me.selectedChild);
357 void Nexposee_pullNexposee(entity me, entity other, vector theAlign)
359 other.Nexposee_align = theAlign;