Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1373)

Side by Side Diff: ash/system/tray/tray_details_view.h

Issue 2831023003: Refactor AddScrollListItem() in system menu detailed views (Closed)
Patch Set: Rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/hover_highlight_view.cc ('k') | ash/system/tray/tray_details_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // |gfx::kNoneIcon| can be used if there is no icon.
75 HoverHighlightView* AddScrollListItem(const gfx::VectorIcon& icon,
76 const base::string16& text);
77
78 // Adds a targetable row to |scroll_content_| containing |icon|, |text|, and a
79 // checkbox. |checked| determines whether the checkbox is checked or not.
80 // |gfx::kNoneIcon| can be used if there is no icon.
81 HoverHighlightView* AddScrollListCheckableItem(const gfx::VectorIcon& icon,
tdanderson 2017/04/25 14:32:48 Sorry for the churn here, but how about instead ov
mohsen 2017/04/25 19:23:48 I believe preference is not to overload functions.
tdanderson 2017/04/25 21:00:27 As discussed offline, I think overloading is appro
mohsen 2017/04/25 21:54:52 Done.
82 const base::string16& text,
83 bool checked);
84
85 // Convenience function to call AddScrollListCheckableItem() with
86 // |gfx::kNoneIcon|.
87 HoverHighlightView* AddScrollListCheckableItemWithoutIcon(
88 const base::string16& text,
89 bool checked);
90
91 // Adds a sticky sub header to |scroll_content_| containing |icon| and a text
92 // represented by |text_id| resource id. |gfx::kNoneIcon| can be used if there
93 // is no icon.
94 TriView* AddScrollListSubHeader(const gfx::VectorIcon& icon, int text_id);
95
96 // Convenience function to call AddScrollListSubHeader() with
97 // |gfx::kNoneIcon|.
tdanderson 2017/04/25 14:32:48 nit: I suggest omitting mention of kNoneIcon in th
mohsen 2017/04/25 19:23:47 Removed kNoneIcon from all these functions' commen
98 TriView* AddScrollListSubHeaderWithoutIcon(int text_id);
99
70 // Removes (and destroys) all child views. 100 // Removes (and destroys) all child views.
71 void Reset(); 101 void Reset();
72 102
73 // Shows or hides the progress bar below the title row. It occupies the same 103 // 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 104 // space as the separator, so when shown the separator is hidden. If
75 // |progress_bar_| doesn't already exist it will be created. 105 // |progress_bar_| doesn't already exist it will be created.
76 void ShowProgress(double value, bool visible); 106 void ShowProgress(double value, bool visible);
77 107
78 // Helper functions which create and return the settings and help buttons, 108 // Helper functions which create and return the settings and help buttons,
79 // respectively, used in the material design top-most header row. The caller 109 // respectively, used in the material design top-most header row. The caller
80 // assumes ownership of the returned buttons. 110 // assumes ownership of the returned buttons.
81 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id); 111 views::CustomButton* CreateSettingsButton(int setting_accessible_name_id);
82 views::CustomButton* CreateHelpButton(); 112 views::CustomButton* CreateHelpButton();
83 113
84 TriView* tri_view() { return tri_view_; } 114 TriView* tri_view() { return tri_view_; }
115 views::ScrollView* scroller() const { return scroller_; }
116 views::View* scroll_content() const { return scroll_content_; }
85 117
86 private: 118 private:
87 friend class test::TrayDetailsViewTest; 119 friend class test::TrayDetailsViewTest;
88 120
89 // Overridden to handle clicks on subclass-specific views. 121 // Overridden to handle clicks on subclass-specific views.
90 virtual void HandleViewClicked(views::View* view); 122 virtual void HandleViewClicked(views::View* view);
91 123
92 // Overridden to handle button presses on subclass-specific buttons. 124 // Overridden to handle button presses on subclass-specific buttons.
93 virtual void HandleButtonPressed(views::Button* sender, 125 virtual void HandleButtonPressed(views::Button* sender,
94 const ui::Event& event); 126 const ui::Event& event);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 160
129 // Used to delay the transition to the default view. 161 // Used to delay the transition to the default view.
130 base::OneShotTimer transition_delay_timer_; 162 base::OneShotTimer transition_delay_timer_;
131 163
132 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); 164 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView);
133 }; 165 };
134 166
135 } // namespace ash 167 } // namespace ash
136 168
137 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ 169 #endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_
OLDNEW
« no previous file with comments | « ash/system/tray/hover_highlight_view.cc ('k') | ash/system/tray/tray_details_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698