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

Method anchorControl

Engine/source/gui/containers/guiContainer.cpp:356–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354//-----------------------------------------------------------------------------
355
356bool GuiContainer::anchorControl( GuiControl *control, const Point2I &deltaParentExtent )
357{
358 GuiContainer *container = dynamic_cast<GuiContainer*>( control );
359 if( !control || !container )
360 return false;
361
362 // If we're docked, we don't anchor to anything
363 if( (container->getDocking() & Docking::dockAny) || !(container->getDocking() & Docking::dockInvalid) )
364 return false;
365
366 if( deltaParentExtent.isZero() )
367 return false;
368
369 RectI oldRect = control->getBounds();
370 RectI newRect = control->getBounds();
371
372 F32 deltaBottom = mSizingOptions.mAnchorBottom ? (F32)deltaParentExtent.y : 0.0f;
373 F32 deltaRight = mSizingOptions.mAnchorRight ? (F32)deltaParentExtent.x : 0.0f;
374 F32 deltaLeft = mSizingOptions.mAnchorLeft ? 0.0f : (F32)deltaParentExtent.x;
375 F32 deltaTop = mSizingOptions.mAnchorTop ? 0.0f : (F32)deltaParentExtent.y;
376
377 // Apply Delta's to newRect
378 newRect.point.x += (S32)deltaLeft;
379 newRect.extent.x += (S32)(deltaRight - deltaLeft);
380 newRect.point.y += (S32)deltaTop;
381 newRect.extent.y += (S32)(deltaBottom - deltaTop);
382
383 Point2I minExtent = control->getMinExtent();
384 // Only resize if our minExtent is satisfied with it.
385 if( !( newRect.extent.x >= minExtent.x && newRect.extent.y >= minExtent.y ) )
386 return false;
387
388 if( newRect.point == oldRect.point && newRect.extent == oldRect.extent )
389 return false;
390
391 // Finally Size the control
392 control->resize( newRect.point, newRect.extent );
393
394 // We made changes
395 return true;
396}
397
398//-----------------------------------------------------------------------------
399

Callers

nothing calls this directly

Calls 5

getDockingMethod · 0.80
isZeroMethod · 0.45
getBoundsMethod · 0.45
getMinExtentMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected