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 a targetable row to |scroll_content_| containing |icon| and |text|. |
| 74 HoverHighlightView* AddScrollListItem(const gfx::VectorIcon& icon, |
| 75 const base::string16& text); |
| 76 |
| 77 // Adds a targetable row to |scroll_content_| containing |icon|, |text|, and a |
| 78 // checkbox. |checked| determines whether the checkbox is checked or not. |
| 79 HoverHighlightView* AddScrollListCheckableItem(const gfx::VectorIcon& icon, |
| 80 const base::string16& text, |
| 81 bool checked); |
| 82 |
| 83 // Adds a targetable row to |scroll_content_| containing |text| and a |
| 84 // checkbox. |checked| determines whether the checkbox is checked or not. |
| 85 HoverHighlightView* AddScrollListCheckableItem(const base::string16& text, |
| 86 bool checked); |
| 87 |
| 88 // Adds a sticky sub header to |scroll_content_| containing |icon| and a text |
| 89 // represented by |text_id| resource id. |
| 90 TriView* AddScrollListSubHeader(const gfx::VectorIcon& icon, int text_id); |
| 91 |
| 92 // Adds a sticky sub header to |scroll_content_| containing a text represented |
| 93 // by |text_id| resource id. |
| 94 TriView* AddScrollListSubHeader(int text_id); |
| 95 |
70 // Removes (and destroys) all child views. | 96 // Removes (and destroys) all child views. |
71 void Reset(); | 97 void Reset(); |
72 | 98 |
73 // Shows or hides the progress bar below the title row. It occupies the same | 99 // 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 | 100 // space as the separator, so when shown the separator is hidden. If |
75 // |progress_bar_| doesn't already exist it will be created. | 101 // |progress_bar_| doesn't already exist it will be created. |
76 void ShowProgress(double value, bool visible); | 102 void ShowProgress(double value, bool visible); |
77 | 103 |
78 // Helper functions which create and return the settings and help buttons, | 104 // Helper functions which create and return the settings and help buttons, |
79 // respectively, used in the material design top-most header row. The caller | 105 // respectively, used in the material design top-most header row. The caller |
80 // assumes ownership of the returned buttons. | 106 // assumes ownership of the returned buttons. |
81 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id); | 107 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id); |
82 views::CustomButton* CreateHelpButton(); | 108 views::CustomButton* CreateHelpButton(); |
83 | 109 |
84 TriView* tri_view() { return tri_view_; } | 110 TriView* tri_view() { return tri_view_; } |
| 111 views::ScrollView* scroller() const { return scroller_; } |
| 112 views::View* scroll_content() const { return scroll_content_; } |
85 | 113 |
86 private: | 114 private: |
87 friend class test::TrayDetailsViewTest; | 115 friend class test::TrayDetailsViewTest; |
88 | 116 |
89 // Overridden to handle clicks on subclass-specific views. | 117 // Overridden to handle clicks on subclass-specific views. |
90 virtual void HandleViewClicked(views::View* view); | 118 virtual void HandleViewClicked(views::View* view); |
91 | 119 |
92 // Overridden to handle button presses on subclass-specific buttons. | 120 // Overridden to handle button presses on subclass-specific buttons. |
93 virtual void HandleButtonPressed(views::Button* sender, | 121 virtual void HandleButtonPressed(views::Button* sender, |
94 const ui::Event& event); | 122 const ui::Event& event); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 156 |
129 // Used to delay the transition to the default view. | 157 // Used to delay the transition to the default view. |
130 base::OneShotTimer transition_delay_timer_; | 158 base::OneShotTimer transition_delay_timer_; |
131 | 159 |
132 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); | 160 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); |
133 }; | 161 }; |
134 | 162 |
135 } // namespace ash | 163 } // namespace ash |
136 | 164 |
137 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 165 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
OLD | NEW |