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

Method onAction

Engine/source/gui/controls/guiPopUpCtrl.cpp:1220–1345  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1218
1219//------------------------------------------------------------------------------
1220void GuiPopUpMenuCtrl::onAction()
1221{
1222 GuiControl *canCtrl = getParent();
1223
1224 addChildren();
1225
1226 GuiCanvas *root = getRoot();
1227 Point2I windowExt = root->getExtent();
1228
1229 mBackground->resize( Point2I(0,0), root->getExtent() );
1230
1231 S32 textWidth = 0, width = getWidth();
1232 const S32 textSpace = 2;
1233 bool setScroll = false;
1234
1235 for ( U32 i = 0; i < mEntries.size(); ++i )
1236 if ( S32(mProfile->mFont->getStrWidth( mEntries[i].buf )) > textWidth )
1237 textWidth = mProfile->mFont->getStrWidth( mEntries[i].buf );
1238
1239 S32 sbWidth = mSc->getControlProfile()->mBorderThickness * 2 + mSc->scrollBarThickness(); // Calculate the scroll bar width
1240 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.
1241 {
1242 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.
1243 width = textWidth;
1244
1245 // If a child margin is not defined for the scroll control, let's add
1246 // some space between the text and scroll control for readability
1247 if(mSc->getChildMargin().x == 0)
1248 width += textSpace;
1249 }
1250
1251 mTl->setCellSize(Point2I(width, mProfile->mFont->getHeight() + textSpace));
1252
1253 for ( U32 j = 0; j < mEntries.size(); ++j )
1254 mTl->addEntry( mEntries[j].id, mEntries[j].buf );
1255
1256 if ( mSelIndex >= 0 )
1257 mTl->setSelectedCell( Point2I( 0, mSelIndex ) );
1258
1259 Point2I pointInGC = canCtrl->localToGlobalCoord( getPosition() );
1260 Point2I scrollPoint( pointInGC.x, pointInGC.y + getHeight() );
1261
1262 //Calc max Y distance, so Scroll Ctrl will fit on window
1263
1264 S32 sbBorder = mSc->getControlProfile()->mBorderThickness * 2 + mSc->getChildMargin().y * 2;
1265 S32 maxYdis = windowExt.y - pointInGC.y - getHeight() - sbBorder;
1266
1267 //If scroll bars need to be added
1268 mRevNum = 0;
1269 if ( maxYdis < mTl->getHeight() + sbBorder )
1270 {
1271 //Should we pop menu list above the button
1272 if ( maxYdis < pointInGC.y )
1273 {
1274 if(mReverseTextList)
1275 reverseTextList();
1276
1277 maxYdis = pointInGC.y;

Callers 1

DefineEngineMethodFunction · 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