@@ -37,6 +37,8 @@ GuiExpandCtrl::GuiExpandCtrl()
37
37
mEasingFunction = EasingFunction::Linear;
38
38
mAnimationLength = 500 ;
39
39
mCalcGuard = false ;
40
+
41
+ setField (" profile" , " GuiDefaultProfile" );
40
42
}
41
43
42
44
void GuiExpandCtrl::initPersistFields ()
@@ -47,6 +49,13 @@ void GuiExpandCtrl::initPersistFields()
47
49
addField (" easeTimeExpand" , TypeS32, Offset (mAnimationLength , GuiExpandCtrl));
48
50
}
49
51
52
+ void GuiExpandCtrl::addObject (SimObject* obj)
53
+ {
54
+ Parent::addObject (obj);
55
+
56
+ toggleHiddenChildren ();
57
+ }
58
+
50
59
void GuiExpandCtrl::parentResized (const Point2I &oldParentExtent, const Point2I &newParentExtent)
51
60
{
52
61
Point2I newPosition = getPosition ();
@@ -114,6 +123,7 @@ void GuiExpandCtrl::parentResized(const Point2I &oldParentExtent, const Point2I
114
123
else
115
124
{
116
125
mBounds .extent = mCollapsedExtent ;
126
+ toggleHiddenChildren ();
117
127
}
118
128
setUpdate ();
119
129
}
@@ -122,6 +132,7 @@ void GuiExpandCtrl::childResized(GuiControl* child)
122
132
{
123
133
calcExpandedExtent ();
124
134
Parent::childResized (child);
135
+ toggleHiddenChildren ();
125
136
}
126
137
127
138
void GuiExpandCtrl::setCollapsedExtent (const Point2I &extent)
@@ -161,6 +172,15 @@ void GuiExpandCtrl::setExpanded(bool isExpanded)
161
172
mAnimationProgress = 1 - mAnimationProgress ;
162
173
mExpanded = isExpanded;
163
174
setProcessTicks (true );
175
+
176
+ if (mExpanded )
177
+ {
178
+ startExpand ();
179
+ }
180
+ else
181
+ {
182
+ startCollapse ();
183
+ }
164
184
}
165
185
166
186
bool GuiExpandCtrl::processExpansion ()
@@ -205,6 +225,14 @@ bool GuiExpandCtrl::processExpansion()
205
225
if (mAnimationProgress >= 1 .0f )
206
226
{
207
227
mAnimationProgress = 1 .0f ;
228
+ if (!mExpanded )
229
+ {
230
+ collapseComplete ();
231
+ }
232
+ else
233
+ {
234
+ expandComplete ();
235
+ }
208
236
return false ;
209
237
}
210
238
return true ;
@@ -221,4 +249,62 @@ void GuiExpandCtrl::processTick()
221
249
{
222
250
setProcessTicks (false );
223
251
}
252
+ }
253
+
254
+ void GuiExpandCtrl::startExpand ()
255
+ {
256
+ if (isMethod (" onStartExpand" ))
257
+ {
258
+ Con::executef (this , 2 , " onStartExpand" );
259
+ }
260
+
261
+ toggleHiddenChildren ();
262
+ }
263
+
264
+ void GuiExpandCtrl::startCollapse ()
265
+ {
266
+ if (isMethod (" onStartCollapse" ))
267
+ {
268
+ Con::executef (this , 2 , " onStartCollapse" );
269
+ }
270
+ }
271
+
272
+ void GuiExpandCtrl::expandComplete ()
273
+ {
274
+ if (isMethod (" onExpandComplete" ))
275
+ {
276
+ Con::executef (this , 2 , " onExpandComplete" );
277
+ }
278
+ }
279
+
280
+ void GuiExpandCtrl::collapseComplete ()
281
+ {
282
+ if (isMethod (" onCollapseComplete" ))
283
+ {
284
+ Con::executef (this , 2 , " onCollapseComplete" );
285
+ }
286
+
287
+ toggleHiddenChildren ();
288
+ }
289
+
290
+ void GuiExpandCtrl::toggleHiddenChildren ()
291
+ {
292
+ RectI innerRect = getInnerRect ();
293
+ innerRect.point = Point2I::Zero;
294
+
295
+ for (iterator i = begin (); i != end (); i++)
296
+ {
297
+ GuiControl* ctrl = static_cast <GuiControl*>(*i);
298
+
299
+ RectI childBounds = ctrl->getBounds ();
300
+ RectI parentBounds = RectI (innerRect);
301
+ if (!mExpanded && !parentBounds.intersect (childBounds))
302
+ {
303
+ ctrl->mVisible = false ;
304
+ }
305
+ else
306
+ {
307
+ ctrl->mVisible = true ;
308
+ }
309
+ }
224
310
}
0 commit comments