OLD | NEW |
---|---|
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 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ |
6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/observer_list.h" | |
10 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
11 | 10 |
12 namespace ui { | 11 namespace ui { |
13 class NativeTheme; | 12 class NativeTheme; |
14 } // namespace ui | 13 } // namespace ui |
15 | 14 |
16 namespace views { | 15 namespace views { |
17 class Label; | 16 class Label; |
18 } // namespace views | 17 } // namespace views |
19 | 18 |
20 namespace ash { | 19 namespace ash { |
21 class TrayPopupItemStyleObserver; | |
22 | 20 |
23 // Central style provider for the system tray menu. Makes it easier to ensure | 21 // Central style provider for the system tray menu. Makes it easier to ensure |
24 // all visuals are consistent and easily updated in one spot instead of being | 22 // all visuals are consistent and easily updated in one spot instead of being |
25 // defined in multiple places throughout the code. | 23 // defined in multiple places throughout the code. |
26 class TrayPopupItemStyle { | 24 class TrayPopupItemStyle { |
tdanderson
2016/09/22 20:44:16
As discussed in person, perhaps include some comme
bruthig
2016/09/22 21:47:22
Done. WDYT?
| |
27 public: | 25 public: |
28 // The different visual styles that a row can have. | 26 // The different visual styles that a row can have. |
29 enum class ColorStyle { | 27 enum class ColorStyle { |
30 // Active and clickable. | 28 // Active and clickable. |
31 ACTIVE, | 29 ACTIVE, |
32 // Inactive but clickable. | 30 // Inactive but clickable. |
33 INACTIVE, | 31 INACTIVE, |
34 // Disabled and not clickable. | 32 // Disabled and not clickable. |
35 DISABLED, | 33 DISABLED, |
36 }; | 34 }; |
(...skipping 11 matching lines...) Expand all Loading... | |
48 // Sub text within a row (e.g. user name in user row). | 46 // Sub text within a row (e.g. user name in user row). |
49 CAPTION, | 47 CAPTION, |
50 // Child buttons within rows that have a visible border (e.g. Cast's | 48 // Child buttons within rows that have a visible border (e.g. Cast's |
51 // "Stop", etc). | 49 // "Stop", etc). |
52 BUTTON, | 50 BUTTON, |
53 }; | 51 }; |
54 | 52 |
55 TrayPopupItemStyle(const ui::NativeTheme* theme, FontStyle font_style); | 53 TrayPopupItemStyle(const ui::NativeTheme* theme, FontStyle font_style); |
56 ~TrayPopupItemStyle(); | 54 ~TrayPopupItemStyle(); |
57 | 55 |
58 void AddObserver(TrayPopupItemStyleObserver* observer); | |
59 void RemoveObserver(TrayPopupItemStyleObserver* observer); | |
60 | |
61 const ui::NativeTheme* theme() const { return theme_; } | 56 const ui::NativeTheme* theme() const { return theme_; } |
62 | 57 |
63 // Sets the |theme_| and notifies observers. | 58 void set_theme(const ui::NativeTheme* theme) { theme_ = theme; } |
64 void SetTheme(const ui::NativeTheme* theme); | |
65 | 59 |
66 ColorStyle color_style() const { return color_style_; } | 60 ColorStyle color_style() const { return color_style_; } |
67 | 61 |
68 // Sets the |color_style_| and notifies observers if |color_style_| changed. | 62 void set_color_style(ColorStyle color_style) { color_style_ = color_style; } |
69 void SetColorStyle(ColorStyle color_style); | |
70 | 63 |
71 FontStyle font_style() const { return font_style_; } | 64 FontStyle font_style() const { return font_style_; } |
72 | 65 |
73 // Sets the |font_style_| notifies observers if |font_style_| changed. | 66 void set_font_style(FontStyle font_style) { font_style_ = font_style; } |
74 void SetFontStyle(FontStyle font_style); | |
75 | 67 |
76 SkColor GetForegroundColor() const; | 68 SkColor GetForegroundColor() const; |
77 | 69 |
78 // Configures a Label as per the style (e.g. color, font). | 70 // Configures a Label as per the style (e.g. color, font). |
79 void SetupLabel(views::Label* label) const; | 71 void SetupLabel(views::Label* label) const; |
80 | 72 |
81 private: | 73 private: |
82 void NotifyObserversStyleUpdated(); | |
83 | |
84 // The theme that the styles are dervied from. | 74 // The theme that the styles are dervied from. |
85 const ui::NativeTheme* theme_; | 75 const ui::NativeTheme* theme_; |
86 | 76 |
87 FontStyle font_style_; | 77 FontStyle font_style_; |
88 | 78 |
89 ColorStyle color_style_; | 79 ColorStyle color_style_; |
90 | 80 |
91 base::ObserverList<TrayPopupItemStyleObserver> observers_; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemStyle); | 81 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemStyle); |
94 }; | 82 }; |
95 | 83 |
96 } // namespace ash | 84 } // namespace ash |
97 | 85 |
98 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ | 86 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_STYLE_H_ |
OLD | NEW |