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

Method onAction

Engine/source/gui/controls/guiPopUpCtrlEx.cpp:1388–1539  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1386
1387//------------------------------------------------------------------------------
1388void GuiPopUpMenuCtrlEx::onAction()
1389{
1390 if (!mActive)
1391 return;
1392
1393 GuiControl *canCtrl = getParent();
1394
1395 addChildren();
1396
1397 GuiCanvas *root = getRoot();
1398 Point2I windowExt = root->getExtent();
1399
1400 mBackground->resize( Point2I(0,0), root->getExtent() );
1401
1402 S32 textWidth = 0, width = getWidth();
1403 //const S32 menuSpace = 5; // Removed as no longer used.
1404 const S32 textSpace = 2;
1405 bool setScroll = false;
1406
1407 for ( U32 i = 0; i < mEntries.size(); ++i )
1408 if ( S32(mProfile->mFont->getStrWidth( mEntries[i].buf )) > textWidth )
1409 textWidth = mProfile->mFont->getStrWidth( mEntries[i].buf );
1410
1411 //if(textWidth > getWidth())
1412 S32 sbWidth = mSc->getControlProfile()->mBorderThickness * 2 + mSc->scrollBarThickness(); // Calculate the scroll bar width
1413 if ( textWidth > ( getWidth() - sbWidth-mProfile->mTextOffset.x - mSc->getChildMargin().x * 2 ) ) // The text draw area to test against is the width of the drop-down minus the scroll bar width, the text margin and the scroll bar child margins.
1414 {
1415 //textWidth +=10;
1416 textWidth +=sbWidth + mProfile->mTextOffset.x + mSc->getChildMargin().x * 2; // The new width is the width of the text plus the scroll bar width plus the text margin size plus the scroll bar child margins.
1417 width = textWidth;
1418
1419 // If a child margin is not defined for the scroll control, let's add
1420 // some space between the text and scroll control for readability
1421 if(mSc->getChildMargin().x == 0)
1422 width += textSpace;
1423 }
1424
1425 //mTl->setCellSize(Point2I(width, mFont->getHeight()+3));
1426 mTl->setCellSize(Point2I(width, mProfile->mFont->getHeight() + textSpace)); // Modified the above line to use textSpace rather than the '3' as this is what is used below.
1427
1428 for ( U32 j = 0; j < mEntries.size(); ++j )
1429 mTl->addEntry( mEntries[j].id, mEntries[j].buf );
1430
1431 if ( mSelIndex >= 0 )
1432 mTl->setSelectedCell( Point2I( 0, mSelIndex ) );
1433
1434 Point2I pointInGC = canCtrl->localToGlobalCoord( getPosition() );
1435 Point2I scrollPoint( pointInGC.x, pointInGC.y + getHeight() );
1436
1437 //Calc max Y distance, so Scroll Ctrl will fit on window
1438 //S32 maxYdis = windowExt.y - pointInGC.y - getHeight() - menuSpace;
1439 S32 sbBorder = mSc->getControlProfile()->mBorderThickness * 2 + mSc->getChildMargin().y * 2; // Added to take into account the border thickness and the margin of the child controls of the scroll control when figuring out the size of the contained text list control
1440 S32 maxYdis = windowExt.y - pointInGC.y - getHeight() - sbBorder; // - menuSpace; // Need to remove the border thickness from the contained control maximum extent and got rid of the 'menuspace' variable
1441
1442 //If scroll bars need to be added
1443 mRevNum = 0; // Added here rather than within the following 'if' statements.
1444 if ( maxYdis < mTl->getHeight() + sbBorder ) // Instead of adding sbBorder, it was: 'textSpace'
1445 {

Callers 1

guiPopUpCtrlEx.cppFile · 0.45

Calls 15

getWidthFunction · 0.85
getPositionFunction · 0.85
getExtentMethod · 0.80
getStrWidthMethod · 0.80
setSelectedCellMethod · 0.80
localToGlobalCoordMethod · 0.80
globalToLocalCoordMethod · 0.80
pushDialogControlMethod · 0.80
getCellSizeMethod · 0.80
scrollCellVisibleMethod · 0.80
Point2IClass · 0.50
getHeightFunction · 0.50

Tested by

no test coverage detected