aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-03 00:04:12 +0200
committerEugene Sandulenko2019-10-03 00:05:12 +0200
commitee139e86f31dd67d7a59cf7dc0da9efba212d23b (patch)
treec59e2e2202e389a5eaca19e15d63d72f22af37dd /graphics/macgui
parent571a455c6a8f3e5b7d2ff1a149c52fa379ec0f7d (diff)
downloadscummvm-rg350-ee139e86f31dd67d7a59cf7dc0da9efba212d23b.tar.gz
scummvm-rg350-ee139e86f31dd67d7a59cf7dc0da9efba212d23b.tar.bz2
scummvm-rg350-ee139e86f31dd67d7a59cf7dc0da9efba212d23b.zip
GRAPHICS: MACGUI: Correctly render highlights for the open submenus
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macmenu.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 895f097d27..ed430cb5cd 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -94,6 +94,9 @@ struct MacMenuSubItem {
struct MacMenuSubMenu {
SubItemArray subitems;
Common::Rect bbox;
+ int highlight;
+
+ MacMenuSubMenu() : highlight(-1) {}
~MacMenuSubMenu() {
for (uint i = 0; i < subitems.size(); i++)
@@ -695,7 +698,7 @@ void MacMenu::renderSubmenu(MacMenuSubMenu *menu, bool recursive) {
int arrowX = r->right - 14;
int color = _wm->_colorBlack;
- if (i == (uint)_activeSubItem && (!text.empty() || !unicodeText.empty()) && menu->subitems[i]->enabled) {
+ if (i == (uint)menu->highlight && (!text.empty() || !unicodeText.empty()) && menu->subitems[i]->enabled) {
color = _wm->_colorWhite;
Common::Rect trect(r->left, y - (_wm->_fontMan->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
@@ -753,8 +756,8 @@ void MacMenu::renderSubmenu(MacMenuSubMenu *menu, bool recursive) {
y += kMenuDropdownItemHeight;
}
- if (recursive && _activeSubItem != -1 && menu->subitems[_activeSubItem]->submenu != nullptr)
- renderSubmenu(menu->subitems[_activeSubItem]->submenu, false);
+ if (recursive && menu->highlight != -1 && menu->subitems[menu->highlight]->submenu != nullptr)
+ renderSubmenu(menu->subitems[menu->highlight]->submenu, false);
_contentIsDirty = true;
//g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
@@ -838,6 +841,8 @@ bool MacMenu::mouseClick(int x, int y) {
if (numSubItem != _activeSubItem) {
_activeSubItem = numSubItem;
+ it->highlight = _activeSubItem;
+
renderSubmenu(it);
_contentIsDirty = true;
}
@@ -853,15 +858,19 @@ bool MacMenu::mouseClick(int x, int y) {
_activeSubItem = 0;
_contentIsDirty = true;
+ _menustack.back()->highlight = 0;
+
return true;
}
}
if (_menustack.size() > 1) {
if (_menustack[_menustack.size() - 2]->bbox.contains(x, y)) {
+ _menustack.back()->highlight = -1; // Erase it for the closed popup
+
_menustack.pop_back();
- _activeSubItem = (y - _menustack.back()->bbox.top) / kMenuDropdownItemHeight;
+ _activeSubItem = _menustack.back()->highlight;
_contentIsDirty = true;