| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "ui/views/views_delegate.h" | 5 #include "ui/views/views_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/views/layout/layout_constants.h" | 9 #include "ui/views/layout/layout_constants.h" |
| 10 #include "ui/views/views_touch_selection_controller_factory.h" | 10 #include "ui/views/views_touch_selection_controller_factory.h" |
| 11 #include "ui/views/widget/native_widget_private.h" | 11 #include "ui/views/widget/native_widget_private.h" |
| 12 | 12 |
| 13 #if defined(USE_AURA) | 13 #if defined(USE_AURA) |
| 14 #include "ui/views/touchui/touch_selection_menu_runner_views.h" | 14 #include "ui/views/touchui/touch_selection_menu_runner_views.h" |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 ViewsDelegate* views_delegate = nullptr; | 20 ViewsDelegate* views_delegate = nullptr; |
| 21 | 21 |
| 22 // Horizontal spacing between the image of a label button and its text. This |
| 23 // affects checkboxes and radiobuttons. |
| 24 constexpr int kIconTextSpacing = 5; |
| 22 } | 25 } |
| 23 | 26 |
| 24 ViewsDelegate::~ViewsDelegate() { | 27 ViewsDelegate::~ViewsDelegate() { |
| 25 ui::TouchEditingControllerFactory::SetInstance(nullptr); | 28 ui::TouchEditingControllerFactory::SetInstance(nullptr); |
| 26 | 29 |
| 27 DCHECK_EQ(this, views_delegate); | 30 DCHECK_EQ(this, views_delegate); |
| 28 views_delegate = nullptr; | 31 views_delegate = nullptr; |
| 29 } | 32 } |
| 30 | 33 |
| 31 ViewsDelegate* ViewsDelegate::GetInstance() { | 34 ViewsDelegate* ViewsDelegate::GetInstance() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor, | 122 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor, |
| 120 const base::Closure& callback) { | 123 const base::Closure& callback) { |
| 121 return EDGE_BOTTOM; | 124 return EDGE_BOTTOM; |
| 122 } | 125 } |
| 123 #endif | 126 #endif |
| 124 | 127 |
| 125 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() { | 128 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() { |
| 126 return nullptr; | 129 return nullptr; |
| 127 } | 130 } |
| 128 | 131 |
| 129 gfx::Insets ViewsDelegate::GetDialogButtonInsets() const { | 132 gfx::Insets ViewsDelegate::GetInsetsMetric(InsetsMetric metric) const { |
| 130 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, | 133 switch (metric) { |
| 131 kButtonHEdgeMarginNew); | 134 case InsetsMetric::DIALOG_BUTTON: |
| 135 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, |
| 136 kButtonHEdgeMarginNew); |
| 137 case InsetsMetric::DIALOG_FRAME_VIEW: |
| 138 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, |
| 139 kButtonHEdgeMarginNew); |
| 140 case InsetsMetric::BUBBLE_DIALOG: |
| 141 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin); |
| 142 } |
| 143 NOTREACHED(); |
| 144 return gfx::Insets(); |
| 132 } | 145 } |
| 133 | 146 |
| 134 int ViewsDelegate::GetDialogCloseButtonMargin() const { | 147 int ViewsDelegate::GetSpacingMetric(SpacingMetric metric) const { |
| 135 return kCloseButtonMargin; | 148 return GetDefaultSpacingMetric(metric); |
| 136 } | 149 } |
| 137 | 150 |
| 138 int ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() const { | 151 int ViewsDelegate::GetDefaultSpacingMetric(SpacingMetric metric) { |
| 139 return kRelatedButtonHSpacing; | 152 switch (metric) { |
| 140 } | 153 case SpacingMetric::CLOSE_BUTTON_MARGIN: |
| 141 | 154 return kCloseButtonMargin; |
| 142 int ViewsDelegate::GetDialogRelatedControlVerticalSpacing() const { | 155 case SpacingMetric::RELATED_HORIZONTAL_BUTTON: |
| 143 return kRelatedControlVerticalSpacing; | 156 return kRelatedButtonHSpacing; |
| 144 } | 157 case SpacingMetric::RELATED_VERTICAL_CONTROL: |
| 145 | 158 return kRelatedControlVerticalSpacing; |
| 146 gfx::Insets ViewsDelegate::GetDialogFrameViewInsets() const { | 159 case SpacingMetric::ICON_TO_TEXT: |
| 147 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, | 160 return kIconTextSpacing; |
| 148 kButtonHEdgeMarginNew); | 161 case SpacingMetric::DIALOG_BUTTON_MINIMUM_WIDTH: |
| 149 } | 162 return kDialogMinimumButtonWidth; |
| 150 | 163 case SpacingMetric::BUTTON_HORIZONTAL_PADDING: |
| 151 gfx::Insets ViewsDelegate::GetBubbleDialogMargins() const { | 164 return kButtonHorizontalPadding; |
| 152 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin); | 165 } |
| 153 } | 166 NOTREACHED(); |
| 154 | 167 return 0; |
| 155 int ViewsDelegate::GetButtonMinimumWidth() const { | |
| 156 return kMinimumButtonWidth; | |
| 157 } | |
| 158 | |
| 159 int ViewsDelegate::GetDialogButtonMinimumWidth() const { | |
| 160 return kDialogMinimumButtonWidth; | |
| 161 } | |
| 162 | |
| 163 int ViewsDelegate::GetButtonHorizontalPadding() const { | |
| 164 return kButtonHorizontalPadding; | |
| 165 } | 168 } |
| 166 | 169 |
| 167 ViewsDelegate::ViewsDelegate() | 170 ViewsDelegate::ViewsDelegate() |
| 168 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) { | 171 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) { |
| 169 DCHECK(!views_delegate); | 172 DCHECK(!views_delegate); |
| 170 views_delegate = this; | 173 views_delegate = this; |
| 171 | 174 |
| 172 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); | 175 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); |
| 173 | 176 |
| 174 #if defined(USE_AURA) | 177 #if defined(USE_AURA) |
| 175 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews()); | 178 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews()); |
| 176 #endif | 179 #endif |
| 177 } | 180 } |
| 178 | 181 |
| 179 } // namespace views | 182 } // namespace views |
| OLD | NEW |