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, setFocus, void(entity, 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.setFocus(other, NULL);
50 void resizeNotifyNexposee(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
52 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize);
55 void calcNexposee(entity me)
59 * can't put that here ;)
63 vector emins, emaxs, e2mins, e2maxs;
65 for(scale = 0.7;; scale *= 0.9)
67 for(e = me.firstChild; e; e = e.Container_nextSibling)
69 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
70 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
73 for(e = me.firstChild; e; e = e.Container_nextSibling)
75 emins = e.Nexposee_smallOrigin;
76 emaxs = emins + e.Nexposee_smallSize;
77 for(e2 = e.Container_nextSibling; e2; e2 = e2.Container_nextSibling)
79 e2mins = e2.Nexposee_smallOrigin;
80 e2maxs = e2mins + e2.Nexposee_smallSize;
82 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
83 // amins < bmins < amaxs < bmaxs
87 if((e2mins_x - emaxs_x) * (emins_x - e2maxs_x) > 0) // x overlap
88 if((e2mins_y - emaxs_y) * (emins_y - e2maxs_y) > 0) // y overlap
100 for(e = me.firstChild; e; e = e.Container_nextSibling)
102 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
103 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
107 void setNexposeeNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
109 other.Nexposee_scaleCenter = scalecenter;
110 other.Nexposee_smallAlpha = other.Container_alpha = a0;
111 other.Nexposee_mediumAlpha = a1;
114 void drawNexposee(entity me)
119 if(me.animationState == -1)
121 me.animationState = 0;
125 //print(ftos(me.animationState), "\n");
127 f = min(1, frametime * 5);
128 switch(me.animationState)
131 me.animationFactor = 0;
134 me.animationFactor += f;
135 if(me.animationFactor >= 1)
137 me.animationFactor = 1;
138 me.animationState = 2;
139 setFocusContainer(me, me.selectedChild);
143 me.animationFactor = 1;
146 me.animationFactor -= f;
147 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
148 if(me.animationFactor <= 0)
150 me.animationFactor = 0;
151 me.animationState = 0;
152 me.selectedChild = me.mouseFocusedChild;
157 f = min(1, frametime * 10);
158 for(e = me.firstChild; e; e = e.Container_nextSibling)
162 if(e == me.selectedChild)
164 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
165 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
166 a0 = e.Nexposee_mediumAlpha;
167 if(me.animationState == 3)
168 if(e != me.mouseFocusedChild)
169 a0 = e.Nexposee_smallAlpha;
170 a = a0 * (1 - me.animationFactor) + me.animationFactor;
174 // minimum theSize counts
175 e.Container_origin = e.Nexposee_smallOrigin;
176 e.Container_size = e.Nexposee_smallSize;
177 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
179 e.Container_alpha = e.Container_alpha * (1 - f) + a * f;
185 float mousePressNexposee(entity me, vector pos)
187 if(me.animationState == 0)
189 me.mouseFocusedChild = NULL;
190 mouseMoveNexposee(me, pos);
193 me.animationState = 1;
194 setFocusContainer(me, NULL);
198 else if(me.animationState == 2)
200 if(!mousePressContainer(me, pos))
202 me.animationState = 3;
203 setFocusContainer(me, NULL);
210 float mouseReleaseNexposee(entity me, vector pos)
212 if(me.animationState == 2)
213 return mouseReleaseContainer(me, pos);
217 float mouseDragNexposee(entity me, vector pos)
219 if(me.animationState == 2)
220 return mouseDragContainer(me, pos);
224 float mouseMoveNexposee(entity me, vector pos)
227 me.mousePosition = pos;
228 e = me.mouseFocusedChild;
229 me.mouseFocusedChild = me.itemFromPoint(me, pos);
230 if(me.animationState == 2)
231 return mouseMoveContainer(me, pos);
232 if(me.animationState == 0)
234 if(me.mouseFocusedChild)
235 if(me.mouseFocusedChild != e)
236 me.selectedChild = me.mouseFocusedChild;
242 float keyUpNexposee(entity me, float scan, float ascii, float shift)
244 if(me.animationState == 2)
245 return keyUpContainer(me, scan, ascii, shift);
249 float keyDownNexposee(entity me, float scan, float ascii, float shift)
252 if(me.animationState == 2)
253 if(keyDownContainer(me, scan, ascii, shift))
257 if(me.animationState == 0)
262 me.selectedChild = me.selectedChild.Container_prevSibling;
263 if(!me.selectedChild)
264 me.selectedChild = me.lastChild;
269 me.selectedChild = me.selectedChild.Container_nextSibling;
270 if(!me.selectedChild)
271 me.selectedChild = me.firstChild;
275 switch(me.animationState)
279 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER));
283 nexposeeKey = (scan == K_ESCAPE);
288 switch(me.animationState)
292 me.animationState = 1;
296 me.animationState = 3;
300 me.selectedChild = me.focusedChild;
301 if(!me.selectedChild)
302 me.animationState = 0;
303 setFocusContainer(me, NULL);
309 void addItemNexposee(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
311 other.Nexposee_initialSize = theSize;
312 other.Nexposee_initialOrigin = theOrigin;
313 other.Nexposee_initialAlpha = theAlpha;
314 addItemContainer(me, other, theOrigin, theSize, theAlpha);
317 void setFocusNexposee(entity me, entity other)
319 if(me.animationState == 0)
323 me.focusedChild = other;
324 me.selectedChild = other;
325 me.animationState = 1;
328 else if(me.animationState == 2)
332 me.selectedChild = me.focusedChild;
333 me.focusedChild = NULL;
334 me.animationState = 3;