OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ITEM_MORE_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ |
6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "ash/common/system/tray/actionable_view.h" | 10 #include "ash/common/system/tray/actionable_view.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
11 | 13 |
12 namespace views { | 14 namespace views { |
13 class ImageView; | 15 class ImageView; |
14 class Label; | 16 class Label; |
15 class View; | 17 class View; |
16 } | 18 } |
17 | 19 |
18 namespace ash { | 20 namespace ash { |
19 class SystemTrayItem; | 21 class SystemTrayItem; |
| 22 class TrayPopupItemStyle; |
20 | 23 |
21 // A view with a chevron ('>') on the right edge. Clicking on the view brings up | 24 // A view with a more arrow on the right edge. Clicking on the view brings up |
22 // the detailed view of the tray-item that owns it. | 25 // the detailed view of the tray-item that owns it. |
23 class TrayItemMore : public ActionableView { | 26 class TrayItemMore : public ActionableView { |
24 public: | 27 public: |
25 TrayItemMore(SystemTrayItem* owner, bool show_more); | 28 TrayItemMore(SystemTrayItem* owner, bool show_more); |
26 ~TrayItemMore() override; | 29 ~TrayItemMore() override; |
27 | 30 |
28 SystemTrayItem* owner() const { return owner_; } | 31 SystemTrayItem* owner() const { return owner_; } |
29 | 32 |
30 void SetLabel(const base::string16& label); | 33 void SetLabel(const base::string16& label); |
31 void SetImage(const gfx::ImageSkia& image_skia); | 34 void SetImage(const gfx::ImageSkia& image_skia); |
32 void SetAccessibleName(const base::string16& name); | 35 void SetAccessibleName(const base::string16& name); |
33 | 36 |
| 37 protected: |
| 38 // Returns a style that will be applied to elements in the UpdateStyle() |
| 39 // method. e.g. changing the label's font and color. Descendants can override |
| 40 // to apply specialized configurations of the style. e.g. changing the style's |
| 41 // ColorStyle based on whether Bluetooth is enabled/disabled. |
| 42 virtual std::unique_ptr<TrayPopupItemStyle> CreateStyle() const; |
| 43 |
| 44 // Applies the style created from CreateStyle(). Should be called whenever any |
| 45 // input state changes that changes the style configuration created by |
| 46 // CreateStyle(). e.g. if Bluetooth is changed between enabled/disabled then |
| 47 // a differently configured style will be returned from CreateStyle() and thus |
| 48 // it will need to be applied. |
| 49 // |
| 50 // By default this will be called when OnNativeThemeChanged() is called which |
| 51 // will ensure the most up to date theme is actually applied. |
| 52 virtual void UpdateStyle(); |
| 53 |
34 private: | 54 private: |
35 // TODO(bruthig): Re-design to inform subclasses when the style changes while | |
36 // avoiding virtual function calls from the constructor. | |
37 void UpdateStyle(); | |
38 | |
39 // Overridden from ActionableView. | 55 // Overridden from ActionableView. |
40 bool PerformAction(const ui::Event& event) override; | 56 bool PerformAction(const ui::Event& event) override; |
41 | 57 |
42 // Overridden from views::View. | 58 // Overridden from views::View. |
43 void Layout() override; | 59 void Layout() override; |
44 void GetAccessibleState(ui::AXViewState* state) override; | 60 void GetAccessibleState(ui::AXViewState* state) override; |
45 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 61 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
46 | 62 |
47 SystemTrayItem* owner_; | 63 SystemTrayItem* owner_; |
48 // True if |more_| should be shown. | 64 // True if |more_| should be shown. |
49 bool show_more_; | 65 bool show_more_; |
50 views::ImageView* icon_; | 66 views::ImageView* icon_; |
51 views::Label* label_; | 67 views::Label* label_; |
52 views::ImageView* more_; | 68 views::ImageView* more_; |
53 base::string16 accessible_name_; | 69 base::string16 accessible_name_; |
54 | 70 |
55 DISALLOW_COPY_AND_ASSIGN(TrayItemMore); | 71 DISALLOW_COPY_AND_ASSIGN(TrayItemMore); |
56 }; | 72 }; |
57 | 73 |
58 } // namespace ash | 74 } // namespace ash |
59 | 75 |
60 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ | 76 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ |
OLD | NEW |