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_initialOrigin;
39 .float Nexposee_initialAlpha;
41 .vector Nexposee_smallSize;
42 .vector Nexposee_smallOrigin;
43 .float Nexposee_smallAlpha;
44 .float Nexposee_mediumAlpha;
45 .vector Nexposee_scaleCenter;
46 .vector Nexposee_align;
47 .float Nexposee_animationFactor;
49 void closeNexposee(entity me)
51 // user must override this
54 void ExposeeCloseButton_Click(entity button, entity other)
56 other.selectedChild = other.focusedChild;
57 other.setFocus(other, NULL);
58 other.animationState = 3;
61 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
64 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
67 void Nexposee_Calc_Scale(entity me, float scale)
70 for(e = me.firstChild; e; e = e.nextSibling)
72 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
73 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
74 if(e.Nexposee_align_x > 0)
75 e.Nexposee_smallOrigin_x = 1 - e.Nexposee_align_x * scale;
76 if(e.Nexposee_align_x < 0)
77 e.Nexposee_smallOrigin_x = -e.Nexposee_smallSize_x + e.Nexposee_align_x * scale;
78 if(e.Nexposee_align_y > 0)
79 e.Nexposee_smallOrigin_y = 1 - e.Nexposee_align_y * scale;
80 if(e.Nexposee_align_y < 0)
81 e.Nexposee_smallOrigin_y = -e.Nexposee_smallSize_y + e.Nexposee_align_y * scale;
85 void calcNexposee(entity me)
89 * can't put that here ;)
93 vector emins, emaxs, e2mins, e2maxs;
95 for(scale = 0.7;; scale *= 0.99)
97 Nexposee_Calc_Scale(me, scale);
99 for(e = me.firstChild; e; e = e.nextSibling)
101 emins = e.Nexposee_smallOrigin;
102 emaxs = emins + e.Nexposee_smallSize;
103 for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
105 e2mins = e2.Nexposee_smallOrigin;
106 e2maxs = e2mins + e2.Nexposee_smallSize;
108 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
109 // amins < bmins < amaxs < bmaxs
110 // for which suffices
113 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
114 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
127 Nexposee_Calc_Scale(me, scale);
130 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
132 other.Nexposee_scaleCenter = scalecenter;
133 other.Nexposee_smallAlpha = a0;
134 me.setAlphaOf(me, other, a0);
135 other.Nexposee_mediumAlpha = a1;
138 void drawNexposee(entity me)
145 if(me.animationState == -1)
147 me.animationState = 0;
150 //print(ftos(me.animationState), "\n");
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 setFocusContainer(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);
210 for(e = me.firstChild; e; e = e.nextSibling)
213 a0 = e.Container_alpha;
214 if(a0 < e.Nexposee_smallAlpha)
215 a = 0.3 * (a0 - 0) / (e.Nexposee_smallAlpha - 0);
216 else if(a0 < e.Nexposee_mediumAlpha)
217 a = 0.3 + 0.5 * (a0 - e.Nexposee_smallAlpha) / (e.Nexposee_mediumAlpha - e.Nexposee_smallAlpha);
219 a = 0.8 - 0.8 * (a0 - e.Nexposee_mediumAlpha) / (1 - e.Nexposee_mediumAlpha);
220 fs = (eX * (1 / draw_scale_x) + eY * (1 / draw_scale_y)) * 36;
221 t = draw_TextWidth(e.title, FALSE) * eX * fs_x + eY * fs_y;
222 draw_Text(e.Container_origin + (e.Container_size_x * eX - t) * 0.5 - 0.5 * eY * t_y, e.title, fs, e.color, a, FALSE);
227 float mousePressNexposee(entity me, vector pos)
229 if(me.animationState == 0)
231 me.mouseFocusedChild = NULL;
232 mouseMoveNexposee(me, pos);
233 if(me.mouseFocusedChild)
235 me.animationState = 1;
236 setFocusContainer(me, NULL);
242 else if(me.animationState == 2)
244 if not(mousePressContainer(me, pos))
246 me.animationState = 3;
247 setFocusContainer(me, NULL);
254 float mouseReleaseNexposee(entity me, vector pos)
256 if(me.animationState == 2)
257 return mouseReleaseContainer(me, pos);
261 float mouseDragNexposee(entity me, vector pos)
263 if(me.animationState == 2)
264 return mouseDragContainer(me, pos);
268 float mouseMoveNexposee(entity me, vector pos)
271 me.mousePosition = pos;
272 e = me.mouseFocusedChild;
273 me.mouseFocusedChild = me.itemFromPoint(me, pos);
274 if(me.animationState == 2)
275 return mouseMoveContainer(me, pos);
276 if(me.animationState == 0)
278 if(me.mouseFocusedChild)
279 if(me.mouseFocusedChild != e)
280 me.selectedChild = me.mouseFocusedChild;
286 float keyUpNexposee(entity me, float scan, float ascii, float shift)
288 if(me.animationState == 2)
289 return keyUpContainer(me, scan, ascii, shift);
293 float keyDownNexposee(entity me, float scan, float ascii, float shift)
296 if(me.animationState == 2)
297 if(keyDownContainer(me, scan, ascii, shift))
301 if(me.animationState == 0)
306 me.selectedChild = me.selectedChild.prevSibling;
307 if not(me.selectedChild)
308 me.selectedChild = me.lastChild;
313 me.selectedChild = me.selectedChild.nextSibling;
314 if not(me.selectedChild)
315 me.selectedChild = me.firstChild;
319 switch(me.animationState)
323 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
327 nexposeeKey = (scan == K_ESCAPE);
332 switch(me.animationState)
336 me.animationState = 1;
340 me.animationState = 3;
344 me.selectedChild = me.focusedChild;
345 if not(me.selectedChild)
346 me.animationState = 0;
347 setFocusContainer(me, NULL);
353 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
355 addItemContainer(me, other, theOrigin, theSize, theAlpha);
356 other.Nexposee_initialSize = other.Container_size;
357 other.Nexposee_initialOrigin = other.Container_origin;
358 other.Nexposee_initialAlpha = other.Container_alpha;
361 void focusEnterNexposee(entity me)
363 if(me.animationState == 2)
364 setFocusContainer(me, me.selectedChild);
367 void pullNexposeeNexposee(entity me, entity other, vector theAlign)
369 other.Nexposee_align = theAlign;