diff --git a/headers/os/interface/MenuBar.h b/headers/os/interface/MenuBar.h index e49f7ae3b9..8c0be34ea0 100644 --- a/headers/os/interface/MenuBar.h +++ b/headers/os/interface/MenuBar.h @@ -36,12 +36,15 @@ class BMenuField; class BMenuBar : public BMenu { public: - BMenuBar( BRect frame, - const char *title, - uint32 resizeMask = - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, - menu_layout layout = B_ITEMS_IN_ROW, - bool resizeToFit = true); + BMenuBar(BRect frame, + const char *title, + uint32 resizeMask = + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, + menu_layout layout = B_ITEMS_IN_ROW, + bool resizeToFit = true); + BMenuBar(const char *title, + menu_layout layout = B_ITEMS_IN_ROW, + uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS); BMenuBar(BMessage *data); virtual ~BMenuBar(); static BArchivable *Instantiate(BMessage *data); diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index dd02e15a5d..4b48a2ddf2 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -51,6 +51,21 @@ BMenuBar::BMenuBar(BRect frame, const char *title, uint32 resizeMask, } +BMenuBar::BMenuBar(const char *title, menu_layout layout, uint32 flags) + : BMenu(BRect(), title, B_FOLLOW_NONE, + flags | B_WILL_DRAW | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT, + layout, false), + fBorder(B_BORDER_FRAME), + fTrackingPID(-1), + fPrevFocusToken(-1), + fMenuSem(-1), + fLastBounds(NULL), + fTracking(false) +{ + InitData(layout); +} + + BMenuBar::BMenuBar(BMessage *data) : BMenu(data), fBorder(B_BORDER_FRAME), @@ -222,11 +237,21 @@ BMenuBar::FrameMoved(BPoint newPosition) void BMenuBar::FrameResized(float newWidth, float newHeight) { - BRect bounds(Bounds()); - BRect rect(fLastBounds->right - 12, fLastBounds->top, bounds.right, bounds.bottom); + // invalidate right border + if (newWidth != fLastBounds->Width()) { + BRect rect(min_c(fLastBounds->right, newWidth), 0, + max_c(fLastBounds->right, newWidth), newHeight); + Invalidate(rect); + } + + // invalidate bottom border + if (newHeight != fLastBounds->Height()) { + BRect rect(0, min_c(fLastBounds->bottom, newHeight) - 1, + newWidth, max_c(fLastBounds->bottom, newHeight)); + Invalidate(rect); + } + fLastBounds->Set(0, 0, newWidth, newHeight); - - Invalidate(rect); BMenu::FrameResized(newWidth, newHeight); }