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.
This commit is contained in:
John Scipione
2013-08-20 16:50:05 -04:00
parent dec0a3523d
commit db85cbe0b5
+11 -8
View File
@@ -444,21 +444,22 @@ BMenuItem::DrawContent()
void void
BMenuItem::Draw() BMenuItem::Draw()
{ {
const rgb_color lowColor = fSuper->LowColor();
const rgb_color highColor = fSuper->HighColor(); const rgb_color highColor = fSuper->HighColor();
rgb_color bgColor = fSuper->LowColor();
bool enabled = IsEnabled(); bool enabled = IsEnabled();
bool selected = IsSelected(); bool selected = IsSelected();
bool activated = selected && (enabled || Submenu() != NULL); bool activated = selected && (enabled || Submenu() != NULL);
// set low color
if (activated) { if (activated) {
// fill in background fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
bgColor = ui_color(B_MENU_SELECTED_BACKGROUND_COLOR); // fill in the background
BRect rect = Frame(); BRect rect(Frame());
be_control_look->DrawMenuItemBackground(fSuper, rect, rect, be_control_look->DrawMenuItemBackground(fSuper, rect, Frame(),
bgColor, BControlLook::B_ACTIVATED); fSuper->LowColor(), BControlLook::B_ACTIVATED);
} else } else
bgColor = ui_color(B_MENU_BACKGROUND_COLOR); fSuper->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
// set high color // set high color
if (activated && enabled) if (activated && enabled)
@@ -466,6 +467,7 @@ BMenuItem::Draw()
else if (enabled) else if (enabled)
fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
else { else {
rgb_color bgColor = fSuper->LowColor();
if (bgColor.red + bgColor.green + bgColor.blue > 128 * 3) if (bgColor.red + bgColor.green + bgColor.blue > 128 * 3)
fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT)); fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT));
else else
@@ -489,8 +491,9 @@ BMenuItem::Draw()
_DrawSubmenuSymbol(); _DrawSubmenuSymbol();
} }
// restore the parent menu's low color and high color
fSuper->SetLowColor(lowColor);
fSuper->SetHighColor(highColor); fSuper->SetHighColor(highColor);
// restore the high color of the parent menu
} }