From bd57c145be88c15d40eb869978523956a01895a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 15 Aug 2007 20:38:29 +0000 Subject: [PATCH] * setting a different menu color with the menu preflet gives now visually agreeable results (I hope) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21967 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BMCPrivate.cpp | 2 +- src/kits/interface/MenuBar.cpp | 8 +++++--- src/kits/interface/MenuItem.cpp | 13 ++++++++++--- src/kits/interface/SeparatorItem.cpp | 22 +++++++++++++++------- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index e817c93ca3..c3c1111eba 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -146,7 +146,7 @@ _BMCMenuBar_::Draw(BRect updateRect) bounds.bottom += 1.0; // prepare some colors - rgb_color normalNoTint = ui_color(B_MENU_BACKGROUND_COLOR); + rgb_color normalNoTint = LowColor(); rgb_color noTint = tint_color(normalNoTint, 0.74); rgb_color darken4; rgb_color normalDarken4; diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index bdb4344cae..033a0c1046 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -152,15 +152,17 @@ BMenuBar::Draw(BRect updateRect) // Restore the background of the previously selected menuitem DrawBackground(bounds & updateRect); - SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); + rgb_color noTint = LowColor(); + + SetHighColor(tint_color(noTint, B_LIGHTEN_2_TINT)); StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f)); StrokeLine(BPoint(bounds.right, 0.0f)); - SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT)); + SetHighColor(tint_color(noTint, B_DARKEN_1_TINT)); StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f), BPoint(bounds.right, bounds.bottom - 1.0f)); - SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); + SetHighColor(tint_color(noTint, 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)); diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 4ee61114ce..2f1aac89a8 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -442,12 +442,17 @@ BMenuItem::Draw() bool enabled = IsEnabled(); bool selected = IsSelected(); - rgb_color noTint = ui_color(B_MENU_BACKGROUND_COLOR); +// rgb_color noTint = ui_color(B_MENU_BACKGROUND_COLOR); +// TODO: the above is currently broken, because ui_color is +// not informed of changes to the app_server palette yet + rgb_color noTint = fSuper->LowColor(); rgb_color bgColor = noTint; // set low color and fill background if selected if (selected && (enabled || Submenu()) /*&& fSuper->fRedrawAfterSticky*/) { - bgColor = ui_color(B_MENU_SELECTED_BACKGROUND_COLOR); +// bgColor = ui_color(B_MENU_SELECTED_BACKGROUND_COLOR); +// see above + bgColor = tint_color(bgColor, B_DARKEN_3_TINT); fSuper->SetLowColor(bgColor); fSuper->FillRect(Frame(), B_SOLID_LOW); } else @@ -478,6 +483,8 @@ BMenuItem::Draw() if (Submenu()) _DrawSubmenuSymbol(bgColor); } + + fSuper->SetLowColor(noTint); } @@ -699,7 +706,7 @@ BMenuItem::_DrawShortcutSymbol() BFont font; menu->GetFont(&font); BPoint where = ContentLocation(); - where.x = fBounds.right - font.Size(); + where.x = fBounds.right - font.Size(); if (menu->fSubmenus) where.x -= fBounds.Height() - 4; diff --git a/src/kits/interface/SeparatorItem.cpp b/src/kits/interface/SeparatorItem.cpp index ba774fe3e4..9f4aad5a9c 100644 --- a/src/kits/interface/SeparatorItem.cpp +++ b/src/kits/interface/SeparatorItem.cpp @@ -12,6 +12,7 @@ #include +#include BSeparatorItem::BSeparatorItem() @@ -61,10 +62,14 @@ void BSeparatorItem::GetContentSize(float* _width, float* _height) { if (_width != NULL) - *_width = 2.0f; + *_width = 2.0; - if (_height != NULL) - *_height = 8.0f; + if (_height != NULL) { + BFont font(be_plain_font); + if (Menu()) + Menu()->GetFont(&font); + *_height = floorf(font.Size() * 0.8); + } } @@ -77,11 +82,14 @@ BSeparatorItem::Draw() BRect bounds = Frame(); rgb_color oldColor = menu->HighColor(); + rgb_color lowColor = menu->LowColor(); - menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT)); - menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f), BPoint(bounds.right - 1.0f, bounds.top + 4.0f)); - menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); - menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f), BPoint(bounds.right - 1.0f, bounds.top + 5.0f)); + menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT)); + menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f), + BPoint(bounds.right - 1.0f, bounds.top + 4.0f)); + menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT)); + menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f), + BPoint(bounds.right - 1.0f, bounds.top + 5.0f)); menu->SetHighColor(oldColor); }