From 4436b7269deb26c44ccaa9f57a1a041e13f1afed Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sun, 30 Apr 2006 20:24:30 +0000 Subject: [PATCH] Menuitems are layoutted better, fixing bug 526 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17282 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 12 +++++++----- src/kits/interface/MenuWindow.cpp | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 3714f2f908..1e8eacf4f9 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1400,22 +1400,24 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems, if (item->fModifiers && item->fShortcutChar) iWidth += 25.0f; + if (item->fSubmenu != NULL) + iWidth += 20.0f; item->fBounds.left = 0.0f; item->fBounds.top = frame.bottom; item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom; - frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right + 20); + frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right); frame.bottom = item->fBounds.bottom + 1.0f; } } if (fMaxContentWidth > 0) frame.right = min_c(frame.right, fMaxContentWidth); - //if (moveItems) { + if (moveItems) { for (int32 i = 0; i < fItems.CountItems(); i++) ItemAt(i)->fBounds.right = frame.right; - //} + } frame.right = ceilf(frame.right); frame.bottom--; break; @@ -1441,10 +1443,10 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems, } } - //if (moveItems) { + if (moveItems) { for (int32 i = 0; i < fItems.CountItems(); i++) ItemAt(i)->fBounds.bottom = frame.bottom; - //} + } frame.right = ceilf(frame.right); break; diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp index c56fcb4d50..b84495eec8 100644 --- a/src/kits/interface/MenuWindow.cpp +++ b/src/kits/interface/MenuWindow.cpp @@ -119,7 +119,8 @@ BMenuFrame::Draw(BRect updateRect) font_height height; GetFontHeight(&height); SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT)); - DrawString(kEmptyMenuLabel, BPoint(3, ceilf(height.ascent + 2))); + BPoint where((Bounds().Width() - fMenu->StringWidth(kEmptyMenuLabel)) / 2, ceilf(height.ascent + 1)); + DrawString(kEmptyMenuLabel, where); } SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));