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

Side by Side Diff: ui/views/views_delegate.h

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Prefer embedded initialization over heap allocation for TestViewsDelegate 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
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 UI_VIEWS_VIEWS_DELEGATE_H_ 5 #ifndef UI_VIEWS_VIEWS_DELEGATE_H_
6 #define UI_VIEWS_VIEWS_DELEGATE_H_ 6 #define UI_VIEWS_VIEWS_DELEGATE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 class Widget; 51 class Widget;
52 52
53 #if defined(USE_AURA) 53 #if defined(USE_AURA)
54 class TouchSelectionMenuRunnerViews; 54 class TouchSelectionMenuRunnerViews;
55 #endif 55 #endif
56 56
57 namespace internal { 57 namespace internal {
58 class NativeWidgetDelegate; 58 class NativeWidgetDelegate;
59 } 59 }
60 60
61 enum class InsetsMetric {
62 // The insets that should be applied around a DialogClientView. Note that
63 // the top inset is used for the distance between the buttons and the
64 // DialogClientView's content view.
65 DIALOG_BUTTON,
66 // The insets that should be applied around a dialog's frame view.
67 DIALOG_FRAME_VIEW,
68 // The margins that should be applied around a bubble dialog.
Peter Kasting 2017/03/01 06:32:36 What is a "bubble dialog"? Is that what the UX fo
kylix_rd 2017/03/01 17:33:27 Yes, I think the UX folks are using "popover" as a
Peter Kasting 2017/03/01 23:32:23 That's fair.
69 BUBBLE_DIALOG,
70 };
71
72 enum class SpacingMetric {
Peter Kasting 2017/03/01 06:32:36 Nit: I suggest naming these to closely align with
kylix_rd 2017/03/01 17:33:27 Some of those constant names contain the word "SPA
Peter Kasting 2017/03/01 23:32:23 That's fine, I didn't mean you had to copy names e
73 // The distance between a dialog's edge and the close button in the upper
74 // trailing corner.
75 CLOSE_BUTTON_MARGIN,
76 // The spacing between a pair of related horizontal buttons, used for
77 // dialog layout.
78 RELATED_HORIZONTAL_BUTTON,
79 // The spacing between a pair of related vertical controls, used for
80 // dialog layout.
81 RELATED_VERTICAL_CONTROL,
82 // The spacing between the image on a label button and its associated
83 // text.
84 ICON_TO_TEXT,
85 // Returns the default minimum width of a dialog button.
Peter Kasting 2017/03/01 06:32:36 Nit: No "Returns" (2 places)
kylix_rd 2017/03/01 17:33:27 Done.
86 DIALOG_BUTTON_MINIMUM_WIDTH,
87 // Returns the default padding to add on each side of a button's label.
88 BUTTON_HORIZONTAL_PADDING,
89 };
90
61 // ViewsDelegate is an interface implemented by an object using the views 91 // ViewsDelegate is an interface implemented by an object using the views
62 // framework. It is used to obtain various high level application utilities 92 // framework. It is used to obtain various high level application utilities
63 // and perform some actions such as window placement saving. 93 // and perform some actions such as window placement saving.
64 // 94 //
65 // The embedding app must set the ViewsDelegate instance by instantiating an 95 // The embedding app must set the ViewsDelegate instance by instantiating an
66 // implementation of ViewsDelegate (the constructor will set the instance). 96 // implementation of ViewsDelegate (the constructor will set the instance).
67 class VIEWS_EXPORT ViewsDelegate { 97 class VIEWS_EXPORT ViewsDelegate {
68 public: 98 public:
69 using NativeWidgetFactory = 99 using NativeWidgetFactory =
70 base::Callback<NativeWidget*(const Widget::InitParams&, 100 base::Callback<NativeWidget*(const Widget::InitParams&,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // not changed, |callback| is never run. 219 // not changed, |callback| is never run.
190 // 220 //
191 // The return value is a bitmask of AppbarAutohideEdge. 221 // The return value is a bitmask of AppbarAutohideEdge.
192 virtual int GetAppbarAutohideEdges(HMONITOR monitor, 222 virtual int GetAppbarAutohideEdges(HMONITOR monitor,
193 const base::Closure& callback); 223 const base::Closure& callback);
194 #endif 224 #endif
195 225
196 // Returns a blocking pool task runner given a TaskRunnerType. 226 // Returns a blocking pool task runner given a TaskRunnerType.
197 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner(); 227 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner();
198 228
199 // Returns the insets that should be applied around a DialogClientView. Note 229 // Returns the insets metric according to the given enumeration element.
200 // that the top inset is used for the distance between the buttons and the 230 virtual gfx::Insets GetInsetsMetric(InsetsMetric metric) const;
201 // DialogClientView's content view.
202 virtual gfx::Insets GetDialogButtonInsets() const;
203 231
204 // Returns the distance between a dialog's edge and the close button in the 232 // Returns the spacing metric according to the given enumeration element.
205 // upper trailing corner. 233 virtual int GetSpacingMetric(SpacingMetric metric) const;
206 virtual int GetDialogCloseButtonMargin() const;
207 234
208 // Returns the spacing between a pair of related horizontal buttons, used for 235 // Returns the default metric in instances where a delegate hasn't been
209 // dialog layout. 236 // instantiated.
210 virtual int GetDialogRelatedButtonHorizontalSpacing() const; 237 static int GetDefaultSpacingMetric(SpacingMetric metric);
sky 2017/02/28 20:11:52 Now that you've made it so ViewsDelegate is always
kylix_rd 2017/03/01 17:33:27 Done.
211
212 // Returns the spacing between a pair of related vertical controls, used for
213 // dialog layout.
214 virtual int GetDialogRelatedControlVerticalSpacing() const;
215
216 // Returns the insets that should be applied around a dialog's frame view.
217 virtual gfx::Insets GetDialogFrameViewInsets() const;
218
219 // Returns the margins that should be applied around a bubble dialog.
220 virtual gfx::Insets GetBubbleDialogMargins() const;
221
222 // Returns the default minimum width of a button.
223 virtual int GetButtonMinimumWidth() const;
224
225 // Returns the minimum width of a dialog button.
226 virtual int GetDialogButtonMinimumWidth() const;
227
228 // Returns the default padding to add on each side of a button's label.
229 virtual int GetButtonHorizontalPadding() const;
230 238
231 protected: 239 protected:
232 ViewsDelegate(); 240 ViewsDelegate();
233 241
234 private: 242 private:
235 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; 243 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
236 244
237 #if defined(USE_AURA) 245 #if defined(USE_AURA)
238 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_; 246 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_;
239 #endif 247 #endif
240 248
241 NativeWidgetFactory native_widget_factory_; 249 NativeWidgetFactory native_widget_factory_;
242 250
243 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate); 251 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
244 }; 252 };
245 253
246 } // namespace views 254 } // namespace views
247 255
248 #endif // UI_VIEWS_VIEWS_DELEGATE_H_ 256 #endif // UI_VIEWS_VIEWS_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698