aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Leavengood <leavengood@gmail.com>2012-07-28 23:00:56 -0400
committerRyan Leavengood <leavengood@gmail.com>2012-07-28 23:02:17 -0400
commit6a03786cc9918b43c7695cc2349e77eb3193e922 (patch)
treea57c089e9acefb1771a9edf5ca93fbab234bcab7
parent1510ac00817ec2679621f9579bb25a71400f6c8b (diff)
Draw menus using the user chosen colors.hrev44426
-rw-r--r--headers/os/interface/MenuItem.h4
-rw-r--r--src/kits/interface/BMCPrivate.cpp4
-rw-r--r--src/kits/interface/MenuItem.cpp47
3 files changed, 23 insertions, 32 deletions
diff --git a/headers/os/interface/MenuItem.h b/headers/os/interface/MenuItem.h
index a484a83032..0f2e979e6e 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 e79df82eb6..ed270412ed 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 5d2dd98c8c..dc7ffef932 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!