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

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: Reduced ViewsDelegate layout/metric functions to only two functions Created 3 years, 10 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 enum class ProcessMenuAcceleratorResult { 81 enum class ProcessMenuAcceleratorResult {
82 // The accelerator was handled while the menu was showing. No further action 82 // The accelerator was handled while the menu was showing. No further action
83 // is needed and the menu should be kept open. 83 // is needed and the menu should be kept open.
84 LEAVE_MENU_OPEN, 84 LEAVE_MENU_OPEN,
85 85
86 // The accelerator was not handled. Menu should be closed and the 86 // The accelerator was not handled. Menu should be closed and the
87 // accelerator will be reposted to be handled after the menu closes. 87 // accelerator will be reposted to be handled after the menu closes.
88 CLOSE_MENU 88 CLOSE_MENU
89 }; 89 };
90 90
91 enum class InsetsMetric {
sky 2017/02/17 20:50:46 optional: move this and SpacingMetric outside of V
kylix_rd 2017/02/17 21:40:51 I added them based on the precedent set by Process
sky 2017/02/17 22:39:03 For enums that are used extensively, like I think
92 // The insets that should be applied around a DialogClientView. Note that
93 // the top inset is used for the distance between the buttons and the
94 // DialogClientView's content view.
95 DIALOG_BUTTON,
96 // The insets that should be applied around a dialog's frame view.
97 DIALOG_FRAME_VIEW,
98 // The margins that should be applied around a bubble dialog.
99 BUBBLE_DIALOG,
100 };
101
102 enum class SpacingMetric {
103 // The distance between a dialog's edge and the close button in the upper
104 // trailing corner.
105 CLOSE_BUTTON_MARGIN,
106 // The spacing between a pair of related horizontal buttons, used for
107 // dialog layout.
108 RELATED_HORIZONTAL_BUTTON,
109 // The spacing between a pair of related vertical controls, used for
110 // dialog layout.
111 RELATED_VERTICAL_CONTROL,
112 // The spacing between the image on a label button and its associated
113 // text.
114 ICON_TO_TEXT,
115 };
116
91 virtual ~ViewsDelegate(); 117 virtual ~ViewsDelegate();
92 118
93 // Returns the ViewsDelegate instance if there is one, or nullptr otherwise. 119 // Returns the ViewsDelegate instance if there is one, or nullptr otherwise.
94 static ViewsDelegate* GetInstance(); 120 static ViewsDelegate* GetInstance();
95 121
96 // Call this method to set a factory callback that will be used to construct 122 // Call this method to set a factory callback that will be used to construct
97 // NativeWidget implementations overriding the platform defaults. 123 // NativeWidget implementations overriding the platform defaults.
98 void set_native_widget_factory(NativeWidgetFactory factory) { 124 void set_native_widget_factory(NativeWidgetFactory factory) {
99 native_widget_factory_ = factory; 125 native_widget_factory_ = factory;
100 } 126 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // not changed, |callback| is never run. 215 // not changed, |callback| is never run.
190 // 216 //
191 // The return value is a bitmask of AppbarAutohideEdge. 217 // The return value is a bitmask of AppbarAutohideEdge.
192 virtual int GetAppbarAutohideEdges(HMONITOR monitor, 218 virtual int GetAppbarAutohideEdges(HMONITOR monitor,
193 const base::Closure& callback); 219 const base::Closure& callback);
194 #endif 220 #endif
195 221
196 // Returns a blocking pool task runner given a TaskRunnerType. 222 // Returns a blocking pool task runner given a TaskRunnerType.
197 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner(); 223 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner();
198 224
199 // Returns the insets that should be applied around a DialogClientView. Note 225 // 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 226 virtual gfx::Insets GetInsetsMetric(InsetsMetric metric) const;
201 // DialogClientView's content view.
202 virtual gfx::Insets GetDialogButtonInsets() const;
203 227
204 // Returns the distance between a dialog's edge and the close button in the 228 // Returns the spacing metric according to the given enumeration element.
205 // upper trailing corner. 229 virtual int GetSpacingMetric(SpacingMetric metric) const;
206 virtual int GetDialogCloseButtonMargin() const;
207
208 // Returns the spacing between a pair of related horizontal buttons, used for
209 // dialog layout.
210 virtual int GetDialogRelatedButtonHorizontalSpacing() const;
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 230
222 protected: 231 protected:
223 ViewsDelegate(); 232 ViewsDelegate();
224 233
225 private: 234 private:
226 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; 235 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
227 236
228 #if defined(USE_AURA) 237 #if defined(USE_AURA)
229 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_; 238 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_;
230 #endif 239 #endif
231 240
232 NativeWidgetFactory native_widget_factory_; 241 NativeWidgetFactory native_widget_factory_;
233 242
234 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate); 243 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
235 }; 244 };
236 245
237 } // namespace views 246 } // namespace views
238 247
239 #endif // UI_VIEWS_VIEWS_DELEGATE_H_ 248 #endif // UI_VIEWS_VIEWS_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698