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

Method scrollToObject

Engine/source/gui/containers/guiScrollCtrl.cpp:570–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568//-----------------------------------------------------------------------------
569
570void GuiScrollCtrl::scrollToObject(GuiControl *targetControl)
571{
572 bool isValidChild = false;
573 Point2I relativePosition = targetControl->getPosition();
574 GuiControl* parentControl = targetControl->getParent();
575 while (parentControl)
576 {
577 GuiScrollCtrl* scrollControl = dynamic_cast<GuiScrollCtrl*>(parentControl);
578 if (scrollControl == this)
579 {
580 relativePosition += scrollControl->getChildRelPos();
581 isValidChild = true;
582 break;
583 }
584
585 relativePosition += parentControl->getPosition();
586 parentControl = parentControl->getParent();
587 }
588
589 if (isValidChild)
590 {
591 scrollRectVisible(RectI(relativePosition, targetControl->getExtent()));
592 }
593 else
594 {
595 Con::errorf("GuiScrollCtrl::scrollToObject() - Specified object is not a child of this scroll control (%d)!", targetControl->getId());
596 }
597}
598
599//-----------------------------------------------------------------------------
600

Callers 1

guiScrollCtrl.cppFile · 0.80

Calls 6

getExtentMethod · 0.80
getIdMethod · 0.65
RectIClass · 0.50
errorfFunction · 0.50
getPositionMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected