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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Deleted LayoutDelegate and HarmonyLayoutDelegate. 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_views_layout_delegate.h"
6
7 gfx::Insets HarmonyViewsLayoutDelegate::GetInsetsMetric(
8 ChromeInsetsMetric metric) const {
9 switch (metric) {
10 case ChromeInsetsMetric::DIALOG_BUTTON:
11 case ChromeInsetsMetric::PANEL_LAYOUT:
12 case ChromeInsetsMetric::BUBBLE_DIALOG:
13 return gfx::Insets(kHarmonyLayoutUnit);
14 case ChromeInsetsMetric::DIALOG_FRAME_VIEW: {
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 ChromeInsetsMetric::VECTOR_IMAGE_BUTTON:
21 return gfx::Insets(kHarmonyLayoutUnit / 4);
22 }
23 NOTREACHED();
24 return gfx::Insets();
25 }
26
27 int HarmonyViewsLayoutDelegate::GetDistanceMetric(
28 ChromeDistanceMetric metric) const {
29 switch (metric) {
30 case ChromeDistanceMetric::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;
Peter Kasting 2017/04/04 02:08:54 Nit: Should probably refer to the VECTOR_IMAGE_BUT
35 }
36 case ChromeDistanceMetric::RELATED_BUTTON_HORIZONTAL:
Peter Kasting 2017/04/04 02:08:54 Nit: Might make sense to collapse together cases t
kylix_rd 2017/04/04 20:28:23 I thought doing about that. I was just concerned t
Peter Kasting 2017/04/05 19:30:10 Not 100% confident, but I think at most one or two
37 return kHarmonyLayoutUnit / 2;
38 case ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL:
39 return kHarmonyLayoutUnit;
40 case ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL_SMALL:
41 return kHarmonyLayoutUnit;
42 case ChromeDistanceMetric::RELATED_CONTROL_VERTICAL:
43 return kHarmonyLayoutUnit / 2;
44 case ChromeDistanceMetric::RELATED_CONTROL_VERTICAL_SMALL:
45 return kHarmonyLayoutUnit / 2;
46 case ChromeDistanceMetric::DIALOG_BUTTON_MARGIN:
47 return kHarmonyLayoutUnit;
48 case ChromeDistanceMetric::DIALOG_BUTTON_TOP:
49 return kHarmonyLayoutUnit;
50 case ChromeDistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
51 case ChromeDistanceMetric::BUTTON_MINIMUM_WIDTH:
52 // Minimum label size plus padding.
53 return 2 * kHarmonyLayoutUnit +
54 2 * GetDistanceMetric(
55 ChromeDistanceMetric::BUTTON_HORIZONTAL_PADDING);
56 case ChromeDistanceMetric::BUTTON_HORIZONTAL_PADDING:
57 return kHarmonyLayoutUnit;
58 case ChromeDistanceMetric::BUTTON_MAX_LINKABLE_WIDTH:
59 return kHarmonyLayoutUnit * 8;
60 case ChromeDistanceMetric::RELATED_LABEL_HORIZONTAL:
61 return kHarmonyLayoutUnit;
62 case ChromeDistanceMetric::SUBSECTION_HORIZONTAL_INDENT:
63 return 0;
64 case ChromeDistanceMetric::PANEL_CONTENT_MARGIN:
65 return kHarmonyLayoutUnit;
66 case ChromeDistanceMetric::UNRELATED_CONTROL_HORIZONTAL:
67 return kHarmonyLayoutUnit;
68 case ChromeDistanceMetric::UNRELATED_CONTROL_HORIZONTAL_LARGE:
69 return kHarmonyLayoutUnit;
70 case ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL:
71 return kHarmonyLayoutUnit;
72 case ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL_LARGE:
73 return kHarmonyLayoutUnit;
74 }
75 NOTREACHED();
76 return 0;
77 }
78 views::GridLayout::Alignment
79 HarmonyViewsLayoutDelegate::GetControlLabelGridAlignment() const {
80 return views::GridLayout::LEADING;
81 }
82
83 bool HarmonyViewsLayoutDelegate::UseExtraDialogPadding() const {
84 return false;
85 }
86
87 bool HarmonyViewsLayoutDelegate::ShouldShowWindowIcon() const {
88 return false;
89 }
90
91 bool HarmonyViewsLayoutDelegate::IsHarmonyMode() const {
92 return true;
93 }
94
95 int HarmonyViewsLayoutDelegate::GetDialogPreferredWidth(
96 DialogWidth width) const {
97 switch (width) {
98 case DialogWidth::SMALL:
99 return 320;
100 case DialogWidth::MEDIUM:
101 return 448;
102 case DialogWidth::LARGE:
103 return 512;
104 }
105 NOTREACHED();
106 return 0;
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698