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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: LayoutDelegate -> LayoutProvider 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 "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
6
7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const {
8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX);
9 switch (metric) {
10 case views::INSETS_DIALOG_BUTTON:
11 case views::INSETS_PANEL:
12 case views::INSETS_BUBBLE_CONTENTS:
13 return gfx::Insets(kHarmonyLayoutUnit);
14 case views::INSETS_DIALOG_TITLE: {
15 constexpr int top = kHarmonyLayoutUnit;
16 constexpr int side = kHarmonyLayoutUnit;
17 // Titles are inset at the top and sides, but not at the bottom.
18 return gfx::Insets(top, side, 0, side);
19 }
20 case views::INSETS_VECTOR_IMAGE_BUTTON:
21 return gfx::Insets(kHarmonyLayoutUnit / 4);
22 }
23 NOTREACHED();
24 return gfx::Insets();
25 }
26
27 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const {
28 DCHECK_GE(metric, views::VIEWS_INSETS_MAX);
29 switch (metric) {
30 case views::DISTANCE_CLOSE_BUTTON_MARGIN: {
31 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2;
32 // The visible margin is based on the unpadded size, so to get the actual
33 // margin we need to subtract out the padding.
34 return kVisibleMargin - kHarmonyLayoutUnit / 4;
35 }
36 case views::DISTANCE_RELATED_BUTTON_HORIZONTAL:
37 return kHarmonyLayoutUnit / 2;
38 case views::DISTANCE_RELATED_CONTROL_HORIZONTAL:
39 return kHarmonyLayoutUnit;
40 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL:
41 return kHarmonyLayoutUnit;
42 case views::DISTANCE_RELATED_CONTROL_VERTICAL:
43 return kHarmonyLayoutUnit / 2;
44 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL:
45 return kHarmonyLayoutUnit / 2;
46 case DISTANCE_DIALOG_BUTTON_MARGIN:
47 return kHarmonyLayoutUnit;
48 case DISTANCE_DIALOG_BUTTON_TOP:
49 return kHarmonyLayoutUnit;
50 case views::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH:
51 case DISTANCE_BUTTON_MINIMUM_WIDTH:
52 // Minimum label size plus padding.
53 return 2 * kHarmonyLayoutUnit +
54 2 * GetDistanceMetric(views::DISTANCE_BUTTON_HORIZONTAL_PADDING);
55 case views::DISTANCE_BUTTON_HORIZONTAL_PADDING:
56 return kHarmonyLayoutUnit;
57 case DISTANCE_BUTTON_MAX_LINKABLE_WIDTH:
58 return kHarmonyLayoutUnit * 8;
59 case DISTANCE_RELATED_LABEL_HORIZONTAL:
60 return kHarmonyLayoutUnit;
61 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT:
62 return 0;
63 case DISTANCE_PANEL_CONTENT_MARGIN:
64 return kHarmonyLayoutUnit;
65 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL:
66 return kHarmonyLayoutUnit;
67 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE:
68 return kHarmonyLayoutUnit;
69 case DISTANCE_UNRELATED_CONTROL_VERTICAL:
70 return kHarmonyLayoutUnit;
71 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE:
72 return kHarmonyLayoutUnit;
73 }
74 NOTREACHED();
75 return 0;
76 }
77 views::GridLayout::Alignment
Peter Kasting 2017/04/12 21:37:44 Nit: Blank line above
kylix_rd 2017/04/13 16:45:42 Done.
78 HarmonyLayoutProvider::GetControlLabelGridAlignment() const {
79 return views::GridLayout::LEADING;
80 }
81
82 bool HarmonyLayoutProvider::UseExtraDialogPadding() const {
83 return false;
84 }
85
86 bool HarmonyLayoutProvider::ShouldShowWindowIcon() const {
87 return false;
88 }
89
90 bool HarmonyLayoutProvider::IsHarmonyMode() const {
91 return true;
92 }
93
94 int HarmonyLayoutProvider::GetDialogPreferredWidth(DialogWidth width) const {
95 switch (width) {
96 case DialogWidth::SMALL:
97 return 320;
98 case DialogWidth::MEDIUM:
99 return 448;
100 case DialogWidth::LARGE:
101 return 512;
102 }
103 NOTREACHED();
104 return 0;
105 }
106
107 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider()
108 const {
109 return typography_provider_;
110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698