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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed 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 2016 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_delegate.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/logging.h"
9
10 static base::LazyInstance<HarmonyLayoutDelegate>::DestructorAtExit
11 harmony_layout_delegate_ = LAZY_INSTANCE_INITIALIZER;
12
13 // static
14 HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() {
15 return harmony_layout_delegate_.Pointer();
16 }
17
18 int HarmonyLayoutDelegate::GetMetric(Metric metric) const {
19 switch (metric) {
20 case Metric::BUTTON_HORIZONTAL_PADDING:
21 return kHarmonyLayoutUnit;
22 case Metric::DIALOG_BUTTON_MARGIN:
23 return kHarmonyLayoutUnit;
24 case Metric::BUTTON_MAX_LINKABLE_WIDTH:
25 return kHarmonyLayoutUnit * 8;
26 case Metric::BUTTON_MINIMUM_WIDTH:
27 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH:
28 // Minimum label size plus padding.
29 return 2 * kHarmonyLayoutUnit +
30 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING);
31 case Metric::DIALOG_BUTTON_TOP_SPACING:
32 return kHarmonyLayoutUnit;
33 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: {
34 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2;
35 // The visible margin is based on the unpadded size, so to get the actual
36 // margin we need to subtract out the padding.
37 return kVisibleMargin - GetMetric(Metric::VECTOR_IMAGE_BUTTON_PADDING);
38 }
39 case Metric::PANEL_CONTENT_MARGIN:
40 return kHarmonyLayoutUnit;
41 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING:
42 return kHarmonyLayoutUnit / 2;
43 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING:
44 return kHarmonyLayoutUnit;
45 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING_SMALL:
46 return kHarmonyLayoutUnit;
47 case Metric::RELATED_CONTROL_VERTICAL_SPACING:
48 return kHarmonyLayoutUnit / 2;
49 case Metric::RELATED_CONTROL_VERTICAL_SPACING_SMALL:
50 return kHarmonyLayoutUnit / 2;
51 case Metric::RELATED_LABEL_HORIZONTAL_SPACING:
52 return kHarmonyLayoutUnit;
53 case Metric::SUBSECTION_HORIZONTAL_INDENT:
54 return 0;
55 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING:
56 return kHarmonyLayoutUnit;
57 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE:
58 return kHarmonyLayoutUnit;
59 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING:
60 return kHarmonyLayoutUnit;
61 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING_LARGE:
62 return kHarmonyLayoutUnit;
63 case Metric::VECTOR_IMAGE_BUTTON_PADDING:
64 return 4;
65 }
66 NOTREACHED();
67 return 0;
68 }
69
70 views::GridLayout::Alignment
71 HarmonyLayoutDelegate::GetControlLabelGridAlignment() const {
72 return views::GridLayout::LEADING;
73 }
74
75 bool HarmonyLayoutDelegate::UseExtraDialogPadding() const {
76 return false;
77 }
78
79 bool HarmonyLayoutDelegate::ShouldShowWindowIcon() const {
80 return false;
81 }
82
83 bool HarmonyLayoutDelegate::IsHarmonyMode() const {
84 return true;
85 }
86
87 int HarmonyLayoutDelegate::GetDialogPreferredWidth(DialogWidth width) const {
88 switch (width) {
89 case DialogWidth::SMALL:
90 return 320;
91 case DialogWidth::MEDIUM:
92 return 448;
93 case DialogWidth::LARGE:
94 return 512;
95 }
96 NOTREACHED();
97 return 0;
98 }
99
100 const views::TypographyProvider& HarmonyLayoutDelegate::GetTypographyProvider()
101 const {
102 return typography_provider_;
103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/harmony/harmony_layout_delegate.h ('k') | chrome/browser/ui/views/harmony/harmony_layout_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698