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

Side by Side Diff: ash/common/system/tray/tray_popup_item_style.cc

Issue 2496963004: [ash-md] Fixed the effective text/icon colors in the system menu. (Closed)
Patch Set: Fixed compile error (typo). Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « ash/common/system/tray/tray_popup_item_style.h ('k') | ash/common/system/tray_accessibility.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/tray/tray_popup_item_style.h" 5 #include "ash/common/system/tray/tray_popup_item_style.h"
6 6
7 #include "third_party/skia/include/core/SkColor.h" 7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/gfx/font.h" 8 #include "ui/gfx/font.h"
9 #include "ui/gfx/font_list.h" 9 #include "ui/gfx/font_list.h"
10 #include "ui/native_theme/native_theme.h" 10 #include "ui/native_theme/native_theme.h"
11 #include "ui/views/controls/label.h" 11 #include "ui/views/controls/label.h"
12 12
13 namespace ash { 13 namespace ash {
14 namespace { 14 namespace {
15 15
16 // TODO(bruthig): Consider adding an 'inactive' color to the NativeTheme 16 // TODO(bruthig|tdanderson): Figure out why the theme providers aren't providing
17 // and allow Label to use it directly. This would require changing the 17 // the desired colors. See http://crbug.com/614453.
18 // View::enabled_ flag to a tri-state enum. 18
19 const SkColor kInactiveTextColor = SkColorSetRGB(0x64, 0x64, 0x64); 19 // The base color used to compute the effective text colors.
20 const SkColor kBaseTextColor = SK_ColorBLACK;
21
22 const int kActiveTextAlpha = 0xDE;
23 const int kInactiveTextAlpha = 0x8A;
24 const int kDisabledTextAlpha = 0x61;
25
26 // The base color used to compute the effective icon colors.
27 const SkColor kBaseIconColor = SkColorSetRGB(0x5a, 0x5a, 0x5a);
28
29 const int kActiveIconAlpha = 0xFF;
30 const int kInactiveIconAlpha = 0x8A;
31 const int kDisabledIconAlpha = 0x61;
32
20 } // namespace 33 } // namespace
21 34
22 TrayPopupItemStyle::TrayPopupItemStyle(const ui::NativeTheme* theme, 35 TrayPopupItemStyle::TrayPopupItemStyle(const ui::NativeTheme* theme,
23 FontStyle font_style) 36 FontStyle font_style)
24 : theme_(theme), 37 : theme_(theme),
25 font_style_(font_style), 38 font_style_(font_style),
26 color_style_(ColorStyle::ACTIVE) {} 39 color_style_(ColorStyle::ACTIVE) {}
27 40
28 TrayPopupItemStyle::~TrayPopupItemStyle() {} 41 TrayPopupItemStyle::~TrayPopupItemStyle() {}
29 42
30 SkColor TrayPopupItemStyle::GetForegroundColor() const { 43 SkColor TrayPopupItemStyle::GetTextColor() const {
31 switch (color_style_) { 44 switch (color_style_) {
32 case ColorStyle::ACTIVE: 45 case ColorStyle::ACTIVE:
33 return theme_->GetSystemColor( 46 return SkColorSetA(kBaseTextColor, kActiveTextAlpha);
34 ui::NativeTheme::kColorId_LabelEnabledColor);
35 case ColorStyle::INACTIVE: 47 case ColorStyle::INACTIVE:
36 return kInactiveTextColor; 48 return SkColorSetA(kBaseTextColor, kInactiveTextAlpha);
37 case ColorStyle::DISABLED: 49 case ColorStyle::DISABLED:
38 return theme_->GetSystemColor( 50 return SkColorSetA(kBaseTextColor, kDisabledTextAlpha);
39 ui::NativeTheme::kColorId_LabelDisabledColor);
40 } 51 }
41 NOTREACHED(); 52 NOTREACHED();
42 // Use a noticeable color to help notice unhandled cases. 53 // Use a noticeable color to help notice unhandled cases.
54 return SK_ColorMAGENTA;
55 }
56
57 SkColor TrayPopupItemStyle::GetIconColor() const {
58 switch (color_style_) {
59 case ColorStyle::ACTIVE:
60 return SkColorSetA(kBaseIconColor, kActiveIconAlpha);
61 case ColorStyle::INACTIVE:
62 return SkColorSetA(kBaseIconColor, kInactiveIconAlpha);
63 case ColorStyle::DISABLED:
64 return SkColorSetA(kBaseIconColor, kDisabledIconAlpha);
65 }
66 NOTREACHED();
67 // Use a noticeable color to help notice unhandled cases.
43 return SK_ColorMAGENTA; 68 return SK_ColorMAGENTA;
44 } 69 }
45 70
46 void TrayPopupItemStyle::SetupLabel(views::Label* label) const { 71 void TrayPopupItemStyle::SetupLabel(views::Label* label) const {
47 label->SetEnabledColor(GetForegroundColor()); 72 label->SetEnabledColor(GetTextColor());
48 73
49 const gfx::FontList& base_font_list = views::Label::GetDefaultFontList(); 74 const gfx::FontList& base_font_list = views::Label::GetDefaultFontList();
50 switch (font_style_) { 75 switch (font_style_) {
51 case FontStyle::TITLE: 76 case FontStyle::TITLE:
52 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL, 77 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL,
53 gfx::Font::Weight::MEDIUM)); 78 gfx::Font::Weight::MEDIUM));
54 break; 79 break;
55 case FontStyle::DEFAULT_VIEW_LABEL: 80 case FontStyle::DEFAULT_VIEW_LABEL:
56 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL, 81 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL,
57 gfx::Font::Weight::NORMAL)); 82 gfx::Font::Weight::NORMAL));
58 break; 83 break;
59 case FontStyle::DETAILED_VIEW_LABEL: 84 case FontStyle::DETAILED_VIEW_LABEL:
60 case FontStyle::SYSTEM_INFO: 85 case FontStyle::SYSTEM_INFO:
61 label->SetFontList(base_font_list.Derive(1, gfx::Font::NORMAL, 86 label->SetFontList(base_font_list.Derive(1, gfx::Font::NORMAL,
62 gfx::Font::Weight::NORMAL)); 87 gfx::Font::Weight::NORMAL));
63 break; 88 break;
64 case FontStyle::CAPTION: 89 case FontStyle::CAPTION:
65 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL, 90 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
66 gfx::Font::Weight::NORMAL)); 91 gfx::Font::Weight::NORMAL));
67 break; 92 break;
68 case FontStyle::BUTTON: 93 case FontStyle::BUTTON:
69 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL, 94 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
70 gfx::Font::Weight::MEDIUM)); 95 gfx::Font::Weight::MEDIUM));
71 break; 96 break;
72 } 97 }
73 } 98 }
74 99
75 } // namespace ash 100 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_item_style.h ('k') | ash/common/system/tray_accessibility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698