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

Side by Side Diff: ash/common/system/tray/tray_popup_utils.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
7
8 #include <memory>
9
10 #include "ash/common/login_status.h"
11 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/system/tray/tray_popup_ink_drop_style.h"
13 #include "ash/common/system/tray/tri_view.h"
14 #include "base/strings/string16.h"
15
16 namespace views {
17 class ButtonListener;
18 class CustomButton;
19 class ImageView;
20 class InkDrop;
21 class InkDropRipple;
22 class InkDropHighlight;
23 class InkDropHostView;
24 class InkDropMask;
25 class Label;
26 class LabelButton;
27 class Painter;
28 class Separator;
29 class Slider;
30 class SliderListener;
31 class ToggleButton;
32 } // namespace views
33
34 namespace ash {
35
36 // Factory/utility functions used by the system menu.
37 class TrayPopupUtils {
38 public:
39 // Creates a default container view to be used by system menu rows that are
40 // either a single targetable area or not targetable at all. The caller takes
41 // over ownership of the created view.
42 //
43 // The returned view consists of 3 regions: START, CENTER, and END. Any child
44 // Views added to the START and END containers will be added horizontally and
45 // any Views added to the CENTER container will be added vertically.
46 //
47 // The START and END containers have a fixed minimum width but can grow into
48 // the CENTER container if space is required and available.
49 //
50 // The CENTER container has a flexible width.
51 static TriView* CreateDefaultRowView();
52
53 // Creates a container view to be used by system menu sub-section header rows.
54 // The caller takes over ownership of the created view.
55 //
56 // The returned view consists of 2 regions: CENTER, and END having the same
57 // properties as when using |CreateMultiTargetRowView|. The START container is
58 // hidden.
59 // The END container has a fixed minimum width but can grow into the CENTER
60 // container if space is required and available. The CENTER container has a
61 // flexible width.
62 static TriView* CreateSubHeaderRowView();
63
64 // Creates a container view to be used by system menu rows that want to embed
65 // a targetable area within one (or more) of the containers OR by any row
66 // that requires a non-default layout within the container views. The returned
67 // view will have the following configurations:
68 // - default minimum row height
69 // - default minimum width for the START and END containers
70 // - default left and right insets
71 // - default container flex values
72 // - Each container view will have a FillLayout installed on it
73 //
74 // The caller takes over ownership of the created view.
75 //
76 // The START and END containers have a fixed minimum width but can grow into
77 // the CENTER container if space is required and available. The CENTER
78 // container has a flexible width.
79 //
80 // Clients can use ConfigureContainer() to configure their own container views
81 // before adding them to the returned TriView.
82 static TriView* CreateMultiTargetRowView();
83
84 // Returns a label that has been configured for system menu layout. This
85 // should be used by all rows that require a label, i.e. both default and
86 // detailed rows should use this.
87 //
88 // TODO(bruthig): Update all system menu rows to use this.
89 static views::Label* CreateDefaultLabel();
90
91 // Returns an image view to be used in the main image region of a system menu
92 // row. This should be used by all rows that have a main image, i.e. both
93 // default and detailed rows should use this.
94 //
95 // TODO(bruthig): Update all system menu rows to use this.
96 static views::ImageView* CreateMainImageView();
97
98 // Returns an image view to be used in the 'more' region of default rows. This
99 // is used for all 'more' images as well as other images that appear in this
100 // region, e.g. audio output icon.
101 //
102 // TODO(bruthig): Update all default rows to use this.
103 static views::ImageView* CreateMoreImageView();
104
105 // Returns a slider configured for proper layout within a TriView container
106 // with a FillLayout.
107 static views::Slider* CreateSlider(views::SliderListener* listener);
108
109 // Returns a ToggleButton that has been configured for system menu layout.
110 static views::ToggleButton* CreateToggleButton(
111 views::ButtonListener* listener,
112 int accessible_name_id);
113
114 // Creates a default focus painter used for most things in tray popups.
115 static std::unique_ptr<views::Painter> CreateFocusPainter();
116
117 // Common setup for various buttons in the system menu.
118 static void ConfigureTrayPopupButton(views::CustomButton* button);
119
120 // Sets up |view| to be a sticky header in a tray detail scroll view.
121 static void ConfigureAsStickyHeader(views::View* view);
122
123 // Configures a |view| to have a visible separator below.
124 static void ShowStickyHeaderSeparator(views::View* view, bool show_separator);
125
126 // Configures |container_view| just like CreateDefaultRowView() would
127 // configure |container| on its returned TriView. To be used when mutliple
128 // targetable areas are required within a single row.
129 static void ConfigureContainer(TriView::Container container,
130 views::View* container_view);
131
132 // Creates a button for use in the system menu that only has a visible border
133 // when being hovered/clicked. Caller assumes ownership.
134 static views::LabelButton* CreateTrayPopupBorderlessButton(
135 views::ButtonListener* listener,
136 const base::string16& text);
137
138 // Creates a button for use in the system menu. For MD, this is a prominent
139 // text
140 // button. For non-MD, this does the same thing as the above. Caller assumes
141 // ownership.
142 static views::LabelButton* CreateTrayPopupButton(
143 views::ButtonListener* listener,
144 const base::string16& text);
145
146 // Creates and returns a vertical separator to be used between two items in a
147 // material design system menu row. The caller assumes ownership of the
148 // returned separator.
149 static views::Separator* CreateVerticalSeparator();
150
151 // Creates in InkDrop instance for |host| according to the |ink_drop_style|.
152 // All styles are configured to show the highlight when the ripple is visible.
153 //
154 // All targetable views in the system menu should delegate
155 // InkDropHost::CreateInkDrop() calls here.
156 static std::unique_ptr<views::InkDrop> CreateInkDrop(
157 TrayPopupInkDropStyle ink_drop_style,
158 views::InkDropHostView* host);
159
160 // Creates an InkDropRipple instance for |host| according to the
161 // |ink_drop_style|. The ripple will be centered on |center_point|.
162 //
163 // All targetable views in the system menu should delegate
164 // InkDropHost::CreateInkDropRipple() calls here.
165 static std::unique_ptr<views::InkDropRipple> CreateInkDropRipple(
166 TrayPopupInkDropStyle ink_drop_style,
167 const views::View* host,
168 const gfx::Point& center_point,
169 SkColor color = kTrayPopupInkDropBaseColor);
170
171 // Creates in InkDropHighlight instance for |host| according to the
172 // |ink_drop_style|.
173 //
174 // All targetable views in the system menu should delegate
175 // InkDropHost::CreateInkDropHighlight() calls here.
176 static std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight(
177 TrayPopupInkDropStyle ink_drop_style,
178 const views::View* host,
179 SkColor color = kTrayPopupInkDropBaseColor);
180
181 // Creates in InkDropMask instance for |host| according to the
182 // |ink_drop_style|. May return null.
183 //
184 // All targetable views in the system menu should delegate
185 // InkDropHost::CreateInkDropMask() calls here.
186 static std::unique_ptr<views::InkDropMask> CreateInkDropMask(
187 TrayPopupInkDropStyle ink_drop_style,
188 const views::View* host);
189
190 // Creates and returns a horizontal separator line to be drawn between rows
191 // in a detailed view. If |left_inset| is true, then the separator is inset on
192 // the left by the width normally occupied by an icon. Caller assumes
193 // ownership of the returned separator.
194 static views::Separator* CreateListItemSeparator(bool left_inset);
195
196 // Creates and returns a horizontal separator line to be drawn between rows
197 // in a detailed view above the sub-header rows. Caller assumes ownership of
198 // the returned separator.
199 static views::Separator* CreateListSubHeaderSeparator();
200
201 // Returns true if it is possible to open WebUI settings in a browser window,
202 // i.e., the user is logged in, not on the lock screen, and not in a secondary
203 // account flow.
204 static bool CanOpenWebUISettings(LoginStatus status);
205
206 private:
207 // Returns the effective ink drop insets for |host| according to the
208 // |ink_drop_style|.
209 static gfx::Insets GetInkDropInsets(TrayPopupInkDropStyle ink_drop_style);
210
211 // Returns the effective ink drop bounds for |host| according to the
212 // |ink_drop_style|.
213 static gfx::Rect GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style,
214 const views::View* host);
215
216 DISALLOW_IMPLICIT_CONSTRUCTORS(TrayPopupUtils);
217 };
218
219 } // namespace ash
220
221 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_item_style.cc ('k') | ash/common/system/tray/tray_popup_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698