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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user