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

Side by Side Diff: chrome/browser/ui/views/harmony/harmony_layout_provider.cc

Issue 2932523003: Fix Harmony popover buttons being flush with their content. (Closed)
Patch Set: fix merge 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
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 "chrome/browser/ui/views/harmony/harmony_layout_provider.h" 5 #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
6 6
7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const { 7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const {
8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX); 8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX);
9 switch (metric) { 9 switch (metric) {
10 case views::INSETS_VECTOR_IMAGE_BUTTON: 10 case views::INSETS_VECTOR_IMAGE_BUTTON:
11 return gfx::Insets(kHarmonyLayoutUnit / 4); 11 return gfx::Insets(kHarmonyLayoutUnit / 4);
12 default: 12 default:
13 return ChromeLayoutProvider::GetInsetsMetric(metric); 13 return ChromeLayoutProvider::GetInsetsMetric(metric);
14 } 14 }
15 } 15 }
16 16
17 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { 17 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const {
18 DCHECK_GE(metric, views::VIEWS_INSETS_MAX); 18 DCHECK_GE(metric, views::VIEWS_INSETS_MAX);
19 switch (metric) { 19 switch (metric) {
20 case views::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN:
20 case views::DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN: 21 case views::DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN:
21 case views::DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN: 22 case views::DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN:
22 case views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN: 23 case views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN:
23 case views::DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN: 24 case views::DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN:
24 return kHarmonyLayoutUnit; 25 return kHarmonyLayoutUnit;
25 case DISTANCE_CONTROL_LIST_VERTICAL: 26 case DISTANCE_CONTROL_LIST_VERTICAL:
26 return kHarmonyLayoutUnit * 3 / 4; 27 return kHarmonyLayoutUnit * 3 / 4;
27 case views::DISTANCE_CLOSE_BUTTON_MARGIN: { 28 case views::DISTANCE_CLOSE_BUTTON_MARGIN: {
28 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2; 29 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2;
29 // The visible margin is based on the unpadded size, so to get the actual 30 // The visible margin is based on the unpadded size, so to get the actual
30 // margin we need to subtract out the padding. 31 // margin we need to subtract out the padding.
31 return kVisibleMargin - kHarmonyLayoutUnit / 4; 32 return kVisibleMargin - kHarmonyLayoutUnit / 4;
32 } 33 }
33 case views::DISTANCE_RELATED_BUTTON_HORIZONTAL: 34 case views::DISTANCE_RELATED_BUTTON_HORIZONTAL:
34 return kHarmonyLayoutUnit / 2; 35 return kHarmonyLayoutUnit / 2;
35 case views::DISTANCE_RELATED_CONTROL_HORIZONTAL: 36 case views::DISTANCE_RELATED_CONTROL_HORIZONTAL:
36 return kHarmonyLayoutUnit; 37 return kHarmonyLayoutUnit;
37 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL: 38 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL:
38 return kHarmonyLayoutUnit; 39 return kHarmonyLayoutUnit;
39 case views::DISTANCE_RELATED_CONTROL_VERTICAL: 40 case views::DISTANCE_RELATED_CONTROL_VERTICAL:
40 return kHarmonyLayoutUnit / 2; 41 return kHarmonyLayoutUnit / 2;
41 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL: 42 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL:
42 return kHarmonyLayoutUnit / 2; 43 return kHarmonyLayoutUnit / 2;
43 case views::DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN: 44 case views::DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN:
44 return kHarmonyLayoutUnit; 45 return kHarmonyLayoutUnit;
45 case DISTANCE_DIALOG_BUTTON_TOP:
46 return kHarmonyLayoutUnit;
47 case views::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: 46 case views::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH:
48 case DISTANCE_BUTTON_MINIMUM_WIDTH: 47 case DISTANCE_BUTTON_MINIMUM_WIDTH:
49 // Minimum label size plus padding. 48 // Minimum label size plus padding.
50 return 2 * kHarmonyLayoutUnit + 49 return 2 * kHarmonyLayoutUnit +
51 2 * GetDistanceMetric(views::DISTANCE_BUTTON_HORIZONTAL_PADDING); 50 2 * GetDistanceMetric(views::DISTANCE_BUTTON_HORIZONTAL_PADDING);
52 case views::DISTANCE_BUTTON_HORIZONTAL_PADDING: 51 case views::DISTANCE_BUTTON_HORIZONTAL_PADDING:
53 return kHarmonyLayoutUnit; 52 return kHarmonyLayoutUnit;
54 case views::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: 53 case views::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH:
55 return kHarmonyLayoutUnit * 7; 54 return kHarmonyLayoutUnit * 7;
56 case DISTANCE_RELATED_LABEL_HORIZONTAL: 55 case DISTANCE_RELATED_LABEL_HORIZONTAL:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 93 }
95 94
96 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * 95 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) *
97 kHarmonyLayoutUnit; 96 kHarmonyLayoutUnit;
98 } 97 }
99 98
100 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() 99 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider()
101 const { 100 const {
102 return typography_provider_; 101 return typography_provider_;
103 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/harmony/chrome_layout_provider.cc ('k') | ui/views/bubble/bubble_dialog_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698