Merge pull request #2340 from Areloch/popupMenuBGFix

Makes the popups correctly operate anywhere in the space of the canvas
This commit is contained in:
Areloch 2019-03-31 12:36:15 -05:00 committed by GitHub
commit e7c485b113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -282,11 +282,6 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
if (owner == NULL) if (owner == NULL)
return; return;
GuiControl* editorGui;
Sim::findObject("EditorGui", editorGui);
if (editorGui)
{
GuiPopupMenuBackgroundCtrl* backgroundCtrl; GuiPopupMenuBackgroundCtrl* backgroundCtrl;
Sim::findObject("PopUpMenuControl", backgroundCtrl); Sim::findObject("PopUpMenuControl", backgroundCtrl);
@ -340,7 +335,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
if(backgroundCtrl->mMenuBarCtrl == nullptr) if(backgroundCtrl->mMenuBarCtrl == nullptr)
backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl(); backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl();
backgroundCtrl->setExtent(editorGui->getExtent()); backgroundCtrl->setExtent(owner->getExtent());
mTextList->clear(); mTextList->clear();
@ -430,8 +425,16 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
mTextList->setPosition(popupPos.x - widthDiff, popupPos.y); mTextList->setPosition(popupPos.x - widthDiff, popupPos.y);
} }
mTextList->setHidden(false); //If we'd overshoot the screen vertically, just mirror the axis so we're above the mouse
S32 heightDiff = (mTextList->getPosition().y + mTextList->getExtent().y) - backgroundCtrl->getHeight();
if (heightDiff > 0)
{
Point2I popupPos = mTextList->getPosition();
mTextList->setPosition(popupPos.x, popupPos.y - mTextList->getExtent().y);
} }
mTextList->setHidden(false);
} }
void PopupMenu::hidePopup() void PopupMenu::hidePopup()