From 0c26ddbc29ef759dae88e3689e953251c0c6b1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Jun 2005 15:11:58 +0000 Subject: [PATCH] The MenuBar background is now drawn correctly when selected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13319 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/MenuBar.cpp | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 9016dd9656..04ee40b11c 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -132,17 +132,19 @@ BMenuBar::Border() const } -void +void BMenuBar::Draw(BRect updateRect) { // TODO: implement additional border styles - if (IsEnabled()) { - PushState(); - + if (IsEnabled()) { + // ToDo: this is a work-around for broken PushState()/PopState() +// PushState(); + rgb_color color = HighColor(); + BRect bounds(Bounds()); // Restore the background of the previously selected menuitem DrawBackground(bounds & updateRect); - + SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f)); StrokeLine(BPoint(bounds.right, 0.0f)); @@ -154,20 +156,20 @@ BMenuBar::Draw(BRect updateRect) SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom)); StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom)); - - PopState(); - + +// PopState(); + SetHighColor(color); + DrawItems(updateRect); - } else { LayoutItems(0); Sync(); Invalidate(); } -} +} -void +void BMenuBar::AttachedToWindow() { Install(Window()); @@ -397,16 +399,17 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) BMenuItem *resultItem = NULL; BWindow *window = Window(); int localAction = MENU_ACT_NONE; - do { + + while (true) { bigtime_t snoozeAmount = 30000; if (window->LockWithTimeout(200000) < B_OK) break; - + BPoint where; ulong buttons; GetMouse(&where, &buttons); - - BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); + + BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); if (menuItem != NULL && menuItem != fSelected) { // only select the item SelectItem(menuItem, -1); @@ -416,7 +419,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) SelectItem(menuItem); } } - + if (fSelected != NULL) { BMenu *menu = fSelected->Submenu(); if (menu != NULL) { @@ -429,17 +432,16 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) break; } } - + window->Unlock(); - + if (localAction == MENU_ACT_CLOSE) break; - + if (snoozeAmount > 0) snooze(snoozeAmount); - - } while (true); - + } + if (window->Lock()) { if (fSelected != NULL) SelectItem(NULL); @@ -447,10 +449,10 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) resultItem->Invoke(); window->Unlock(); } - + if (action != NULL) *action = static_cast(localAction); - + return resultItem; }