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;
48 void closeNexposee(entity me)
50 // user must override this
53 void ExposeeCloseButton_Click(entity button, entity other)
55 other.selectedChild = other.focusedChild;
56 other.setFocus(other, NULL);
57 other.animationState = 3;
60 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
62 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
65 void Nexposee_Calc_Scale(entity me, float scale)
68 for(e = me.firstChild; e; e = e.nextSibling)
70 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
71 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
72 if(e.Nexposee_align_x > 0)
73 e.Nexposee_smallOrigin_x = 1 - e.Nexposee_align_x * scale;
74 if(e.Nexposee_align_x < 0)
75 e.Nexposee_smallOrigin_x = -e.Nexposee_smallSize_x + e.Nexposee_align_x * scale;
76 if(e.Nexposee_align_y > 0)
77 e.Nexposee_smallOrigin_y = 1 - e.Nexposee_align_y * scale;
78 if(e.Nexposee_align_y < 0)
79 e.Nexposee_smallOrigin_y = -e.Nexposee_smallSize_y + e.Nexposee_align_y * scale;
83 void calcNexposee(entity me)
87 * can't put that here ;)
91 vector emins, emaxs, e2mins, e2maxs;
93 for(scale = 0.7;; scale *= 0.99)
95 Nexposee_Calc_Scale(me, scale);
97 for(e = me.firstChild; e; e = e.nextSibling)
99 emins = e.Nexposee_smallOrigin;
100 emaxs = emins + e.Nexposee_smallSize;
101 for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
103 e2mins = e2.Nexposee_smallOrigin;
104 e2maxs = e2mins + e2.Nexposee_smallSize;
106 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
107 // amins < bmins < amaxs < bmaxs
108 // for which suffices
111 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
112 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
125 Nexposee_Calc_Scale(me, scale);
128 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
130 other.Nexposee_scaleCenter = scalecenter;
131 other.Nexposee_smallAlpha = a0;
132 me.setAlphaOf(me, other, a0);
133 other.Nexposee_mediumAlpha = a1;
136 void drawNexposee(entity me)
143 if(me.animationState == -1)
145 me.animationState = 0;
149 //print(ftos(me.animationState), "\n");
151 f = min(1, frametime * 5);
152 switch(me.animationState)
155 me.animationFactor = 0;
158 me.animationFactor += f;
159 if(me.animationFactor >= 1)
161 me.animationFactor = 1;
162 me.animationState = 2;
163 setFocusContainer(me, me.selectedChild);
167 me.animationFactor = 1;
170 me.animationFactor -= f;
171 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
172 if(me.animationFactor <= 0)
174 me.animationFactor = 0;
175 me.animationState = 0;
176 me.selectedChild = me.mouseFocusedChild;
181 f = min(1, frametime * 10);
182 for(e = me.firstChild; e; e = e.nextSibling)
184 if(e == me.selectedChild)
186 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
187 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
188 a0 = e.Nexposee_mediumAlpha;
189 if(me.animationState == 3)
190 if(e != me.mouseFocusedChild)
191 a0 = e.Nexposee_smallAlpha;
192 a = a0 * (1 - me.animationFactor) + me.animationFactor;
196 // minimum theSize counts
197 e.Container_origin = e.Nexposee_smallOrigin;
198 e.Container_size = e.Nexposee_smallSize;
199 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
201 me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f);
207 for(e = me.firstChild; e; e = e.nextSibling)
210 a0 = e.Container_alpha;
211 if(a0 < e.Nexposee_smallAlpha)
212 a = 0.3 * (a0 - 0) / (e.Nexposee_smallAlpha - 0);
213 else if(a0 < e.Nexposee_mediumAlpha)
214 a = 0.3 + 0.5 * (a0 - e.Nexposee_smallAlpha) / (e.Nexposee_mediumAlpha - e.Nexposee_smallAlpha);
216 a = 0.8 - 0.8 * (a0 - e.Nexposee_mediumAlpha) / (1 - e.Nexposee_mediumAlpha);
217 fs = (eX * (1 / draw_scale_x) + eY * (1 / draw_scale_y)) * 36;
218 t = draw_TextWidth(e.title, FALSE) * eX * fs_x + eY * fs_y;
219 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);
224 float mousePressNexposee(entity me, vector pos)
226 if(me.animationState == 0)
228 me.mouseFocusedChild = NULL;
229 mouseMoveNexposee(me, pos);
230 if(me.mouseFocusedChild)
232 me.animationState = 1;
233 setFocusContainer(me, NULL);
239 else if(me.animationState == 2)
241 if not(mousePressContainer(me, pos))
243 me.animationState = 3;
244 setFocusContainer(me, NULL);
251 float mouseReleaseNexposee(entity me, vector pos)
253 if(me.animationState == 2)
254 return mouseReleaseContainer(me, pos);
258 float mouseDragNexposee(entity me, vector pos)
260 if(me.animationState == 2)
261 return mouseDragContainer(me, pos);
265 float mouseMoveNexposee(entity me, vector pos)
268 me.mousePosition = pos;
269 e = me.mouseFocusedChild;
270 me.mouseFocusedChild = me.itemFromPoint(me, pos);
271 if(me.animationState == 2)
272 return mouseMoveContainer(me, pos);
273 if(me.animationState == 0)
275 if(me.mouseFocusedChild)
276 if(me.mouseFocusedChild != e)
277 me.selectedChild = me.mouseFocusedChild;
283 float keyUpNexposee(entity me, float scan, float ascii, float shift)
285 if(me.animationState == 2)
286 return keyUpContainer(me, scan, ascii, shift);
290 float keyDownNexposee(entity me, float scan, float ascii, float shift)
293 if(me.animationState == 2)
294 if(keyDownContainer(me, scan, ascii, shift))
298 if(me.animationState == 0)
303 me.selectedChild = me.selectedChild.prevSibling;
304 if not(me.selectedChild)
305 me.selectedChild = me.lastChild;
310 me.selectedChild = me.selectedChild.nextSibling;
311 if not(me.selectedChild)
312 me.selectedChild = me.firstChild;
316 switch(me.animationState)
320 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
324 nexposeeKey = (scan == K_ESCAPE);
329 switch(me.animationState)
333 me.animationState = 1;
337 me.animationState = 3;
341 me.selectedChild = me.focusedChild;
342 if not(me.selectedChild)
343 me.animationState = 0;
344 setFocusContainer(me, NULL);
350 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
352 addItemContainer(me, other, theOrigin, theSize, theAlpha);
353 other.Nexposee_initialSize = other.Container_size;
354 other.Nexposee_initialOrigin = other.Container_origin;
355 other.Nexposee_initialAlpha = other.Container_alpha;
358 void focusEnterNexposee(entity me)
360 if(me.animationState == 2)
361 setFocusContainer(me, me.selectedChild);
364 void pullNexposeeNexposee(entity me, entity other, vector theAlign)
366 other.Nexposee_align = theAlign;