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

Side by Side Diff: chrome/browser/ui/views/harmony/chrome_layout_provider.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 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/chrome_layout_provider.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/ui/views/harmony/chrome_typography.h"
10 #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
11 #include "ui/base/material_design/material_design_controller.h"
12 #include "ui/views/layout/layout_constants.h"
13
14 // static
15 ChromeLayoutProvider* ChromeLayoutProvider::Get() {
16 return static_cast<ChromeLayoutProvider*>(views::LayoutProvider::Get());
17 }
18
19 // static
20 std::unique_ptr<views::LayoutProvider>
21 ChromeLayoutProvider::CreateLayoutProvider() {
22 return ui::MaterialDesignController::IsSecondaryUiMaterial()
23 ? base::MakeUnique<HarmonyLayoutProvider>()
24 : base::MakeUnique<ChromeLayoutProvider>();
25 }
26
27 int ChromeLayoutProvider::GetDistanceMetric(int metric) const {
28 switch (metric) {
29 case DISTANCE_BUTTON_MAX_LINKABLE_WIDTH:
30 return 0;
31 case DISTANCE_BUTTON_MINIMUM_WIDTH:
32 return views::kMinimumButtonWidth;
33 case DISTANCE_DIALOG_BUTTON_MARGIN:
34 return views::kButtonHEdgeMarginNew;
35 case DISTANCE_DIALOG_BUTTON_TOP:
36 return 0;
37 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL:
38 return views::kRelatedControlSmallHorizontalSpacing;
39 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL:
40 return views::kRelatedControlSmallVerticalSpacing;
41 case DISTANCE_RELATED_LABEL_HORIZONTAL:
42 return views::kItemLabelSpacing;
43 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT:
44 return views::kCheckboxIndent;
45 case DISTANCE_PANEL_CONTENT_MARGIN:
46 return views::kPanelHorizMargin;
47 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL:
48 return views::kUnrelatedControlHorizontalSpacing;
49 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE:
50 return views::kUnrelatedControlLargeHorizontalSpacing;
51 case DISTANCE_UNRELATED_CONTROL_VERTICAL:
52 return views::kUnrelatedControlVerticalSpacing;
53 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE:
54 return views::kUnrelatedControlLargeVerticalSpacing;
55 default:
56 return views::LayoutProvider::GetDistanceMetric(metric);
57 }
58 }
59
60 const views::TypographyProvider& ChromeLayoutProvider::GetTypographyProvider()
61 const {
62 // This is not a data member because then HarmonyLayoutProvider would inherit
63 // it, even when it provides its own.
64 CR_DEFINE_STATIC_LOCAL(LegacyTypographyProvider, legacy_provider, ());
65 return legacy_provider;
66 }
67
68 views::GridLayout::Alignment
69 ChromeLayoutProvider::GetControlLabelGridAlignment() const {
70 return views::GridLayout::TRAILING;
71 }
72
73 bool ChromeLayoutProvider::UseExtraDialogPadding() const {
74 return true;
75 }
76
77 bool ChromeLayoutProvider::ShouldShowWindowIcon() const {
78 return true;
79 }
80
81 bool ChromeLayoutProvider::IsHarmonyMode() const {
82 return false;
83 }
84
85 int ChromeLayoutProvider::GetDialogPreferredWidth(DialogWidth width) const {
86 return 0;
87 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/harmony/chrome_layout_provider.h ('k') | chrome/browser/ui/views/harmony/harmony_layout_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698