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

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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Merged with latest changes. 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) 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
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 switch (metric) {
136 } 149 case SpacingMetric::CLOSE_BUTTON_MARGIN:
137 150 return kCloseButtonMargin;
138 int ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() const { 151 case SpacingMetric::ICON_TO_TEXT:
139 return kRelatedButtonHSpacing; 152 return kIconTextSpacing;
140 } 153 case SpacingMetric::RELATED_HORIZONTAL_BUTTON:
141 154 return kRelatedButtonHSpacing;
142 int ViewsDelegate::GetDialogRelatedControlVerticalSpacing() const { 155 case SpacingMetric::RELATED_VERTICAL_CONTROL:
143 return kRelatedControlVerticalSpacing; 156 return kRelatedControlVerticalSpacing;
144 } 157 case SpacingMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
145 158 return kDialogMinimumButtonWidth;
146 gfx::Insets ViewsDelegate::GetDialogFrameViewInsets() const { 159 case SpacingMetric::BUTTON_HORIZONTAL_PADDING:
147 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, 160 return kButtonHorizontalPadding;
148 kButtonHEdgeMarginNew); 161 }
149 } 162 NOTREACHED();
150 163 return 0;
151 gfx::Insets ViewsDelegate::GetBubbleDialogMargins() const {
152 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin);
153 }
154
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 } 164 }
166 165
167 ViewsDelegate::ViewsDelegate() 166 ViewsDelegate::ViewsDelegate()
168 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) { 167 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
169 DCHECK(!views_delegate); 168 DCHECK(!views_delegate);
170 views_delegate = this; 169 views_delegate = this;
171 170
172 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); 171 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get());
173 172
174 #if defined(USE_AURA) 173 #if defined(USE_AURA)
175 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews()); 174 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews());
176 #endif 175 #endif
177 } 176 }
178 177
179 } // namespace views 178 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698