aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-03 15:13:41 +0200
committerEugene Sandulenko2019-10-03 21:51:28 +0200
commitc6930f2f78471e1af3e70967b1f3f7142c233bc4 (patch)
treed4a3114fdf1ba90ea9a3e54fcc239453bef5288d /graphics/macgui
parent09b1f9d6c1ddae7ed648fb09fb7f81f72c7a0c66 (diff)
downloadscummvm-rg350-c6930f2f78471e1af3e70967b1f3f7142c233bc4.tar.gz
scummvm-rg350-c6930f2f78471e1af3e70967b1f3f7142c233bc4.tar.bz2
scummvm-rg350-c6930f2f78471e1af3e70967b1f3f7142c233bc4.zip
GRAPHICS: MACGUI: Implement hovering out of menus behaviour
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macmenu.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 3bcfdcc996..61fa02b7b9 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -837,7 +837,7 @@ bool MacMenu::mouseClick(int x, int y) {
if (_menustack.size() > 0 && _menustack.back()->bbox.contains(x, y)) {
MacMenuSubMenu *it = _menustack.back();
- int numSubItem = (y - it->bbox.top) / kMenuDropdownItemHeight;
+ int numSubItem = MIN<int>((y - it->bbox.top) / kMenuDropdownItemHeight, it->subitems.size() - 1);
if (numSubItem != _activeSubItem) {
_activeSubItem = numSubItem;
@@ -851,32 +851,36 @@ bool MacMenu::mouseClick(int x, int y) {
return true;
}
- if (_activeSubItem != -1) {
- if (_menustack.back()->subitems[_activeSubItem]->submenu != nullptr) {
- if (_menustack.back()->subitems[_activeSubItem]->submenu->bbox.contains(x, y)) {
- _menustack.push_back(_menustack.back()->subitems[_activeSubItem]->submenu);
+ if (_activeSubItem != -1 && _menustack.back()->subitems[_activeSubItem]->submenu != nullptr) {
+ if (_menustack.back()->subitems[_activeSubItem]->submenu->bbox.contains(x, y)) {
+ _menustack.push_back(_menustack.back()->subitems[_activeSubItem]->submenu);
- _activeSubItem = 0;
- _contentIsDirty = true;
+ _activeSubItem = 0;
+ _contentIsDirty = true;
- _menustack.back()->highlight = 0;
+ _menustack.back()->highlight = 0;
- return true;
- }
+ 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
+ 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();
+ _menustack.pop_back();
- _activeSubItem = _menustack.back()->highlight;
+ MacMenuSubMenu *menu = _menustack.back();
- _contentIsDirty = true;
+ _activeSubItem = MIN<int>((y - menu->bbox.top) / kMenuDropdownItemHeight, menu->subitems.size() - 1);
- return true;
- }
+ menu->highlight = _activeSubItem;
+
+ renderSubmenu(menu);
+
+ _contentIsDirty = true;
+
+ return true;
}
}