From 298cd4c2bffa793e9d17f22f5d2d6f49c3d07a73 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 9 May 2013 21:26:36 -0400 Subject: [PATCH] BMenuField: Fix menu bar resizing in auto-size mode. Fixes #9753 (for real this time) Don't resize the menu field when the menu bar resizes, the menu field stays the same size because we'll need to use it's width to check when the menu bar width has expanded beyond its width. Then, if the selected menu item expands the menu bar to a width greater than the width of the menu field resize it to the menu field width. --- src/kits/interface/BMCPrivate.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 6dc16759fd..f1dde0267d 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -137,12 +137,10 @@ _BMCMenuBar_::AttachedToWindow() void _BMCMenuBar_::Draw(BRect updateRect) { - if (fFixedSize) { - float height; - GetPreferredSize(NULL, &height); - ResizeTo(fMenuField->_MenuBarWidth(), height); - // Set the width to the menu field width because the menubar - // bounds are expanded by the selected menu item. + if (fFixedSize || Bounds().Width() > fMenuField->_MenuBarWidth()) { + // Set the width of the menu bar because the menu bar bounds have + // been expanded by the selected menu item. + ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height()); } BRect rect(Bounds()); rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); @@ -195,15 +193,6 @@ _BMCMenuBar_::FrameResized(float width, float height) } } - if (!fFixedSize && ResizingMode() == (B_FOLLOW_LEFT | B_FOLLOW_TOP)) { - // we have been shrinked or enlarged and need to take care - // of the size of the parent menu field as well - // NOTE: no worries about follow mode, we follow left and top - // in autosize mode - diff = Frame().right + 2 - fMenuField->Bounds().right; - fMenuField->ResizeBy(diff, 0.0); - } - BMenuBar::FrameResized(width, height); }