From db85cbe0b53f9377a0310e0740306c35a3df36f1 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 20 Aug 2013 16:50:05 -0400 Subject: [PATCH] MenuItem: Set and restore the low color too A small revision on my last published commit, set and restore the low color in addition to the high color when drawing the menu item because DrawString() will produce nicer looking results if the low color of the view matches the color it draws on due to anti-aliasing. --- src/kits/interface/MenuItem.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index b2dfc92c3c..3e3e0b874b 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -444,21 +444,22 @@ BMenuItem::DrawContent() void BMenuItem::Draw() { + const rgb_color lowColor = fSuper->LowColor(); const rgb_color highColor = fSuper->HighColor(); - rgb_color bgColor = fSuper->LowColor(); bool enabled = IsEnabled(); bool selected = IsSelected(); bool activated = selected && (enabled || Submenu() != NULL); + // set low color if (activated) { - // fill in background - bgColor = ui_color(B_MENU_SELECTED_BACKGROUND_COLOR); - BRect rect = Frame(); - be_control_look->DrawMenuItemBackground(fSuper, rect, rect, - bgColor, BControlLook::B_ACTIVATED); + fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR)); + // fill in the background + BRect rect(Frame()); + be_control_look->DrawMenuItemBackground(fSuper, rect, Frame(), + fSuper->LowColor(), BControlLook::B_ACTIVATED); } else - bgColor = ui_color(B_MENU_BACKGROUND_COLOR); + fSuper->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR)); // set high color if (activated && enabled) @@ -466,6 +467,7 @@ BMenuItem::Draw() else if (enabled) fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); else { + rgb_color bgColor = fSuper->LowColor(); if (bgColor.red + bgColor.green + bgColor.blue > 128 * 3) fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT)); else @@ -489,8 +491,9 @@ BMenuItem::Draw() _DrawSubmenuSymbol(); } + // restore the parent menu's low color and high color + fSuper->SetLowColor(lowColor); fSuper->SetHighColor(highColor); - // restore the high color of the parent menu }