MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / stackHorizontal

Method stackHorizontal

Engine/source/gui/containers/guiStackCtrl.cpp:287–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void GuiStackControl::stackHorizontal(bool fromLeft)
288{
289 if( empty() )
290 return;
291
292 S32 begin, end, step;
293 if ( fromLeft )
294 {
295 // Stack from Child0 at left to ChildN at right
296 begin = 0;
297 end = size();
298 step = 1;
299 }
300 else
301 {
302 // Stack from ChildN at left to Child0 at right
303 begin = size()-1;
304 end = -1;
305 step = -1;
306 }
307
308 // Place each visible child control
309 S32 maxHeight = 0;
310 Point2I curPos(0, 0);
311 for ( S32 i = begin; i != end; i += step )
312 {
313 GuiControl * gc = dynamic_cast<GuiControl*>( at(i) );
314 if ( gc && gc->isVisible() )
315 {
316 // Add padding between controls
317 if ( curPos.x > 0 )
318 curPos.x += mPadding;
319
320 Point2I childPos = curPos;
321 if ( !mChangeChildPosition )
322 childPos.y = gc->getTop();
323
324 Point2I childSize( gc->getExtent() );
325 if ( mChangeChildSizeToFit )
326 childSize.y = getHeight();
327
328 gc->resize( childPos, childSize );
329
330 curPos.x += gc->getWidth();
331 maxHeight = getMax( maxHeight, childPos.y + childSize.y );
332 }
333 }
334
335 if ( mDynamicSize )
336 {
337 // Conform our size to the sum of the child sizes.
338 Point2I newPos( getPosition() );
339 Point2I newSize( curPos.x, mDynamicNonStackExtent ? maxHeight : getHeight() );
340
341 newSize.setMax( getMinExtent() );
342
343 // Grow the stack left instead of right?
344 if ( mDynamicPos )

Callers

nothing calls this directly

Calls 13

getMaxFunction · 0.85
getPositionFunction · 0.85
getMinExtentFunction · 0.85
getWidthFunction · 0.85
getExtentMethod · 0.80
emptyFunction · 0.50
sizeFunction · 0.50
getHeightFunction · 0.50
resizeFunction · 0.50
isVisibleMethod · 0.45
resizeMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected