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

Method computeSizes

Engine/source/gui/containers/guiScrollCtrl.cpp:322–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320//-----------------------------------------------------------------------------
321
322void GuiScrollCtrl::computeSizes()
323{
324 S32 thickness = (mProfile ? mProfile->mBorderThickness : 1);
325 Point2I borderExtent(thickness, thickness);
326 mContentPos = borderExtent + mChildMargin;
327 mContentExt = getExtent() - (mChildMargin * 2)
328 - (borderExtent * 2);
329
330 Point2I childLowerRight;
331
332 mHBarEnabled = false;
333 mVBarEnabled = false;
334 mHasVScrollBar = (mForceVScrollBar == ScrollBarAlwaysOn);
335 mHasHScrollBar = (mForceHScrollBar == ScrollBarAlwaysOn);
336
337 setUpdate();
338
339 if (calcChildExtents())
340 {
341 childLowerRight = mChildPos + mChildExt;
342
343 if (mHasVScrollBar)
344 mContentExt.x -= mScrollBarThickness;
345 if (mHasHScrollBar)
346 mContentExt.y -= mScrollBarThickness;
347 if (mChildExt.x > mContentExt.x && (mForceHScrollBar == ScrollBarDynamic))
348 {
349 mHasHScrollBar = true;
350 mContentExt.y -= mScrollBarThickness;
351 }
352 if (mChildExt.y > mContentExt.y && (mForceVScrollBar == ScrollBarDynamic))
353 {
354 mHasVScrollBar = true;
355 mContentExt.x -= mScrollBarThickness;
356
357 // If Extent X Changed, check Horiz Scrollbar.
358 if (mChildExt.x > mContentExt.x && !mHasHScrollBar && (mForceHScrollBar == ScrollBarDynamic))
359 {
360 mHasHScrollBar = true;
361 mContentExt.y -= mScrollBarThickness;
362 }
363 }
364 Point2I contentLowerRight = mContentPos + mContentExt;
365
366 // see if the child controls need to be repositioned (null space in control)
367 Point2I delta(0,0);
368
369 if (mChildPos.x > mContentPos.x)
370 delta.x = mContentPos.x - mChildPos.x;
371 else if (contentLowerRight.x > childLowerRight.x)
372 {
373 S32 diff = contentLowerRight.x - childLowerRight.x;
374 delta.x = getMin(mContentPos.x - mChildPos.x, diff);
375 }
376
377 //reposition the children if the child extent > the scroll content extent
378 if (mChildPos.y > mContentPos.y)
379 delta.y = mContentPos.y - mChildPos.y;

Callers 1

guiScrollCtrl.cppFile · 0.45

Calls 6

beginFunction · 0.85
endFunction · 0.85
setPositionMethod · 0.45
getPositionMethod · 0.45
setHeightMethod · 0.45
setWidthMethod · 0.45

Tested by

no test coverage detected