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')
24 void ExposeeCloseButton_Click(entity button, entity other); // un-exposees the current state
28 // 0 = thumbnails seen
32 // animation factor: 0 = minimum theSize, 1 = maximum theSize
36 .vector Nexposee_initialSize;
37 .vector Nexposee_initialOrigin;
38 .float Nexposee_initialAlpha;
40 .vector Nexposee_smallSize;
41 .vector Nexposee_smallOrigin;
42 .float Nexposee_smallAlpha;
43 .float Nexposee_mediumAlpha;
44 .vector Nexposee_scaleCenter;
46 void closeNexposee(entity me)
48 // user must override this
51 void ExposeeCloseButton_Click(entity button, entity other)
53 other.selectedChild = other.focusedChild;
54 other.setFocus(other, NULL);
55 other.animationState = 3;
58 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
60 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
63 void calcNexposee(entity me)
67 * can't put that here ;)
71 vector emins, emaxs, e2mins, e2maxs;
73 for(scale = 0.7;; scale *= 0.99)
75 for(e = me.firstChild; e; e = e.nextSibling)
77 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
78 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
81 for(e = me.firstChild; e; e = e.nextSibling)
83 emins = e.Nexposee_smallOrigin;
84 emaxs = emins + e.Nexposee_smallSize;
85 for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
87 e2mins = e2.Nexposee_smallOrigin;
88 e2maxs = e2mins + e2.Nexposee_smallSize;
90 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
91 // amins < bmins < amaxs < bmaxs
95 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
96 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
108 for(e = me.firstChild; e; e = e.nextSibling)
110 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
111 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
115 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
117 other.Nexposee_scaleCenter = scalecenter;
118 other.Nexposee_smallAlpha = a0;
119 me.setAlphaOf(me, other, a0);
120 other.Nexposee_mediumAlpha = a1;
123 void drawNexposee(entity me)
130 if(me.animationState == -1)
132 me.animationState = 0;
136 //print(ftos(me.animationState), "\n");
138 f = min(1, frametime * 5);
139 switch(me.animationState)
142 me.animationFactor = 0;
145 me.animationFactor += f;
146 if(me.animationFactor >= 1)
148 me.animationFactor = 1;
149 me.animationState = 2;
150 setFocusContainer(me, me.selectedChild);
154 me.animationFactor = 1;
157 me.animationFactor -= f;
158 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
159 if(me.animationFactor <= 0)
161 me.animationFactor = 0;
162 me.animationState = 0;
163 me.selectedChild = me.mouseFocusedChild;
168 f = min(1, frametime * 10);
169 for(e = me.firstChild; e; e = e.nextSibling)
171 if(e == me.selectedChild)
173 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
174 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
175 a0 = e.Nexposee_mediumAlpha;
176 if(me.animationState == 3)
177 if(e != me.mouseFocusedChild)
178 a0 = e.Nexposee_smallAlpha;
179 a = a0 * (1 - me.animationFactor) + me.animationFactor;
183 // minimum theSize counts
184 e.Container_origin = e.Nexposee_smallOrigin;
185 e.Container_size = e.Nexposee_smallSize;
186 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
188 me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f);
194 for(e = me.firstChild; e; e = e.nextSibling)
197 a0 = e.Container_alpha;
198 if(a0 < e.Nexposee_smallAlpha)
199 a = 0.3 * (a0 - 0) / (e.Nexposee_smallAlpha - 0);
200 else if(a0 < e.Nexposee_mediumAlpha)
201 a = 0.3 + 0.5 * (a0 - e.Nexposee_smallAlpha) / (e.Nexposee_mediumAlpha - e.Nexposee_smallAlpha);
203 a = 0.8 - 0.8 * (a0 - e.Nexposee_mediumAlpha) / (1 - e.Nexposee_mediumAlpha);
204 fs = (eX * (1 / draw_scale_x) + eY * (1 / draw_scale_y)) * 36;
205 t = draw_TextWidth(e.title, FALSE) * eX * fs_x + eY * fs_y;
206 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);
211 float mousePressNexposee(entity me, vector pos)
213 if(me.animationState == 0)
215 me.mouseFocusedChild = NULL;
216 mouseMoveNexposee(me, pos);
217 if(me.mouseFocusedChild)
219 me.animationState = 1;
220 setFocusContainer(me, NULL);
226 else if(me.animationState == 2)
228 if not(mousePressContainer(me, pos))
230 me.animationState = 3;
231 setFocusContainer(me, NULL);
238 float mouseReleaseNexposee(entity me, vector pos)
240 if(me.animationState == 2)
241 return mouseReleaseContainer(me, pos);
245 float mouseDragNexposee(entity me, vector pos)
247 if(me.animationState == 2)
248 return mouseDragContainer(me, pos);
252 float mouseMoveNexposee(entity me, vector pos)
255 me.mousePosition = pos;
256 e = me.mouseFocusedChild;
257 me.mouseFocusedChild = me.itemFromPoint(me, pos);
258 if(me.animationState == 2)
259 return mouseMoveContainer(me, pos);
260 if(me.animationState == 0)
262 if(me.mouseFocusedChild)
263 if(me.mouseFocusedChild != e)
264 me.selectedChild = me.mouseFocusedChild;
270 float keyUpNexposee(entity me, float scan, float ascii, float shift)
272 if(me.animationState == 2)
273 return keyUpContainer(me, scan, ascii, shift);
277 float keyDownNexposee(entity me, float scan, float ascii, float shift)
280 if(me.animationState == 2)
281 if(keyDownContainer(me, scan, ascii, shift))
285 if(me.animationState == 0)
290 me.selectedChild = me.selectedChild.prevSibling;
291 if not(me.selectedChild)
292 me.selectedChild = me.lastChild;
297 me.selectedChild = me.selectedChild.nextSibling;
298 if not(me.selectedChild)
299 me.selectedChild = me.firstChild;
303 switch(me.animationState)
307 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
311 nexposeeKey = (scan == K_ESCAPE);
316 switch(me.animationState)
320 me.animationState = 1;
324 me.animationState = 3;
328 me.selectedChild = me.focusedChild;
329 if not(me.selectedChild)
330 me.animationState = 0;
331 setFocusContainer(me, NULL);
337 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
339 addItemContainer(me, other, theOrigin, theSize, theAlpha);
340 other.Nexposee_initialSize = other.Container_size;
341 other.Nexposee_initialOrigin = other.Container_origin;
342 other.Nexposee_initialAlpha = other.Container_alpha;
345 void focusEnterNexposee(entity me)
347 if(me.animationState == 2)
348 setFocusContainer(me, me.selectedChild);