| 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 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 Loading... |
| 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 margins that should be applied around a bubble dialog. |
| 63 BUBBLE_DIALOG, |
| 64 // The insets that should be applied around a DialogClientView. Note that |
| 65 // the top inset is used for the distance between the buttons and the |
| 66 // DialogClientView's content view. |
| 67 DIALOG_BUTTON, |
| 68 // The insets that should be applied around a dialog's frame view. |
| 69 DIALOG_FRAME_VIEW, |
| 70 }; |
| 71 |
| 72 enum class DistanceMetric { |
| 73 // The default padding to add on each side of a button's label. |
| 74 BUTTON_HORIZONTAL_PADDING, |
| 75 // The distance between a dialog's edge and the close button in the upper |
| 76 // trailing corner. |
| 77 CLOSE_BUTTON_MARGIN, |
| 78 // The default minimum width of a dialog button. |
| 79 DIALOG_BUTTON_MINIMUM_WIDTH, |
| 80 // The spacing between a pair of related horizontal buttons, used for |
| 81 // dialog layout. |
| 82 RELATED_BUTTON_HORIZONTAL, |
| 83 // Horizontal spacing between controls that are logically related. |
| 84 RELATED_CONTROL_HORIZONTAL, |
| 85 // The spacing between a pair of related vertical controls, used for |
| 86 // dialog layout. |
| 87 RELATED_CONTROL_VERTICAL, |
| 88 }; |
| 89 |
| 61 // ViewsDelegate is an interface implemented by an object using the views | 90 // ViewsDelegate is an interface implemented by an object using the views |
| 62 // framework. It is used to obtain various high level application utilities | 91 // framework. It is used to obtain various high level application utilities |
| 63 // and perform some actions such as window placement saving. | 92 // and perform some actions such as window placement saving. |
| 64 // | 93 // |
| 65 // The embedding app must set the ViewsDelegate instance by instantiating an | 94 // The embedding app must set the ViewsDelegate instance by instantiating an |
| 66 // implementation of ViewsDelegate (the constructor will set the instance). | 95 // implementation of ViewsDelegate (the constructor will set the instance). |
| 67 class VIEWS_EXPORT ViewsDelegate { | 96 class VIEWS_EXPORT ViewsDelegate { |
| 68 public: | 97 public: |
| 69 using NativeWidgetFactory = | 98 using NativeWidgetFactory = |
| 70 base::Callback<NativeWidget*(const Widget::InitParams&, | 99 base::Callback<NativeWidget*(const Widget::InitParams&, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // not changed, |callback| is never run. | 218 // not changed, |callback| is never run. |
| 190 // | 219 // |
| 191 // The return value is a bitmask of AppbarAutohideEdge. | 220 // The return value is a bitmask of AppbarAutohideEdge. |
| 192 virtual int GetAppbarAutohideEdges(HMONITOR monitor, | 221 virtual int GetAppbarAutohideEdges(HMONITOR monitor, |
| 193 const base::Closure& callback); | 222 const base::Closure& callback); |
| 194 #endif | 223 #endif |
| 195 | 224 |
| 196 // Returns a blocking pool task runner given a TaskRunnerType. | 225 // Returns a blocking pool task runner given a TaskRunnerType. |
| 197 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner(); | 226 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner(); |
| 198 | 227 |
| 199 // Returns the insets that should be applied around a DialogClientView. Note | 228 // 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 | 229 virtual gfx::Insets GetInsetsMetric(InsetsMetric metric) const; |
| 201 // DialogClientView's content view. | |
| 202 virtual gfx::Insets GetDialogButtonInsets() const; | |
| 203 | 230 |
| 204 // Returns the distance between a dialog's edge and the close button in the | 231 // Returns the distance metric between elements according to the given |
| 205 // upper trailing corner. | 232 // enumeration element. |
| 206 virtual int GetDialogCloseButtonMargin() const; | 233 virtual int GetDistanceMetric(DistanceMetric metric) 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 | |
| 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 | 234 |
| 231 protected: | 235 protected: |
| 232 ViewsDelegate(); | 236 ViewsDelegate(); |
| 233 | 237 |
| 234 private: | 238 private: |
| 235 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; | 239 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; |
| 236 | 240 |
| 237 #if defined(USE_AURA) | 241 #if defined(USE_AURA) |
| 238 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_; | 242 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_; |
| 239 #endif | 243 #endif |
| 240 | 244 |
| 241 NativeWidgetFactory native_widget_factory_; | 245 NativeWidgetFactory native_widget_factory_; |
| 242 | 246 |
| 243 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate); | 247 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate); |
| 244 }; | 248 }; |
| 245 | 249 |
| 246 } // namespace views | 250 } // namespace views |
| 247 | 251 |
| 248 #endif // UI_VIEWS_VIEWS_DELEGATE_H_ | 252 #endif // UI_VIEWS_VIEWS_DELEGATE_H_ |
| OLD | NEW |