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

Side by Side Diff: ui/views/layout/views_layout_delegate.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Deleted LayoutDelegate and HarmonyLayoutDelegate. 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/layout/views_layout_delegate.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/views/layout/layout_constants.h"
11 #include "ui/views/views_delegate.h"
12
13 namespace views {
14
15 namespace {
16
Peter Kasting 2017/04/04 02:08:55 Nit: Remove blank line
kylix_rd 2017/04/04 20:28:23 Done.
17 static ViewsLayoutDelegate* layout_delegate_ = nullptr;
Peter Kasting 2017/04/04 02:08:55 Nit: I'd name this |g_layout_delegate| since it's
kylix_rd 2017/04/04 20:28:23 Done.
18 }
19
20 ViewsLayoutDelegate::ViewsLayoutDelegate() {
21 layout_delegate_ = this;
22 }
23
24 ViewsLayoutDelegate::~ViewsLayoutDelegate() {
25 if (this == layout_delegate_)
26 layout_delegate_ = nullptr;
27 }
28
29 // static
30 ViewsLayoutDelegate* ViewsLayoutDelegate::Get() {
31 return layout_delegate_;
32 }
33
34 gfx::Insets ViewsLayoutDelegate::GetInsetsMetric(InsetsMetric metric) const {
35 switch (metric) {
36 case InsetsMetric::DIALOG_BUTTON:
37 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew,
38 kButtonHEdgeMarginNew);
39 case InsetsMetric::DIALOG_FRAME_VIEW:
40 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0,
41 kButtonHEdgeMarginNew);
42 case InsetsMetric::BUBBLE_DIALOG:
43 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin);
44 case InsetsMetric::VECTOR_IMAGE_BUTTON:
45 return gfx::Insets(kVectorButtonExtraTouchSize);
46 }
47 NOTREACHED();
48 return gfx::Insets();
49 }
50
51 int ViewsLayoutDelegate::GetDistanceMetric(DistanceMetric metric) const {
52 switch (metric) {
53 case DistanceMetric::CLOSE_BUTTON_MARGIN:
54 return kCloseButtonMargin;
55 case DistanceMetric::RELATED_BUTTON_HORIZONTAL:
56 return kRelatedButtonHSpacing;
57 case DistanceMetric::RELATED_CONTROL_HORIZONTAL:
58 return kRelatedControlHorizontalSpacing;
59 case DistanceMetric::RELATED_CONTROL_VERTICAL:
60 return kRelatedControlVerticalSpacing;
61 case DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
62 return kDialogMinimumButtonWidth;
63 case DistanceMetric::BUTTON_HORIZONTAL_PADDING:
64 return kButtonHorizontalPadding;
65 }
66 NOTREACHED();
67 return 0;
68 }
69
70 const TypographyProvider& ViewsLayoutDelegate::GetTypographyProvider() const {
71 return typography_provider_;
72 }
73
74 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698