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" |
11 #include "ash/common/system/tray/tray_popup_item_style.h" | |
12 #include "ash/common/system/tray/tray_popup_item_style_observer.h" | |
9 #include "base/macros.h" | 13 #include "base/macros.h" |
10 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
11 | 15 |
12 namespace views { | 16 namespace views { |
13 class ImageView; | 17 class ImageView; |
14 class Label; | 18 class Label; |
15 class View; | 19 class View; |
16 } | 20 } |
17 | 21 |
18 namespace ash { | 22 namespace ash { |
19 class SystemTrayItem; | 23 class SystemTrayItem; |
20 | 24 |
21 // A view with a chevron ('>') on the right edge. Clicking on the view brings up | 25 // A view with a chevron ('>') on the right edge. Clicking on the view brings up |
tdanderson
2016/09/08 16:11:02
Maybe update this documentation while you're here.
bruthig
2016/09/12 13:45:34
Updated, WDYT?
tdanderson
2016/09/12 18:51:46
lg
| |
22 // the detailed view of the tray-item that owns it. | 26 // the detailed view of the tray-item that owns it. |
23 class TrayItemMore : public ActionableView { | 27 class TrayItemMore : public ActionableView, public TrayPopupItemStyleObserver { |
24 public: | 28 public: |
25 TrayItemMore(SystemTrayItem* owner, bool show_more); | 29 TrayItemMore(SystemTrayItem* owner, bool show_more); |
26 ~TrayItemMore() override; | 30 ~TrayItemMore() override; |
27 | 31 |
28 SystemTrayItem* owner() const { return owner_; } | 32 SystemTrayItem* owner() const { return owner_; } |
29 | 33 |
30 void SetLabel(const base::string16& label); | 34 void SetLabel(const base::string16& label); |
31 void SetImage(const gfx::ImageSkia& image_skia); | 35 void SetImage(const gfx::ImageSkia& image_skia); |
32 void SetAccessibleName(const base::string16& name); | 36 void SetAccessibleName(const base::string16& name); |
33 | 37 |
38 // Set the current visual style of this item. OnTrayPopupItemStyleChanged() | |
39 // will be called. | |
40 void SetStyle(std::unique_ptr<TrayPopupItemStyle> style); | |
41 | |
34 protected: | 42 protected: |
35 // Replaces the default icon (on the left of the label), and allows a custom | 43 // TrayPopupItemStyleObserver: |
36 // view to be placed there. Once the default icon is replaced, |SetImage| | 44 void OnTrayPopupItemStyleChanged() override; |
37 // should never be called. | 45 |
38 void ReplaceIcon(views::View* view); | 46 TrayPopupItemStyle* style() const { return style_.get(); } |
39 | 47 |
40 private: | 48 private: |
49 // Updates the children Views owned by this. | |
50 void UpdateChildren(); | |
51 | |
41 // Overridden from ActionableView. | 52 // Overridden from ActionableView. |
42 bool PerformAction(const ui::Event& event) override; | 53 bool PerformAction(const ui::Event& event) override; |
43 | 54 |
44 // Overridden from views::View. | 55 // Overridden from views::View. |
45 void Layout() override; | 56 void Layout() override; |
46 void GetAccessibleState(ui::AXViewState* state) override; | 57 void GetAccessibleState(ui::AXViewState* state) override; |
58 void OnThemeChanged() override; | |
47 | 59 |
48 SystemTrayItem* owner_; | 60 SystemTrayItem* owner_; |
49 // True if |more_| should be shown. | 61 // True if |more_| should be shown. |
50 bool show_more_; | 62 bool show_more_; |
51 views::ImageView* icon_; | 63 views::ImageView* icon_; |
52 views::Label* label_; | 64 views::Label* label_; |
53 views::ImageView* more_; | 65 views::ImageView* more_; |
54 base::string16 accessible_name_; | 66 base::string16 accessible_name_; |
55 | 67 |
68 // Current visual style of this item. | |
tdanderson
2016/09/08 16:11:02
consider specifying here (or in the class-level do
bruthig
2016/09/12 13:45:34
Done.
| |
69 std::unique_ptr<TrayPopupItemStyle> style_; | |
70 | |
56 DISALLOW_COPY_AND_ASSIGN(TrayItemMore); | 71 DISALLOW_COPY_AND_ASSIGN(TrayItemMore); |
57 }; | 72 }; |
58 | 73 |
59 } // namespace ash | 74 } // namespace ash |
60 | 75 |
61 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ | 76 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ |
OLD | NEW |