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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 years, 8 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 } 22 }
23 23
24 ViewsDelegate::ViewsDelegate()
25 : editing_controller_factory_(new ViewsTouchEditingControllerFactory) {
26 DCHECK(!views_delegate);
27 views_delegate = this;
28
29 ui::TouchEditingControllerFactory::SetInstance(
30 editing_controller_factory_.get());
31
32 #if defined(USE_AURA)
33 touch_selection_menu_runner_ =
34 base::MakeUnique<TouchSelectionMenuRunnerViews>();
35 #endif
36 }
37
24 ViewsDelegate::~ViewsDelegate() { 38 ViewsDelegate::~ViewsDelegate() {
25 ui::TouchEditingControllerFactory::SetInstance(nullptr); 39 ui::TouchEditingControllerFactory::SetInstance(nullptr);
26 40
27 DCHECK_EQ(this, views_delegate); 41 DCHECK_EQ(this, views_delegate);
28 views_delegate = nullptr; 42 views_delegate = nullptr;
29 } 43 }
30 44
31 ViewsDelegate* ViewsDelegate::GetInstance() { 45 ViewsDelegate* ViewsDelegate::GetInstance() {
32 return views_delegate; 46 return views_delegate;
33 } 47 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor, 133 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
120 const base::Closure& callback) { 134 const base::Closure& callback) {
121 return EDGE_BOTTOM; 135 return EDGE_BOTTOM;
122 } 136 }
123 #endif 137 #endif
124 138
125 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() { 139 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() {
126 return nullptr; 140 return nullptr;
127 } 141 }
128 142
129 gfx::Insets ViewsDelegate::GetInsetsMetric(InsetsMetric metric) const {
130 switch (metric) {
131 case InsetsMetric::BUBBLE_CONTENTS:
132 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin);
133 case InsetsMetric::DIALOG_BUTTON:
134 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew,
135 kButtonHEdgeMarginNew);
136 case InsetsMetric::DIALOG_TITLE:
137 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0,
138 kButtonHEdgeMarginNew);
139 case InsetsMetric::PANEL:
140 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew);
141 case InsetsMetric::VECTOR_IMAGE_BUTTON_PADDING:
142 return gfx::Insets(kVectorButtonExtraTouchSize);
143 }
144 NOTREACHED();
145 return gfx::Insets();
146 }
147
148 int ViewsDelegate::GetDistanceMetric(DistanceMetric metric) const {
149 switch (metric) {
150 case DistanceMetric::CLOSE_BUTTON_MARGIN:
151 return kCloseButtonMargin;
152 case DistanceMetric::RELATED_BUTTON_HORIZONTAL:
153 return kRelatedButtonHSpacing;
154 case DistanceMetric::RELATED_CONTROL_HORIZONTAL:
155 return kRelatedControlHorizontalSpacing;
156 case DistanceMetric::RELATED_CONTROL_VERTICAL:
157 return kRelatedControlVerticalSpacing;
158 case DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
159 return kDialogMinimumButtonWidth;
160 case DistanceMetric::BUTTON_HORIZONTAL_PADDING:
161 return kButtonHorizontalPadding;
162 }
163 NOTREACHED();
164 return 0;
165 }
166
167 ViewsDelegate::ViewsDelegate()
168 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
169 DCHECK(!views_delegate);
170 views_delegate = this;
171
172 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get());
173
174 #if defined(USE_AURA)
175 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews());
176 #endif
177 }
178
179 } // namespace views 143 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/views_delegate.h ('k') | ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698