aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-13 23:47:28 +0200
committerEugene Sandulenko2019-10-13 23:48:42 +0200
commite3888d51f4e5cea2da41868375158c19750b68a1 (patch)
tree3d581749912749ca3c716b06a9921e4c7673bc34 /graphics/macgui
parentdf93f8a65802b1ecd126a51f9edf58ce813a7f2a (diff)
downloadscummvm-rg350-e3888d51f4e5cea2da41868375158c19750b68a1.tar.gz
scummvm-rg350-e3888d51f4e5cea2da41868375158c19750b68a1.tar.bz2
scummvm-rg350-e3888d51f4e5cea2da41868375158c19750b68a1.zip
GRAPHICS: MACGUI: Fix menu width when there is a submenu
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 9594aee3da..25db9afacd 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -580,34 +580,34 @@ void MacMenu::processSubmenuTabs(MacMenuSubMenu *submenu) {
Common::U32String tabSymbol("\t");
- // First, we replace \t with one space, and thus, obtain
+ // First, we replace \t with two spaces, and thus, obtain
// the widest string
for (uint i = 0; i < submenu->items.size(); i++) {
MacMenuItem *item = submenu->items[i];
if (item->unicodeText.empty())
continue;
- int pos = item->unicodeText.find(tabSymbol);
+ Common::U32String res(item->unicodeText);
- if (pos == Common::U32String::npos)
- continue;
+ int pos = item->unicodeText.find(tabSymbol);
- // Sanity check
- if (pos == 0 || pos >= item->unicodeText.size())
- error("Malformed menu: tab position");
+ if (pos != Common::U32String::npos) {
+ // Sanity check
+ if (pos == 0 || pos >= item->unicodeText.size())
+ error("Malformed menu: tab position");
- if (item->unicodeText.find(tabSymbol, pos + 1) != Common::U32String::npos)
- error("Malformed menu: extra tab");
+ if (item->unicodeText.find(tabSymbol, pos + 1) != Common::U32String::npos)
+ error("Malformed menu: extra tab");
- haveTabs = true;
+ haveTabs = true;
- Common::U32String start(item->unicodeText.c_str(), &item->unicodeText.c_str()[pos]);
- Common::U32String end(&item->unicodeText.c_str()[pos + 1]);
- Common::U32String res;
+ Common::U32String start(item->unicodeText.c_str(), &item->unicodeText.c_str()[pos]);
+ Common::U32String end(&item->unicodeText.c_str()[pos + 1]);
- res = start;
- res += Common::U32String(" ");
- res += end;
+ res = start;
+ res += Common::U32String(" ");
+ res += end;
+ }
int width = _font->getStringWidth(res);
if (width > maxWidth) {
@@ -672,8 +672,12 @@ int MacMenu::calcSubMenuWidth(MacMenuSubMenu *submenu) {
maxWidth = width;
}
} else if (!item->unicodeText.empty()) {
- // add accelerator
- int width = _font->getStringWidth(item->unicodeText);
+ Common::U32String text(item->unicodeText);
+
+ if (item->submenu != nullptr) // If we're drawing triangle
+ text += Common::U32String(" ");
+
+ int width = _font->getStringWidth(text);
if (width > maxWidth) {
maxWidth = width;
}