[haiku-commits] haiku: hrev45690 - src/kits/interface

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 16 May 2013 02:05:45 +0200 (CEST)

hrev45690 adds 1 changeset to branch 'master'
old head: ad6158096cc2a81e355597469c319b05a27eb7d8
new head: 01636e8f2af4878e9181ff1a18721494e5222e75
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=01636e8+%5Ead61580

----------------------------------------------------------------------------

01636e8: Adjust menu field's menu bar height in auto mode
  
  On IRC diver pointed out to me that KeymapSwitcher had a menu field that
  was drawing as just a line since my recent change to BMenuField. I did a
  little research and discovered that this was because the menu field in
  KeymapSwitch was not using the layout APIs and it's frame rect was set to
  0 height.
  
  I did a little more research and experimented with menu fields in
  BeOS R5. I discovered that in R5 if the menu field is set to auto-size
  mode then the menu bar inside ignores the height of the menu field frame
  and uses the BMenuBar's preferred height instead.
  
  So, I adjusted the BMenuField code in Haiku accordingly. This should make
  Haiku match the behavior of BeOS R5 in auto-size mode. For fixed-size mode
  it should also work the same, although some more testing is needed to
  see if there are any regressions there.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45690
Commit:      01636e8f2af4878e9181ff1a18721494e5222e75
URL:         http://cgit.haiku-os.org/haiku/commit/?id=01636e8
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed May 15 23:44:52 2013 UTC

----------------------------------------------------------------------------

1 file changed, 11 insertions(+), 3 deletions(-)
src/kits/interface/BMCPrivate.cpp | 14 +++++++++++---

----------------------------------------------------------------------------

diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index f1dde02..491b00d 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -11,6 +11,8 @@
 
 #include <BMCPrivate.h>
 
+#include <algorithm>
+
 #include <ControlLook.h>
 #include <LayoutUtils.h>
 #include <MenuField.h>
@@ -137,10 +139,16 @@ _BMCMenuBar_::AttachedToWindow()
 void
 _BMCMenuBar_::Draw(BRect updateRect)
 {
-       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.
+       // Set the width of the menu bar because the menu bar bounds may have
+       // been expanded by the selected menu item.
+       if (fFixedSize)
                ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height());
+       else {
+               // For compatability with BeOS R5 set the height to the 
preferred height
+               // in auto-size mode ignoring the height of the menu field.
+               float height;
+               BMenuBar::GetPreferredSize(NULL, &height);
+               ResizeTo(std::min(Bounds().Width(), 
fMenuField->_MenuBarWidth()), height);
        }
        BRect rect(Bounds());
        rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);


Other related posts: