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.
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <BMCPrivate.h>
|
#include <BMCPrivate.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
@@ -137,10 +139,16 @@ _BMCMenuBar_::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
_BMCMenuBar_::Draw(BRect updateRect)
|
_BMCMenuBar_::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (fFixedSize || Bounds().Width() > fMenuField->_MenuBarWidth()) {
|
// Set the width of the menu bar because the menu bar bounds may have
|
||||||
// Set the width of the menu bar because the menu bar bounds have
|
// been expanded by the selected menu item.
|
||||||
// been expanded by the selected menu item.
|
if (fFixedSize)
|
||||||
ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height());
|
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());
|
BRect rect(Bounds());
|
||||||
rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||||
|
|||||||
Reference in New Issue
Block a user