Fixed recently introduced regressions with layouted BMenuFields. When passing
fixedSize=true to the private BMenuBar class, it would set the follow mode in AttachedToWindow() such that BMenu would calculate the minimum width differently. Also fixes ticket #3606. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29691 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2006, Haiku Inc.
|
* Copyright 2001-2009 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -58,27 +58,31 @@ _BMCFilter_::operator=(const _BMCFilter_ &)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField *menuField)
|
// #pragma mark -
|
||||||
: BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_ROW,
|
|
||||||
|
|
||||||
|
_BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField)
|
||||||
|
:
|
||||||
|
BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_ROW,
|
||||||
!fixedSize),
|
!fixedSize),
|
||||||
fMenuField(menuField),
|
fMenuField(menuField),
|
||||||
fFixedSize(fixedSize),
|
fFixedSize(fixedSize),
|
||||||
fRunner(NULL),
|
fRunner(NULL),
|
||||||
fShowPopUpMarker(true)
|
fShowPopUpMarker(true)
|
||||||
{
|
{
|
||||||
SetFlags(Flags() | B_FRAME_EVENTS);
|
_Init(true);
|
||||||
SetBorder(B_BORDER_CONTENTS);
|
}
|
||||||
|
|
||||||
float left, top, right, bottom;
|
|
||||||
GetItemMargins(&left, &top, &right, &bottom);
|
|
||||||
// give a bit more space to draw the small thumb
|
|
||||||
left -= 1;
|
|
||||||
right += 3;
|
|
||||||
SetItemMargins(left, top, right, bottom);
|
|
||||||
|
|
||||||
SetMaxContentWidth(frame.Width() - (left + right));
|
_BMCMenuBar_::_BMCMenuBar_(bool fixedSize, BMenuField* menuField)
|
||||||
|
:
|
||||||
fPreviousWidth = frame.Width();
|
BMenuBar("_mc_mb_", B_ITEMS_IN_ROW, !fixedSize),
|
||||||
|
fMenuField(menuField),
|
||||||
|
fFixedSize(fixedSize),
|
||||||
|
fRunner(NULL),
|
||||||
|
fShowPopUpMarker(true)
|
||||||
|
{
|
||||||
|
_Init(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,33 +125,10 @@ _BMCMenuBar_::AttachedToWindow()
|
|||||||
// Don't cause the KeyMenuBar to change by being attached
|
// Don't cause the KeyMenuBar to change by being attached
|
||||||
BMenuBar *menuBar = Window()->KeyMenuBar();
|
BMenuBar *menuBar = Window()->KeyMenuBar();
|
||||||
BMenuBar::AttachedToWindow();
|
BMenuBar::AttachedToWindow();
|
||||||
if (fFixedSize)
|
|
||||||
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
Window()->SetKeyMenuBar(menuBar);
|
Window()->SetKeyMenuBar(menuBar);
|
||||||
|
|
||||||
float left, top, right, bottom;
|
if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0)
|
||||||
GetItemMargins(&left, &top, &right, &bottom);
|
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO: Better fix would be to make BMenuItem draw text properly
|
|
||||||
// centered
|
|
||||||
font_height fontHeight;
|
|
||||||
GetFontHeight(&fontHeight);
|
|
||||||
top = ceilf((Bounds().Height() - ceilf(fontHeight.ascent)
|
|
||||||
- ceilf(fontHeight.descent)) / 2) + 1;
|
|
||||||
bottom = top - 1;
|
|
||||||
#else
|
|
||||||
// TODO: Fix content location properly. This is just a quick fix to
|
|
||||||
// make the BMenuField label and the super-item of the BMenuBar
|
|
||||||
// align vertically.
|
|
||||||
top++;
|
|
||||||
bottom--;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (be_control_look)
|
|
||||||
left = right = be_control_look->DefaultLabelSpacing();
|
|
||||||
|
|
||||||
SetItemMargins(left, top, right + fShowPopUpMarker ? 10 : 0, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -392,3 +373,41 @@ _BMCMenuBar_
|
|||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_BMCMenuBar_::_Init(bool setMaxContentWidth)
|
||||||
|
{
|
||||||
|
SetFlags(Flags() | B_FRAME_EVENTS);
|
||||||
|
SetBorder(B_BORDER_CONTENTS);
|
||||||
|
|
||||||
|
float left, top, right, bottom;
|
||||||
|
GetItemMargins(&left, &top, &right, &bottom);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// TODO: Better fix would be to make BMenuItem draw text properly
|
||||||
|
// centered
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
top = ceilf((Bounds().Height() - ceilf(fontHeight.ascent)
|
||||||
|
- ceilf(fontHeight.descent)) / 2) + 1;
|
||||||
|
bottom = top - 1;
|
||||||
|
#else
|
||||||
|
// TODO: Fix content location properly. This is just a quick fix to
|
||||||
|
// make the BMenuField label and the super-item of the BMenuBar
|
||||||
|
// align vertically.
|
||||||
|
top++;
|
||||||
|
bottom--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (be_control_look)
|
||||||
|
left = right = be_control_look->DefaultLabelSpacing();
|
||||||
|
|
||||||
|
SetItemMargins(left, top, right + fShowPopUpMarker ? 10 : 0, bottom);
|
||||||
|
|
||||||
|
fPreviousWidth = Bounds().Width();
|
||||||
|
|
||||||
|
if (setMaxContentWidth)
|
||||||
|
SetMaxContentWidth(fPreviousWidth - (left + right));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1031,16 +1031,20 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
|
|||||||
fMenu = menu;
|
fMenu = menu;
|
||||||
InitMenu(menu);
|
InitMenu(menu);
|
||||||
|
|
||||||
frame.left = _MenuBarOffset();
|
if ((Flags() & B_SUPPORTS_LAYOUT)) {
|
||||||
frame.top = kVMargin;
|
fMenuBar = new _BMCMenuBar_(fixedSize, this);
|
||||||
frame.right -= kVMargin;
|
} else {
|
||||||
frame.bottom -= kVMargin;
|
frame.left = _MenuBarOffset();
|
||||||
|
frame.top = kVMargin;
|
||||||
TRACE("frame(%.1f, %.1f, %.1f, %.1f) (%.2f, %.2f)\n",
|
frame.right -= kVMargin;
|
||||||
frame.left, frame.top, frame.right, frame.bottom,
|
frame.bottom -= kVMargin;
|
||||||
frame.Width(), frame.Height());
|
|
||||||
|
TRACE("frame(%.1f, %.1f, %.1f, %.1f) (%.2f, %.2f)\n",
|
||||||
fMenuBar = new _BMCMenuBar_(frame, fixedSize, this);
|
frame.left, frame.top, frame.right, frame.bottom,
|
||||||
|
frame.Width(), frame.Height());
|
||||||
|
|
||||||
|
fMenuBar = new _BMCMenuBar_(frame, fixedSize, this);
|
||||||
|
}
|
||||||
|
|
||||||
if (fixedSize) {
|
if (fixedSize) {
|
||||||
// align the menu bar in the full available space
|
// align the menu bar in the full available space
|
||||||
|
|||||||
Reference in New Issue
Block a user