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_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 5 #ifndef ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
6 #define ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 6 #define ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/system/tray/tray_constants.h" | 11 #include "ash/system/tray/tray_constants.h" |
12 #include "ash/system/tray/view_click_listener.h" | 12 #include "ash/system/tray/view_click_listener.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
17 | 17 |
18 namespace gfx { | |
19 struct VectorIcon; | |
20 } // namespace gfx | |
21 | |
18 namespace views { | 22 namespace views { |
19 class BoxLayout; | 23 class BoxLayout; |
20 class CustomButton; | 24 class CustomButton; |
21 class ProgressBar; | 25 class ProgressBar; |
22 class ScrollView; | 26 class ScrollView; |
23 } // namespace views | 27 } // namespace views |
24 | 28 |
25 namespace ash { | 29 namespace ash { |
26 namespace test { | 30 namespace test { |
27 class TrayDetailsViewTest; | 31 class TrayDetailsViewTest; |
28 } // namespace test | 32 } // namespace test |
29 | 33 |
34 class HoverHighlightView; | |
30 class ScrollBorder; | 35 class ScrollBorder; |
31 class SystemTrayItem; | 36 class SystemTrayItem; |
32 class TriView; | 37 class TriView; |
33 | 38 |
34 class ASH_EXPORT TrayDetailsView : public views::View, | 39 class ASH_EXPORT TrayDetailsView : public views::View, |
35 public ViewClickListener, | 40 public ViewClickListener, |
36 public views::ButtonListener { | 41 public views::ButtonListener { |
37 public: | 42 public: |
38 explicit TrayDetailsView(SystemTrayItem* owner); | 43 explicit TrayDetailsView(SystemTrayItem* owner); |
39 ~TrayDetailsView() override; | 44 ~TrayDetailsView() override; |
40 | 45 |
41 // ViewClickListener: | 46 // ViewClickListener: |
42 // Don't override this --- override HandleViewClicked. | 47 // Don't override this --- override HandleViewClicked. |
43 void OnViewClicked(views::View* sender) final; | 48 void OnViewClicked(views::View* sender) final; |
44 | 49 |
45 // views::ButtonListener: | 50 // views::ButtonListener: |
46 // Don't override this --- override HandleButtonPressed. | 51 // Don't override this --- override HandleButtonPressed. |
47 void ButtonPressed(views::Button* sender, const ui::Event& event) final; | 52 void ButtonPressed(views::Button* sender, const ui::Event& event) final; |
48 | 53 |
49 SystemTrayItem* owner() { return owner_; } | 54 SystemTrayItem* owner() { return owner_; } |
50 views::ScrollView* scroller() { return scroller_; } | |
51 views::View* scroll_content() { return scroll_content_; } | |
52 | 55 |
53 protected: | 56 protected: |
54 // views::View: | 57 // views::View: |
55 void Layout() override; | 58 void Layout() override; |
56 int GetHeightForWidth(int width) const override; | 59 int GetHeightForWidth(int width) const override; |
57 | 60 |
58 // Exposes the layout manager of this view to give control to subclasses. | 61 // Exposes the layout manager of this view to give control to subclasses. |
59 views::BoxLayout* box_layout() { return box_layout_; } | 62 views::BoxLayout* box_layout() { return box_layout_; } |
60 | 63 |
61 // Creates the row containing the back button and title. For material design | 64 // Creates the row containing the back button and title. For material design |
62 // this appears at the top of the view, for non-material design it appears | 65 // this appears at the top of the view, for non-material design it appears |
63 // at the bottom. | 66 // at the bottom. |
64 void CreateTitleRow(int string_id); | 67 void CreateTitleRow(int string_id); |
65 | 68 |
66 // Creates a scrollable list. The list has a border at the bottom if there is | 69 // Creates a scrollable list. The list has a border at the bottom if there is |
67 // any other view between the list and the footer row at the bottom. | 70 // any other view between the list and the footer row at the bottom. |
68 void CreateScrollableList(); | 71 void CreateScrollableList(); |
69 | 72 |
73 // Adds an item to the scroll list. |gfx::kNoneIcon| can be used if there is | |
tdanderson
2017/04/24 15:43:39
nit: consider a rewording of first sentence to giv
mohsen
2017/04/25 05:10:01
Done.
| |
74 // no icon. | |
75 HoverHighlightView* AddScrollListItem(const gfx::VectorIcon& icon, | |
76 const base::string16& text); | |
77 // Adds an item to the scroll list with a checkbox. |gfx::kNoneIcon| can be | |
78 // used if there is no icon. | |
79 HoverHighlightView* AddScrollListCheckableItem(const gfx::VectorIcon& icon, | |
80 const base::string16& text, | |
81 bool checked); | |
tdanderson
2017/04/24 15:43:39
nit: newline
mohsen
2017/04/25 05:10:01
Done.
| |
82 // Adds a sticky sub header to the scroll list. |gfx::kNoneIcon| can be used | |
83 // if there is no icon. | |
84 TriView* AddScrollListSubHeader(const gfx::VectorIcon& icon, | |
tdanderson
2017/04/24 15:43:39
To simplify the call sites (not requiring kNoneIco
mohsen
2017/04/25 05:10:01
Done.
| |
85 const base::string16& text); | |
86 | |
70 // Removes (and destroys) all child views. | 87 // Removes (and destroys) all child views. |
71 void Reset(); | 88 void Reset(); |
72 | 89 |
73 // Shows or hides the progress bar below the title row. It occupies the same | 90 // Shows or hides the progress bar below the title row. It occupies the same |
74 // space as the separator, so when shown the separator is hidden. If | 91 // space as the separator, so when shown the separator is hidden. If |
75 // |progress_bar_| doesn't already exist it will be created. | 92 // |progress_bar_| doesn't already exist it will be created. |
76 void ShowProgress(double value, bool visible); | 93 void ShowProgress(double value, bool visible); |
77 | 94 |
78 // Helper functions which create and return the settings and help buttons, | 95 // Helper functions which create and return the settings and help buttons, |
79 // respectively, used in the material design top-most header row. The caller | 96 // respectively, used in the material design top-most header row. The caller |
80 // assumes ownership of the returned buttons. | 97 // assumes ownership of the returned buttons. |
81 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id); | 98 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id); |
82 views::CustomButton* CreateHelpButton(); | 99 views::CustomButton* CreateHelpButton(); |
83 | 100 |
84 TriView* tri_view() { return tri_view_; } | 101 TriView* tri_view() { return tri_view_; } |
102 views::ScrollView* scroller() const { return scroller_; } | |
103 views::View* scroll_content() const { return scroll_content_; } | |
85 | 104 |
86 private: | 105 private: |
87 friend class test::TrayDetailsViewTest; | 106 friend class test::TrayDetailsViewTest; |
88 | 107 |
89 // Overridden to handle clicks on subclass-specific views. | 108 // Overridden to handle clicks on subclass-specific views. |
90 virtual void HandleViewClicked(views::View* view); | 109 virtual void HandleViewClicked(views::View* view); |
91 | 110 |
92 // Overridden to handle button presses on subclass-specific buttons. | 111 // Overridden to handle button presses on subclass-specific buttons. |
93 virtual void HandleButtonPressed(views::Button* sender, | 112 virtual void HandleButtonPressed(views::Button* sender, |
94 const ui::Event& event); | 113 const ui::Event& event); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 147 |
129 // Used to delay the transition to the default view. | 148 // Used to delay the transition to the default view. |
130 base::OneShotTimer transition_delay_timer_; | 149 base::OneShotTimer transition_delay_timer_; |
131 | 150 |
132 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); | 151 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); |
133 }; | 152 }; |
134 | 153 |
135 } // namespace ash | 154 } // namespace ash |
136 | 155 |
137 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 156 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
OLD | NEW |