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))
13 ATTRIB(Nexposee, animationState, float, -1)
14 ATTRIB(Nexposee, animationFactor, float, 0)
15 ATTRIB(Nexposee, selectedChild, entity, NULL)
16 ATTRIB(Nexposee, mouseFocusedChild, entity, NULL)
17 METHOD(Nexposee, addItem, void(entity, entity, vector, vector, float))
18 METHOD(Nexposee, calc, void(entity))
19 METHOD(Nexposee, setNexposee, void(entity, entity, vector, float, float))
20 ATTRIB(Nexposee, mousePosition, vector, '0 0 0')
23 void ExposeeCloseButton_Click(entity button, entity other); // un-exposees the current state
27 // 0 = thumbnails seen
31 // animation factor: 0 = minimum theSize, 1 = maximum theSize
35 .vector Nexposee_initialSize;
36 .vector Nexposee_initialOrigin;
37 .float Nexposee_initialAlpha;
39 .vector Nexposee_smallSize;
40 .vector Nexposee_smallOrigin;
41 .float Nexposee_smallAlpha;
42 .float Nexposee_mediumAlpha;
43 .vector Nexposee_scaleCenter;
45 void ExposeeCloseButton_Click(entity button, entity other)
47 other.selectedChild = other.focusedChild;
48 other.setFocus(other, NULL);
49 other.animationState = 3;
52 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
54 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
57 void calcNexposee(entity me)
61 * can't put that here ;)
65 vector emins, emaxs, e2mins, e2maxs;
67 for(scale = 0.7;; scale *= 0.9)
69 for(e = me.firstChild; e; e = e.Container_nextSibling)
71 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
72 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
75 for(e = me.firstChild; e; e = e.Container_nextSibling)
77 emins = e.Nexposee_smallOrigin;
78 emaxs = emins + e.Nexposee_smallSize;
79 for(e2 = e.Container_nextSibling; e2; e2 = e2.Container_nextSibling)
81 e2mins = e2.Nexposee_smallOrigin;
82 e2maxs = e2mins + e2.Nexposee_smallSize;
84 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
85 // amins < bmins < amaxs < bmaxs
89 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
90 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
102 for(e = me.firstChild; e; e = e.Container_nextSibling)
104 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
105 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
109 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
111 other.Nexposee_scaleCenter = scalecenter;
112 other.Nexposee_smallAlpha = other.Container_alpha = a0;
113 other.Nexposee_mediumAlpha = a1;
116 void drawNexposee(entity me)
121 if(me.animationState == -1)
123 me.animationState = 0;
127 //print(ftos(me.animationState), "\n");
129 f = min(1, frametime * 5);
130 switch(me.animationState)
133 me.animationFactor = 0;
136 me.animationFactor += f;
137 if(me.animationFactor >= 1)
139 me.animationFactor = 1;
140 me.animationState = 2;
141 setFocusContainer(me, me.selectedChild);
145 me.animationFactor = 1;
148 me.animationFactor -= f;
149 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
150 if(me.animationFactor <= 0)
152 me.animationFactor = 0;
153 me.animationState = 0;
154 me.selectedChild = me.mouseFocusedChild;
159 f = min(1, frametime * 10);
160 for(e = me.firstChild; e; e = e.Container_nextSibling)
164 if(e == me.selectedChild)
166 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
167 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
168 a0 = e.Nexposee_mediumAlpha;
169 if(me.animationState == 3)
170 if(e != me.mouseFocusedChild)
171 a0 = e.Nexposee_smallAlpha;
172 a = a0 * (1 - me.animationFactor) + me.animationFactor;
176 // minimum theSize counts
177 e.Container_origin = e.Nexposee_smallOrigin;
178 e.Container_size = e.Nexposee_smallSize;
179 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
181 e.Container_alpha = e.Container_alpha * (1 - f) + a * f;
187 float mousePressNexposee(entity me, vector pos)
189 if(me.animationState == 0)
191 me.mouseFocusedChild = NULL;
192 mouseMoveNexposee(me, pos);
195 me.animationState = 1;
196 setFocusContainer(me, NULL);
200 else if(me.animationState == 2)
202 if(!mousePressContainer(me, pos))
204 me.animationState = 3;
205 setFocusContainer(me, NULL);
212 float mouseReleaseNexposee(entity me, vector pos)
214 if(me.animationState == 2)
215 return mouseReleaseContainer(me, pos);
219 float mouseDragNexposee(entity me, vector pos)
221 if(me.animationState == 2)
222 return mouseDragContainer(me, pos);
226 float mouseMoveNexposee(entity me, vector pos)
229 me.mousePosition = pos;
230 e = me.mouseFocusedChild;
231 me.mouseFocusedChild = me.itemFromPoint(me, pos);
232 if(me.animationState == 2)
233 return mouseMoveContainer(me, pos);
234 if(me.animationState == 0)
236 if(me.mouseFocusedChild)
237 if(me.mouseFocusedChild != e)
238 me.selectedChild = me.mouseFocusedChild;
244 float keyUpNexposee(entity me, float scan, float ascii, float shift)
246 if(me.animationState == 2)
247 return keyUpContainer(me, scan, ascii, shift);
251 float keyDownNexposee(entity me, float scan, float ascii, float shift)
254 if(me.animationState == 2)
255 if(keyDownContainer(me, scan, ascii, shift))
259 if(me.animationState == 0)
264 me.selectedChild = me.selectedChild.Container_prevSibling;
265 if(!me.selectedChild)
266 me.selectedChild = me.lastChild;
271 me.selectedChild = me.selectedChild.Container_nextSibling;
272 if(!me.selectedChild)
273 me.selectedChild = me.firstChild;
277 switch(me.animationState)
281 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
285 nexposeeKey = (scan == K_ESCAPE);
290 switch(me.animationState)
294 me.animationState = 1;
298 me.animationState = 3;
302 me.selectedChild = me.focusedChild;
303 if(!me.selectedChild)
304 me.animationState = 0;
305 setFocusContainer(me, NULL);
311 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
313 other.Nexposee_initialSize = theSize;
314 other.Nexposee_initialOrigin = theOrigin;
315 other.Nexposee_initialAlpha = theAlpha;
316 addItemContainer(me, other, theOrigin, theSize, theAlpha);
319 void focusEnterNexposee(entity me)
321 if(me.animationState == 2)
322 setFocusContainer(me, me.selectedChild);