2 CLASS(Nexposee) EXTENDS(Container)
\r
3 METHOD(Nexposee, draw, void(entity))
\r
4 METHOD(Nexposee, keyDown, float(entity, float, float, float))
\r
5 METHOD(Nexposee, keyUp, float(entity, float, float, float))
\r
6 METHOD(Nexposee, mousePress, float(entity, vector))
\r
7 METHOD(Nexposee, mouseMove, float(entity, vector))
\r
8 METHOD(Nexposee, mouseRelease, float(entity, vector))
\r
9 METHOD(Nexposee, mouseDrag, float(entity, vector))
\r
10 METHOD(Nexposee, resizeNotify, void(entity, vector, vector, vector, vector))
\r
11 METHOD(Nexposee, focusEnter, void(entity))
\r
12 METHOD(Nexposee, close, void(entity))
\r
14 ATTRIB(Nexposee, animationState, float, -1)
\r
15 ATTRIB(Nexposee, animationFactor, float, 0)
\r
16 ATTRIB(Nexposee, selectedChild, entity, NULL)
\r
17 ATTRIB(Nexposee, mouseFocusedChild, entity, NULL)
\r
18 METHOD(Nexposee, addItem, void(entity, entity, vector, vector, float))
\r
19 METHOD(Nexposee, calc, void(entity))
\r
20 METHOD(Nexposee, setNexposee, void(entity, entity, vector, float, float))
\r
21 ATTRIB(Nexposee, mousePosition, vector, '0 0 0')
\r
22 METHOD(Nexposee, pullNexposee, void(entity, entity, vector))
\r
25 void ExposeeCloseButton_Click(entity button, entity other); // un-exposees the current state
\r
28 // animation states:
\r
29 // 0 = thumbnails seen
\r
33 // animation factor: 0 = minimum theSize, 1 = maximum theSize
\r
35 #ifdef IMPLEMENTATION
\r
37 .vector Nexposee_initialSize;
\r
38 .vector Nexposee_initialOrigin;
\r
39 .float Nexposee_initialAlpha;
\r
41 .vector Nexposee_smallSize;
\r
42 .vector Nexposee_smallOrigin;
\r
43 .float Nexposee_smallAlpha;
\r
44 .float Nexposee_mediumAlpha;
\r
45 .vector Nexposee_scaleCenter;
\r
46 .vector Nexposee_align;
\r
47 .float Nexposee_animationFactor;
\r
49 void closeNexposee(entity me)
\r
51 // user must override this
\r
54 void ExposeeCloseButton_Click(entity button, entity other)
\r
56 other.selectedChild = other.focusedChild;
\r
57 other.setFocus(other, NULL);
\r
58 other.animationState = 3;
\r
61 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
\r
64 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
\r
67 void Nexposee_Calc_Scale(entity me, float scale)
\r
70 for(e = me.firstChild; e; e = e.nextSibling)
\r
72 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
\r
73 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
\r
74 if(e.Nexposee_align_x > 0)
\r
75 e.Nexposee_smallOrigin_x = 1 - e.Nexposee_align_x * scale;
\r
76 if(e.Nexposee_align_x < 0)
\r
77 e.Nexposee_smallOrigin_x = -e.Nexposee_smallSize_x + e.Nexposee_align_x * scale;
\r
78 if(e.Nexposee_align_y > 0)
\r
79 e.Nexposee_smallOrigin_y = 1 - e.Nexposee_align_y * scale;
\r
80 if(e.Nexposee_align_y < 0)
\r
81 e.Nexposee_smallOrigin_y = -e.Nexposee_smallSize_y + e.Nexposee_align_y * scale;
\r
85 void calcNexposee(entity me)
\r
89 * can't put that here ;)
\r
93 vector emins, emaxs, e2mins, e2maxs;
\r
95 for(scale = 0.7;; scale *= 0.99)
\r
97 Nexposee_Calc_Scale(me, scale);
\r
99 for(e = me.firstChild; e; e = e.nextSibling)
\r
101 emins = e.Nexposee_smallOrigin;
\r
102 emaxs = emins + e.Nexposee_smallSize;
\r
103 for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
\r
105 e2mins = e2.Nexposee_smallOrigin;
\r
106 e2maxs = e2mins + e2.Nexposee_smallSize;
\r
108 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
\r
109 // amins < bmins < amaxs < bmaxs
\r
110 // for which suffices
\r
113 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
\r
114 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
\r
127 Nexposee_Calc_Scale(me, scale);
\r
130 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
\r
132 other.Nexposee_scaleCenter = scalecenter;
\r
133 other.Nexposee_smallAlpha = a0;
\r
134 me.setAlphaOf(me, other, a0);
\r
135 other.Nexposee_mediumAlpha = a1;
\r
138 void drawNexposee(entity me)
\r
145 if(me.animationState == -1)
\r
147 me.animationState = 0;
\r
150 //print(ftos(me.animationState), "\n");
\r
152 f = min(1, frametime * 5);
\r
153 switch(me.animationState)
\r
156 me.animationFactor = 0;
\r
159 me.animationFactor += f;
\r
160 if(me.animationFactor >= 1)
\r
162 me.animationFactor = 1;
\r
163 me.animationState = 2;
\r
164 setFocusContainer(me, me.selectedChild);
\r
168 me.animationFactor = 1;
\r
171 me.animationFactor -= f;
\r
172 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
\r
173 if(me.animationFactor <= 0)
\r
175 me.animationFactor = 0;
\r
176 me.animationState = 0;
\r
177 me.selectedChild = me.mouseFocusedChild;
\r
182 f = min(1, frametime * 10);
\r
183 for(e = me.firstChild; e; e = e.nextSibling)
\r
185 if(e == me.selectedChild)
\r
187 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
\r
188 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
\r
189 e.Nexposee_animationFactor = me.animationFactor;
\r
190 a0 = e.Nexposee_mediumAlpha;
\r
191 if(me.animationState == 3)
\r
192 if(e != me.mouseFocusedChild)
\r
193 a0 = e.Nexposee_smallAlpha;
\r
194 a = a0 * (1 - me.animationFactor) + me.animationFactor;
\r
198 // minimum theSize counts
\r
199 e.Container_origin = e.Nexposee_smallOrigin;
\r
200 e.Container_size = e.Nexposee_smallSize;
\r
201 e.Nexposee_animationFactor = 0;
\r
202 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
\r
204 me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f);
\r
206 e.Container_fontscale = globalToBoxSize(e.Container_size, e.Nexposee_initialSize);
\r
212 float mousePressNexposee(entity me, vector pos)
\r
214 if(me.animationState == 0)
\r
216 me.mouseFocusedChild = NULL;
\r
217 mouseMoveNexposee(me, pos);
\r
218 if(me.mouseFocusedChild)
\r
220 me.animationState = 1;
\r
221 setFocusContainer(me, NULL);
\r
227 else if(me.animationState == 2)
\r
229 if not(mousePressContainer(me, pos))
\r
231 me.animationState = 3;
\r
232 setFocusContainer(me, NULL);
\r
239 float mouseReleaseNexposee(entity me, vector pos)
\r
241 if(me.animationState == 2)
\r
242 return mouseReleaseContainer(me, pos);
\r
246 float mouseDragNexposee(entity me, vector pos)
\r
248 if(me.animationState == 2)
\r
249 return mouseDragContainer(me, pos);
\r
253 float mouseMoveNexposee(entity me, vector pos)
\r
256 me.mousePosition = pos;
\r
257 e = me.mouseFocusedChild;
\r
258 me.mouseFocusedChild = me.itemFromPoint(me, pos);
\r
259 if(me.animationState == 2)
\r
260 return mouseMoveContainer(me, pos);
\r
261 if(me.animationState == 0)
\r
263 if(me.mouseFocusedChild)
\r
264 if(me.mouseFocusedChild != e)
\r
265 me.selectedChild = me.mouseFocusedChild;
\r
271 float keyUpNexposee(entity me, float scan, float ascii, float shift)
\r
273 if(me.animationState == 2)
\r
274 return keyUpContainer(me, scan, ascii, shift);
\r
278 float keyDownNexposee(entity me, float scan, float ascii, float shift)
\r
281 if(me.animationState == 2)
\r
282 if(keyDownContainer(me, scan, ascii, shift))
\r
286 if(me.animationState == 0)
\r
288 if(shift & S_SHIFT)
\r
290 if(me.selectedChild)
\r
291 me.selectedChild = me.selectedChild.prevSibling;
\r
292 if not(me.selectedChild)
\r
293 me.selectedChild = me.lastChild;
\r
297 if(me.selectedChild)
\r
298 me.selectedChild = me.selectedChild.nextSibling;
\r
299 if not(me.selectedChild)
\r
300 me.selectedChild = me.firstChild;
\r
304 switch(me.animationState)
\r
308 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
\r
312 nexposeeKey = (scan == K_ESCAPE);
\r
317 switch(me.animationState)
\r
321 me.animationState = 1;
\r
325 me.animationState = 3;
\r
328 if(me.focusedChild)
\r
329 me.selectedChild = me.focusedChild;
\r
330 if not(me.selectedChild)
\r
331 me.animationState = 0;
\r
332 setFocusContainer(me, NULL);
\r
338 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
\r
340 addItemContainer(me, other, theOrigin, theSize, theAlpha);
\r
341 other.Nexposee_initialSize = other.Container_size;
\r
342 other.Nexposee_initialOrigin = other.Container_origin;
\r
343 other.Nexposee_initialAlpha = other.Container_alpha;
\r
346 void focusEnterNexposee(entity me)
\r
348 if(me.animationState == 2)
\r
349 setFocusContainer(me, me.selectedChild);
\r
352 void pullNexposeeNexposee(entity me, entity other, vector theAlign)
\r
354 other.Nexposee_align = theAlign;
\r