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

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

Issue 2942453002: Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Rebase to tip Created 3 years, 6 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
« no previous file with comments | « ui/views/layout/layout_constants.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/layout/layout_provider.h" 5 #include "ui/views/layout/layout_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/base/material_design/material_design_controller.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" 10 #include "ui/views/views_delegate.h"
12 11
13 namespace views { 12 namespace views {
14 13
15 namespace { 14 namespace {
15
16 LayoutProvider* g_layout_delegate = nullptr; 16 LayoutProvider* g_layout_delegate = nullptr;
17 } 17
18 } // namespace
18 19
19 LayoutProvider::LayoutProvider() { 20 LayoutProvider::LayoutProvider() {
20 g_layout_delegate = this; 21 g_layout_delegate = this;
21 } 22 }
22 23
23 LayoutProvider::~LayoutProvider() { 24 LayoutProvider::~LayoutProvider() {
24 if (this == g_layout_delegate) 25 if (this == g_layout_delegate)
25 g_layout_delegate = nullptr; 26 g_layout_delegate = nullptr;
26 } 27 }
27 28
(...skipping 27 matching lines...) Expand all
55 return gfx::Insets( 56 return gfx::Insets(
56 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN), 57 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN),
57 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN)); 58 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN));
58 case InsetsMetric::INSETS_DIALOG_TITLE: { 59 case InsetsMetric::INSETS_DIALOG_TITLE: {
59 const gfx::Insets dialog_contents = 60 const gfx::Insets dialog_contents =
60 GetInsetsMetric(INSETS_DIALOG_CONTENTS); 61 GetInsetsMetric(INSETS_DIALOG_CONTENTS);
61 return gfx::Insets(dialog_contents.top(), dialog_contents.left(), 0, 62 return gfx::Insets(dialog_contents.top(), dialog_contents.left(), 0,
62 dialog_contents.right()); 63 dialog_contents.right());
63 } 64 }
64 case InsetsMetric::INSETS_VECTOR_IMAGE_BUTTON: 65 case InsetsMetric::INSETS_VECTOR_IMAGE_BUTTON:
65 return gfx::Insets(kVectorButtonExtraTouchSize); 66 return gfx::Insets(4);
66 } 67 }
67 NOTREACHED(); 68 NOTREACHED();
68 return gfx::Insets(); 69 return gfx::Insets();
69 } 70 }
70 71
71 int LayoutProvider::GetDistanceMetric(int metric) const { 72 int LayoutProvider::GetDistanceMetric(int metric) const {
72 DCHECK_GE(metric, VIEWS_INSETS_MAX); 73 DCHECK_GE(metric, VIEWS_INSETS_MAX);
73 switch (metric) { 74 switch (metric) {
74 case DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN: 75 case DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN:
75 return kPanelHorizMargin; 76 return 13;
76 case DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN: 77 case DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN:
77 case DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN: 78 case DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN:
78 return kPanelVertMargin; 79 return 13;
79 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING: 80 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING:
80 return kButtonHorizontalPadding; 81 return 16;
81 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: 82 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH:
82 return 0; 83 return 0;
83 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN: 84 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN:
84 return kCloseButtonMargin; 85 return 7;
85 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL: 86 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL:
86 return kRelatedButtonHSpacing; 87 return 6;
87 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL: 88 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL:
88 return kRelatedControlHorizontalSpacing; 89 return 8;
89 case DistanceMetric::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN: 90 case DistanceMetric::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN:
90 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL: 91 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL:
91 return kRelatedControlVerticalSpacing; 92 return 8;
92 case DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN: 93 case DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN:
93 return views::kButtonVEdgeMarginNew; 94 return 20;
94 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: 95 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH:
95 return kDialogMinimumButtonWidth; 96 return 75;
96 case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN: 97 case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN:
97 return kButtonHEdgeMarginNew; 98 return 20;
98 case DISTANCE_UNRELATED_CONTROL_VERTICAL: 99 case DISTANCE_UNRELATED_CONTROL_VERTICAL:
99 return kUnrelatedControlVerticalSpacing; 100 return 20;
100 } 101 }
101 NOTREACHED(); 102 NOTREACHED();
102 return 0; 103 return 0;
103 } 104 }
104 105
105 const TypographyProvider& LayoutProvider::GetTypographyProvider() const { 106 const TypographyProvider& LayoutProvider::GetTypographyProvider() const {
106 return typography_provider_; 107 return typography_provider_;
107 } 108 }
108 109
109 int LayoutProvider::GetSnappedDialogWidth(int min_width) const { 110 int LayoutProvider::GetSnappedDialogWidth(int min_width) const {
110 // This is an arbitrary value, but it's a good arbitrary value. Some dialogs 111 // This is an arbitrary value, but it's a good arbitrary value. Some dialogs
111 // have very small widths for their contents views, which causes ugly 112 // have very small widths for their contents views, which causes ugly
112 // title-wrapping where a two-word title is split across multiple lines or 113 // title-wrapping where a two-word title is split across multiple lines or
113 // similar. To prevent that, forbid any snappable dialog from being narrower 114 // similar. To prevent that, forbid any snappable dialog from being narrower
114 // than this value. In principle it's possible to factor in the title width 115 // than this value. In principle it's possible to factor in the title width
115 // here, but it is not really worth the complexity. 116 // here, but it is not really worth the complexity.
116 return std::max(min_width, 320); 117 return std::max(min_width, 320);
117 } 118 }
118 119
119 } // namespace views 120 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/layout/layout_constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698