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

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

Issue 2888563004: Delete panel metrics and define insets in terms of distance metrics. (Closed)
Patch Set: one wrong conversion Created 3 years, 7 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_provider.h ('k') | ui/views/window/dialog_client_view.cc » ('j') | 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" 10 #include "ui/views/layout/layout_constants.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // static 28 // static
29 LayoutProvider* LayoutProvider::Get() { 29 LayoutProvider* LayoutProvider::Get() {
30 return g_layout_delegate; 30 return g_layout_delegate;
31 } 31 }
32 32
33 gfx::Insets LayoutProvider::GetInsetsMetric(int metric) const { 33 gfx::Insets LayoutProvider::GetInsetsMetric(int metric) const {
34 DCHECK_LT(metric, VIEWS_INSETS_MAX); 34 DCHECK_LT(metric, VIEWS_INSETS_MAX);
35 switch (metric) { 35 switch (metric) {
36 case InsetsMetric::INSETS_BUBBLE_CONTENTS: 36 case InsetsMetric::INSETS_BUBBLE_CONTENTS:
37 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin); 37 return gfx::Insets(
38 case InsetsMetric::INSETS_BUBBLE_TITLE: 38 GetDistanceMetric(DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN),
39 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin, 0, 39 GetDistanceMetric(DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN));
40 kPanelHorizMargin); 40 case InsetsMetric::INSETS_BUBBLE_TITLE: {
41 case InsetsMetric::INSETS_DIALOG_BUTTON: 41 const gfx::Insets bubble_contents =
42 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, 42 GetInsetsMetric(INSETS_BUBBLE_CONTENTS);
43 kButtonHEdgeMarginNew); 43 return gfx::Insets(bubble_contents.top(), bubble_contents.left(), 0,
44 case InsetsMetric::INSETS_DIALOG_TITLE: 44 bubble_contents.right());
45 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, 45 }
46 kButtonHEdgeMarginNew); 46 case InsetsMetric::INSETS_DIALOG_BUTTON_ROW: {
47 case InsetsMetric::INSETS_PANEL: 47 const gfx::Insets dialog_contents =
48 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew); 48 GetInsetsMetric(INSETS_DIALOG_CONTENTS);
49 return gfx::Insets(
50 0, dialog_contents.left(),
51 GetDistanceMetric(DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN),
52 dialog_contents.right());
53 }
54 case InsetsMetric::INSETS_DIALOG_CONTENTS:
55 return gfx::Insets(
56 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN),
57 GetDistanceMetric(DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN));
58 case InsetsMetric::INSETS_DIALOG_TITLE: {
59 const gfx::Insets dialog_contents =
60 GetInsetsMetric(INSETS_DIALOG_CONTENTS);
61 return gfx::Insets(dialog_contents.top(), dialog_contents.left(), 0,
62 dialog_contents.right());
63 }
49 case InsetsMetric::INSETS_VECTOR_IMAGE_BUTTON: 64 case InsetsMetric::INSETS_VECTOR_IMAGE_BUTTON:
50 return gfx::Insets(kVectorButtonExtraTouchSize); 65 return gfx::Insets(kVectorButtonExtraTouchSize);
51 } 66 }
52 NOTREACHED(); 67 NOTREACHED();
53 return gfx::Insets(); 68 return gfx::Insets();
54 } 69 }
55 70
56 int LayoutProvider::GetDistanceMetric(int metric) const { 71 int LayoutProvider::GetDistanceMetric(int metric) const {
57 DCHECK_GE(metric, VIEWS_INSETS_MAX); 72 DCHECK_GE(metric, VIEWS_INSETS_MAX);
58 switch (metric) { 73 switch (metric) {
74 case DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN:
75 return kPanelHorizMargin;
76 case DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN:
77 case DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN:
78 return kPanelVertMargin;
59 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING: 79 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING:
60 return kButtonHorizontalPadding; 80 return kButtonHorizontalPadding;
61 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: 81 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH:
62 return 0; 82 return 0;
63 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN: 83 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN:
64 return kCloseButtonMargin; 84 return kCloseButtonMargin;
65 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL: 85 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL:
66 return kRelatedButtonHSpacing; 86 return kRelatedButtonHSpacing;
67 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL: 87 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL:
68 return kRelatedControlHorizontalSpacing; 88 return kRelatedControlHorizontalSpacing;
69 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL: 89 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL:
70 return kRelatedControlVerticalSpacing; 90 return kRelatedControlVerticalSpacing;
91 case DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN:
92 return views::kButtonVEdgeMarginNew;
71 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: 93 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH:
72 return kDialogMinimumButtonWidth; 94 return kDialogMinimumButtonWidth;
95 case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN:
96 return kButtonHEdgeMarginNew;
73 } 97 }
74 NOTREACHED(); 98 NOTREACHED();
75 return 0; 99 return 0;
76 } 100 }
77 101
78 const TypographyProvider& LayoutProvider::GetTypographyProvider() const { 102 const TypographyProvider& LayoutProvider::GetTypographyProvider() const {
79 return typography_provider_; 103 return typography_provider_;
80 } 104 }
81 105
82 int LayoutProvider::GetSnappedDialogWidth(int min_width) const { 106 int LayoutProvider::GetSnappedDialogWidth(int min_width) const {
83 return min_width; 107 return min_width;
84 } 108 }
85 109
86 } // namespace views 110 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/layout/layout_provider.h ('k') | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698