aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-03 21:50:54 +0200
committerEugene Sandulenko2019-10-03 21:51:28 +0200
commit3f7112d5c9a97aead70616ab5ecde5f0efe41968 (patch)
tree1fc0d8f6f2a5263dffd07b17f77cf0f97bd7b5cc /graphics/macgui
parent55c5664cedcf978560ea3277a99a92a181be8021 (diff)
downloadscummvm-rg350-3f7112d5c9a97aead70616ab5ecde5f0efe41968.tar.gz
scummvm-rg350-3f7112d5c9a97aead70616ab5ecde5f0efe41968.tar.bz2
scummvm-rg350-3f7112d5c9a97aead70616ab5ecde5f0efe41968.zip
GRAPHICS: MACGUI: Refactor some code
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macmenu.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 9d05c76fc3..7ed4f3162f 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -102,6 +102,8 @@ struct MacMenuSubMenu {
for (uint i = 0; i < subitems.size(); i++)
delete subitems[i];
}
+
+ int ytoItem(int y) { return MIN<int>((y - bbox.top) / kMenuDropdownItemHeight, subitems.size() - 1); }
};
MacMenuSubItem::~MacMenuSubItem() {
@@ -837,7 +839,7 @@ bool MacMenu::mouseClick(int x, int y) {
if (_menustack.size() > 0 && _menustack.back()->bbox.contains(x, y)) {
MacMenuSubMenu *menu = _menustack.back();
- int numSubItem = MIN<int>((y - menu->bbox.top) / kMenuDropdownItemHeight, menu->subitems.size() - 1);
+ int numSubItem = menu->ytoItem(y);
if (numSubItem != _activeSubItem) {
_activeSubItem = numSubItem;
@@ -870,8 +872,7 @@ bool MacMenu::mouseClick(int x, int y) {
MacMenuSubMenu *menu = _menustack.back();
- _activeSubItem = MIN<int>((y - menu->bbox.top) / kMenuDropdownItemHeight, menu->subitems.size() - 1);
- menu->highlight = _activeSubItem;
+ _activeSubItem = menu->highlight = menu->ytoItem(y);
_contentIsDirty = true;