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

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

Issue 2365523002: Materialized the font/icon color for some default rows in the system menu. (Closed)
Patch Set: Applied TrayPopupItemStyle to Network, SMS, Tracing, OS Update. Created 4 years, 3 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 unified diff | Download patch
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 "ash/common/system/tray/tray_popup_item_style_observer.h"
8 #include "third_party/skia/include/core/SkColor.h" 7 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/gfx/font.h" 8 #include "ui/gfx/font.h"
10 #include "ui/gfx/font_list.h" 9 #include "ui/gfx/font_list.h"
11 #include "ui/native_theme/native_theme.h" 10 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/controls/label.h" 11 #include "ui/views/controls/label.h"
13 12
14 namespace ash { 13 namespace ash {
15 namespace { 14 namespace {
16 15
17 // TODO(bruthig): Consider adding an 'inactive' color to the NativeTheme 16 // TODO(bruthig): Consider adding an 'inactive' color to the NativeTheme
18 // and allow Label to use it directly. This would require changing the 17 // and allow Label to use it directly. This would require changing the
19 // View::enabled_ flag to a tri-state enum. 18 // View::enabled_ flag to a tri-state enum.
20 const SkColor kInactiveTextColor = SkColorSetRGB(0x64, 0x64, 0x64); 19 const SkColor kInactiveTextColor = SkColorSetRGB(0x64, 0x64, 0x64);
21 } // namespace 20 } // namespace
22 21
23 TrayPopupItemStyle::TrayPopupItemStyle(const ui::NativeTheme* theme, 22 TrayPopupItemStyle::TrayPopupItemStyle(const ui::NativeTheme* theme,
24 FontStyle font_style) 23 FontStyle font_style)
25 : theme_(theme), 24 : theme_(theme),
26 font_style_(font_style), 25 font_style_(font_style),
27 color_style_(ColorStyle::ACTIVE) {} 26 color_style_(ColorStyle::ACTIVE) {}
28 27
29 TrayPopupItemStyle::~TrayPopupItemStyle() {} 28 TrayPopupItemStyle::~TrayPopupItemStyle() {}
30 29
31 void TrayPopupItemStyle::AddObserver(TrayPopupItemStyleObserver* observer) {
32 if (!observers_.HasObserver(observer))
33 observers_.AddObserver(observer);
34 }
35
36 void TrayPopupItemStyle::RemoveObserver(TrayPopupItemStyleObserver* observer) {
37 observers_.RemoveObserver(observer);
38 }
39
40 void TrayPopupItemStyle::SetTheme(const ui::NativeTheme* theme) {
41 theme_ = theme;
42 NotifyObserversStyleUpdated();
43 }
44
45 void TrayPopupItemStyle::SetColorStyle(ColorStyle color_style) {
46 color_style_ = color_style;
47 NotifyObserversStyleUpdated();
48 }
49
50 void TrayPopupItemStyle::SetFontStyle(FontStyle font_style) {
51 font_style_ = font_style;
52 NotifyObserversStyleUpdated();
53 }
54
55 SkColor TrayPopupItemStyle::GetForegroundColor() const { 30 SkColor TrayPopupItemStyle::GetForegroundColor() const {
56 switch (color_style_) { 31 switch (color_style_) {
57 case ColorStyle::ACTIVE: 32 case ColorStyle::ACTIVE:
58 return theme_->GetSystemColor( 33 return theme_->GetSystemColor(
59 ui::NativeTheme::kColorId_LabelEnabledColor); 34 ui::NativeTheme::kColorId_LabelEnabledColor);
60 case ColorStyle::INACTIVE: 35 case ColorStyle::INACTIVE:
61 return kInactiveTextColor; 36 return kInactiveTextColor;
62 case ColorStyle::DISABLED: 37 case ColorStyle::DISABLED:
63 return theme_->GetSystemColor( 38 return theme_->GetSystemColor(
64 ui::NativeTheme::kColorId_LabelDisabledColor); 39 ui::NativeTheme::kColorId_LabelDisabledColor);
(...skipping 25 matching lines...) Expand all
90 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL, 65 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
91 gfx::Font::Weight::NORMAL)); 66 gfx::Font::Weight::NORMAL));
92 break; 67 break;
93 case FontStyle::BUTTON: 68 case FontStyle::BUTTON:
94 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL, 69 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
95 gfx::Font::Weight::MEDIUM)); 70 gfx::Font::Weight::MEDIUM));
96 break; 71 break;
97 } 72 }
98 } 73 }
99 74
100 void TrayPopupItemStyle::NotifyObserversStyleUpdated() {
101 FOR_EACH_OBSERVER(TrayPopupItemStyleObserver, observers_,
102 OnTrayPopupItemStyleUpdated());
103 }
104
105 } // namespace ash 75 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698