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

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: Fix various unit-tests 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
17 static ViewsLayoutDelegate* layout_delegate_ = nullptr;
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 }
45 NOTREACHED();
46 return gfx::Insets();
47 }
48
49 int ViewsLayoutDelegate::GetDistanceMetric(DistanceMetric metric) const {
50 switch (metric) {
51 case DistanceMetric::CLOSE_BUTTON_MARGIN:
52 return kCloseButtonMargin;
53 case DistanceMetric::RELATED_BUTTON_HORIZONTAL:
54 return kRelatedButtonHSpacing;
55 case DistanceMetric::RELATED_CONTROL_HORIZONTAL:
56 return kRelatedControlHorizontalSpacing;
57 case DistanceMetric::RELATED_CONTROL_VERTICAL:
58 return kRelatedControlVerticalSpacing;
59 case DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
60 return kDialogMinimumButtonWidth;
61 case DistanceMetric::BUTTON_HORIZONTAL_PADDING:
62 return kButtonHorizontalPadding;
63 }
64 NOTREACHED();
65 return 0;
66 }
67
68 const TypographyProvider& ViewsLayoutDelegate::GetTypographyProvider() const {
69 return typography_provider_;
70 }
71
72 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698