Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: ui/views/controls/menu/menu_item_view.cc

Issue 2700473002: MenuItemView: use disabled text color for subtitles too (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/menu/menu_item_view.cc
diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc
index 4b2efb01ce99a691e7e489c6f75e835b4178704d..556cb240d0954fe1ac6ac59156400ffb3d52e046 100644
--- a/ui/views/controls/menu/menu_item_view.cc
+++ b/ui/views/controls/menu/menu_item_view.cc
@@ -753,6 +753,8 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
(NonIconChildViewsCount() == 0));
MenuDelegate *delegate = GetDelegate();
+ bool emphasized =
+ delegate && delegate->GetShouldUseNormalForegroundColor(GetCommand());
// Render the background. As MenuScrollViewContainer draws the background, we
// only need the background when we want it to look different, as when we're
// selected.
@@ -774,19 +776,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
const int available_height = height() - top_margin - bottom_margin;
// Calculate some colors.
- ui::NativeTheme::ColorId color_id;
- if (enabled()) {
- color_id = render_selection ?
- ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor:
- ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor;
- } else {
- bool emphasized =
- delegate && delegate->GetShouldUseNormalForegroundColor(GetCommand());
- color_id = emphasized
- ? ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor
- : ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor;
- }
- SkColor fg_color = native_theme->GetSystemColor(color_id);
+ SkColor fg_color = GetTextColor(false, render_selection, emphasized);
SkColor icon_color = color_utils::DeriveDefaultIconColor(fg_color);
// Render the check.
@@ -839,7 +829,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
flags);
}
- PaintMinorText(canvas, render_selection);
+ PaintMinorText(canvas, GetTextColor(true, render_selection, emphasized));
// Render the submenu indicator (arrow).
if (HasSubmenu()) {
@@ -854,8 +844,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
}
}
-void MenuItemView::PaintMinorText(gfx::Canvas* canvas,
- bool render_selection) {
+void MenuItemView::PaintMinorText(gfx::Canvas* canvas, SkColor color) {
base::string16 minor_text = GetMinorText();
if (minor_text.empty())
return;
@@ -875,14 +864,24 @@ void MenuItemView::PaintMinorText(gfx::Canvas* canvas,
flags |= gfx::Canvas::TEXT_ALIGN_LEFT;
else
flags |= gfx::Canvas::TEXT_ALIGN_RIGHT;
- canvas->DrawStringRectWithFlags(
- minor_text,
- GetFontList(),
- GetNativeTheme()->GetSystemColor(render_selection ?
- ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor :
- ui::NativeTheme::kColorId_MenuItemSubtitleColor),
- accel_bounds,
- flags);
+ canvas->DrawStringRectWithFlags(minor_text, GetFontList(), color,
+ accel_bounds, flags);
+}
+
+SkColor MenuItemView::GetTextColor(bool minor,
+ bool render_selection,
+ bool emphasized) const {
+ ui::NativeTheme::ColorId color_id =
+ minor ? ui::NativeTheme::kColorId_MenuItemSubtitleColor
+ : ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor;
+ if (enabled()) {
+ if (render_selection)
+ color_id = ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor;
+ } else {
+ if (!emphasized)
+ color_id = ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor;
+ }
+ return GetNativeTheme()->GetSystemColor(color_id);
}
void MenuItemView::DestroyAllMenuHosts() {
« chrome/browser/ui/libgtkui/native_theme_gtk3.cc ('K') | « ui/views/controls/menu/menu_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698