/////////////////////////////////////////////////////////////////////
| 295 | |
| 296 | ////////////////////////////////////////////////////////////////////////// |
| 297 | void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */) |
| 298 | { |
| 299 | if (owner == NULL) |
| 300 | return; |
| 301 | |
| 302 | GuiPopupMenuBackgroundCtrl* backgroundCtrl; |
| 303 | Sim::findObject("PopUpMenuControl", backgroundCtrl); |
| 304 | |
| 305 | GuiControlProfile* profile; |
| 306 | Sim::findObject("ToolsGuiMenuBarProfile", profile); |
| 307 | |
| 308 | if (!profile) |
| 309 | return; |
| 310 | |
| 311 | if (mTextList == nullptr) |
| 312 | { |
| 313 | mTextList = new GuiPopupMenuTextListCtrl(); |
| 314 | mTextList->registerObject(); |
| 315 | mTextList->setControlProfile(profile); |
| 316 | mTextList->mRowHeightPadding = 5; |
| 317 | |
| 318 | mTextList->mPopup = this; |
| 319 | mTextList->mMenuBar = getMenuBarCtrl(); |
| 320 | } |
| 321 | |
| 322 | if (!backgroundCtrl) |
| 323 | { |
| 324 | backgroundCtrl = new GuiPopupMenuBackgroundCtrl(); |
| 325 | |
| 326 | backgroundCtrl->registerObject("PopUpMenuControl"); |
| 327 | } |
| 328 | |
| 329 | if (!backgroundCtrl || !mTextList) |
| 330 | return; |
| 331 | |
| 332 | if (!mIsSubmenu) |
| 333 | { |
| 334 | //if we're a 'parent' menu, then tell the background to clear out all existing other popups |
| 335 | |
| 336 | backgroundCtrl->clearPopups(); |
| 337 | } |
| 338 | |
| 339 | //find out if we're doing a first-time add |
| 340 | S32 popupIndex = backgroundCtrl->findPopupMenu(this); |
| 341 | |
| 342 | if (popupIndex == -1) |
| 343 | { |
| 344 | backgroundCtrl->addObject(mTextList); |
| 345 | backgroundCtrl->mPopups.push_back(this); |
| 346 | } |
| 347 | |
| 348 | mTextList->mBackground = backgroundCtrl; |
| 349 | |
| 350 | owner->pushDialogControl(backgroundCtrl, 10); |
| 351 | |
| 352 | //Set the background control's menubar, if any, and if it's not already set |
| 353 | if(backgroundCtrl->mMenuBarCtrl == nullptr) |
| 354 | backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl(); |
no test coverage detected