Draw menus using the user chosen colors.
This commit is contained in:
@@ -80,9 +80,9 @@ private:
|
|||||||
void _InitData();
|
void _InitData();
|
||||||
void _InitMenuData(BMenu* menu);
|
void _InitMenuData(BMenu* menu);
|
||||||
|
|
||||||
void _DrawMarkSymbol(rgb_color backgroundColor);
|
void _DrawMarkSymbol();
|
||||||
void _DrawShortcutSymbol();
|
void _DrawShortcutSymbol();
|
||||||
void _DrawSubmenuSymbol(rgb_color backgroundColor);
|
void _DrawSubmenuSymbol();
|
||||||
void _DrawControlChar(char shortcut, BPoint where);
|
void _DrawControlChar(char shortcut, BPoint where);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ _BMCMenuBar_::AttachedToWindow()
|
|||||||
if (Parent() != NULL)
|
if (Parent() != NULL)
|
||||||
SetLowColor(Parent()->LowColor());
|
SetLowColor(Parent()->LowColor());
|
||||||
else
|
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) {
|
if (be_control_look != NULL) {
|
||||||
BRect rect(Bounds());
|
BRect rect(Bounds());
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
if (!IsEnabled())
|
if (!IsEnabled())
|
||||||
flags |= BControlLook::B_DISABLED;
|
flags |= BControlLook::B_DISABLED;
|
||||||
|
|||||||
@@ -443,43 +443,34 @@ BMenuItem::DrawContent()
|
|||||||
void
|
void
|
||||||
BMenuItem::Draw()
|
BMenuItem::Draw()
|
||||||
{
|
{
|
||||||
|
rgb_color lowColor = fSuper->LowColor();
|
||||||
|
|
||||||
bool enabled = IsEnabled();
|
bool enabled = IsEnabled();
|
||||||
bool selected = IsSelected();
|
bool selected = IsSelected();
|
||||||
|
|
||||||
rgb_color noTint = fSuper->LowColor();
|
|
||||||
rgb_color bgColor = noTint;
|
|
||||||
|
|
||||||
// set low color and fill background if selected
|
// set low color and fill background if selected
|
||||||
bool activated = selected && (enabled || Submenu())
|
bool activated = selected && (enabled || Submenu())
|
||||||
/*&& fSuper->fRedrawAfterSticky*/;
|
/*&& fSuper->fRedrawAfterSticky*/;
|
||||||
if (activated) {
|
if (activated) {
|
||||||
bgColor = tint_color(bgColor, B_DARKEN_3_TINT);
|
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
BRect rect = Frame();
|
BRect rect = Frame();
|
||||||
be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
|
be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
|
||||||
noTint, BControlLook::B_ACTIVATED);
|
ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
|
||||||
|
BControlLook::B_ACTIVATED);
|
||||||
} else {
|
} else {
|
||||||
fSuper->SetLowColor(bgColor);
|
fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
|
||||||
fSuper->FillRect(Frame(), B_SOLID_LOW);
|
fSuper->FillRect(Frame(), B_SOLID_LOW);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fSuper->SetLowColor(bgColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set high color
|
// set high color
|
||||||
if (be_control_look != NULL) {
|
if (activated)
|
||||||
if (enabled) {
|
fSuper->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
||||||
fSuper->SetHighColor(tint_color(fSuper->LowColor(),
|
else if (enabled)
|
||||||
B_DARKEN_MAX_TINT));
|
fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||||
} else {
|
else {
|
||||||
fSuper->SetHighColor(tint_color(fSuper->LowColor(),
|
// TODO: Use a lighten tint if the menu uses a dark background
|
||||||
B_DISABLED_LABEL_TINT));
|
fSuper->SetHighColor(tint_color(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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw content
|
// draw content
|
||||||
@@ -490,16 +481,16 @@ BMenuItem::Draw()
|
|||||||
const menu_layout layout = MenuPrivate(fSuper).Layout();
|
const menu_layout layout = MenuPrivate(fSuper).Layout();
|
||||||
if (layout == B_ITEMS_IN_COLUMN) {
|
if (layout == B_ITEMS_IN_COLUMN) {
|
||||||
if (IsMarked())
|
if (IsMarked())
|
||||||
_DrawMarkSymbol(bgColor);
|
_DrawMarkSymbol();
|
||||||
|
|
||||||
if (fShortcutChar)
|
if (fShortcutChar)
|
||||||
_DrawShortcutSymbol();
|
_DrawShortcutSymbol();
|
||||||
|
|
||||||
if (Submenu())
|
if (Submenu())
|
||||||
_DrawSubmenuSymbol(bgColor);
|
_DrawSubmenuSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
fSuper->SetLowColor(noTint);
|
fSuper->SetLowColor(lowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -682,7 +673,7 @@ BMenuItem::Select(bool selected)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::_DrawMarkSymbol(rgb_color bgColor)
|
BMenuItem::_DrawMarkSymbol()
|
||||||
{
|
{
|
||||||
fSuper->PushState();
|
fSuper->PushState();
|
||||||
|
|
||||||
@@ -710,7 +701,6 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor)
|
|||||||
arrowShape.LineTo(BPoint(center.x + size, center.y - size));
|
arrowShape.LineTo(BPoint(center.x + size, center.y - size));
|
||||||
|
|
||||||
fSuper->SetDrawingMode(B_OP_OVER);
|
fSuper->SetDrawingMode(B_OP_OVER);
|
||||||
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
|
||||||
fSuper->SetPenSize(2.0);
|
fSuper->SetPenSize(2.0);
|
||||||
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
||||||
// it is not documented in the BeBook, but it is true!
|
// 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.y += (fBounds.Height() - 11) / 2 - 1;
|
||||||
where.x -= 4;
|
where.x -= 4;
|
||||||
|
|
||||||
|
// TODO: It would be nice to draw these taking into account the text (low)
|
||||||
|
// color.
|
||||||
if (fModifiers & B_COMMAND_KEY) {
|
if (fModifiers & B_COMMAND_KEY) {
|
||||||
const BBitmap *command = MenuPrivate::MenuItemCommand();
|
const BBitmap *command = MenuPrivate::MenuItemCommand();
|
||||||
const BRect &rect = command->Bounds();
|
const BRect &rect = command->Bounds();
|
||||||
@@ -773,7 +765,7 @@ BMenuItem::_DrawShortcutSymbol()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
|
BMenuItem::_DrawSubmenuSymbol()
|
||||||
{
|
{
|
||||||
fSuper->PushState();
|
fSuper->PushState();
|
||||||
|
|
||||||
@@ -802,7 +794,6 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
|
|||||||
arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
|
arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
|
||||||
|
|
||||||
fSuper->SetDrawingMode(B_OP_OVER);
|
fSuper->SetDrawingMode(B_OP_OVER);
|
||||||
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
|
||||||
fSuper->SetPenSize(ceilf(size * 0.4));
|
fSuper->SetPenSize(ceilf(size * 0.4));
|
||||||
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
||||||
// it is not documented in the BeBook, but it is true!
|
// it is not documented in the BeBook, but it is true!
|
||||||
|
|||||||
Reference in New Issue
Block a user