hrev44426 adds 1 changeset to branch 'master' old head: 1510ac00817ec2679621f9579bb25a71400f6c8b new head: 6a03786cc9918b43c7695cc2349e77eb3193e922 ---------------------------------------------------------------------------- 6a03786: Draw menus using the user chosen colors. [ Ryan Leavengood <leavengood@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev44426 Commit: 6a03786cc9918b43c7695cc2349e77eb3193e922 URL: http://cgit.haiku-os.org/haiku/commit/?id=6a03786 Author: Ryan Leavengood <leavengood@xxxxxxxxx> Date: Sun Jul 29 03:00:56 2012 UTC ---------------------------------------------------------------------------- 3 files changed, 23 insertions(+), 32 deletions(-) headers/os/interface/MenuItem.h | 4 +-- src/kits/interface/BMCPrivate.cpp | 4 +-- src/kits/interface/MenuItem.cpp | 47 +++++++++++++-------------------- ---------------------------------------------------------------------------- diff --git a/headers/os/interface/MenuItem.h b/headers/os/interface/MenuItem.h index a484a83..0f2e979 100644 --- a/headers/os/interface/MenuItem.h +++ b/headers/os/interface/MenuItem.h @@ -80,9 +80,9 @@ private: void _InitData(); void _InitMenuData(BMenu* menu); - void _DrawMarkSymbol(rgb_color backgroundColor); + void _DrawMarkSymbol(); void _DrawShortcutSymbol(); - void _DrawSubmenuSymbol(rgb_color backgroundColor); + void _DrawSubmenuSymbol(); void _DrawControlChar(char shortcut, BPoint where); private: diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index e79df82..ed27041 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -127,7 +127,7 @@ _BMCMenuBar_::AttachedToWindow() if (Parent() != NULL) SetLowColor(Parent()->LowColor()); else - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR)); } @@ -136,7 +136,7 @@ _BMCMenuBar_::Draw(BRect updateRect) { if (be_control_look != NULL) { BRect rect(Bounds()); - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); uint32 flags = 0; if (!IsEnabled()) flags |= BControlLook::B_DISABLED; diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 5d2dd98..dc7ffef 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -443,43 +443,34 @@ BMenuItem::DrawContent() void BMenuItem::Draw() { + rgb_color lowColor = fSuper->LowColor(); + bool enabled = IsEnabled(); bool selected = IsSelected(); - rgb_color noTint = fSuper->LowColor(); - rgb_color bgColor = noTint; - // set low color and fill background if selected bool activated = selected && (enabled || Submenu()) /*&& fSuper->fRedrawAfterSticky*/; if (activated) { - bgColor = tint_color(bgColor, B_DARKEN_3_TINT); if (be_control_look != NULL) { BRect rect = Frame(); be_control_look->DrawMenuItemBackground(fSuper, rect, rect, - noTint, BControlLook::B_ACTIVATED); + ui_color(B_MENU_SELECTED_BACKGROUND_COLOR), + BControlLook::B_ACTIVATED); } else { - fSuper->SetLowColor(bgColor); + fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR)); fSuper->FillRect(Frame(), B_SOLID_LOW); } - } else { - fSuper->SetLowColor(bgColor); } // set high color - if (be_control_look != NULL) { - if (enabled) { - fSuper->SetHighColor(tint_color(fSuper->LowColor(), - B_DARKEN_MAX_TINT)); - } else { - fSuper->SetHighColor(tint_color(fSuper->LowColor(), - B_DISABLED_LABEL_TINT)); - } - } else { - if (enabled) - fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); - else - fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT)); + if (activated) + fSuper->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); + else if (enabled) + fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); + else { + // TODO: Use a lighten tint if the menu uses a dark background + fSuper->SetHighColor(tint_color(lowColor, B_DISABLED_LABEL_TINT)); } // draw content @@ -490,16 +481,16 @@ BMenuItem::Draw() const menu_layout layout = MenuPrivate(fSuper).Layout(); if (layout == B_ITEMS_IN_COLUMN) { if (IsMarked()) - _DrawMarkSymbol(bgColor); + _DrawMarkSymbol(); if (fShortcutChar) _DrawShortcutSymbol(); if (Submenu()) - _DrawSubmenuSymbol(bgColor); + _DrawSubmenuSymbol(); } - fSuper->SetLowColor(noTint); + fSuper->SetLowColor(lowColor); } @@ -682,7 +673,7 @@ BMenuItem::Select(bool selected) void -BMenuItem::_DrawMarkSymbol(rgb_color bgColor) +BMenuItem::_DrawMarkSymbol() { fSuper->PushState(); @@ -710,7 +701,6 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor) arrowShape.LineTo(BPoint(center.x + size, center.y - size)); fSuper->SetDrawingMode(B_OP_OVER); - fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT)); fSuper->SetPenSize(2.0); // NOTE: StrokeShape() offsets the shape by the current pen position, // it is not documented in the BeBook, but it is true! @@ -742,6 +732,8 @@ BMenuItem::_DrawShortcutSymbol() where.y += (fBounds.Height() - 11) / 2 - 1; where.x -= 4; + // TODO: It would be nice to draw these taking into account the text (low) + // color. if (fModifiers & B_COMMAND_KEY) { const BBitmap *command = MenuPrivate::MenuItemCommand(); const BRect &rect = command->Bounds(); @@ -773,7 +765,7 @@ BMenuItem::_DrawShortcutSymbol() void -BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor) +BMenuItem::_DrawSubmenuSymbol() { fSuper->PushState(); @@ -802,7 +794,6 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor) arrowShape.LineTo(BPoint(center.x - hSize, center.y + size)); fSuper->SetDrawingMode(B_OP_OVER); - fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT)); fSuper->SetPenSize(ceilf(size * 0.4)); // NOTE: StrokeShape() offsets the shape by the current pen position, // it is not documented in the BeBook, but it is true!