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

Side by Side Diff: chrome/browser/ui/views/harmony/chrome_layout_provider.h

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 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 #ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_H_
6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "ui/gfx/geometry/insets.h"
12 #include "ui/views/layout/grid_layout.h"
13 #include "ui/views/layout/layout_provider.h"
14
15 enum ChromeDistanceMetric {
16 // Margin between the edge of a dialog and the left, right, or bottom of a
17 // contained button.
18 DISTANCE_DIALOG_BUTTON_MARGIN = views::VIEWS_DISTANCE_END,
Peter Kasting 2017/04/12 21:37:44 Nit: Alphabetize?
kylix_rd 2017/04/13 16:45:42 Done.
19 // Spacing between a dialog button and the content above it.
20 DISTANCE_DIALOG_BUTTON_TOP,
21 // Horizontal or vertical margin between the edge of a panel and the
22 // contained content.
23 DISTANCE_PANEL_CONTENT_MARGIN,
24 // The maximum width a button can have and still influence the sizes of
25 // other linked buttons. This allows short buttons to have linked widths
26 // without long buttons making things overly wide.
27 DISTANCE_BUTTON_MAX_LINKABLE_WIDTH,
28 // Default minimum width of a button.
29 DISTANCE_BUTTON_MINIMUM_WIDTH,
30 // Smaller horizontal spacing between other controls that are logically
31 // related.
32 DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL,
33 // Smaller vertical spacing between controls that are logically related.
34 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL,
35 // Horizontal spacing between an item such as an icon or checkbox and a
36 // label related to it.
37 DISTANCE_RELATED_LABEL_HORIZONTAL,
38 // Horizontal indent of a subsection relative to related items above, e.g.
39 // checkboxes below explanatory text/headings.
40 DISTANCE_SUBSECTION_HORIZONTAL_INDENT,
41 // Horizontal spacing between controls that are logically unrelated.
42 DISTANCE_UNRELATED_CONTROL_HORIZONTAL,
43 // Larger horizontal spacing between unrelated controls.
44 DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE,
45 // Vertical spacing between controls that are logically unrelated.
46 DISTANCE_UNRELATED_CONTROL_VERTICAL,
47 // Larger vertical spacing between unrelated controls.
48 DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE,
49 };
50
51 enum class DialogWidth {
52 SMALL,
53 MEDIUM,
54 LARGE,
55 };
56
57 class ChromeLayoutProvider : public views::LayoutProvider {
58 public:
59 ChromeLayoutProvider() {}
60 ~ChromeLayoutProvider() override {}
61
62 static ChromeLayoutProvider* Get();
63 static std::unique_ptr<views::LayoutProvider> CreateLayoutProvider();
64
65 int GetDistanceMetric(int metric) const override;
66
67 const views::TypographyProvider& GetTypographyProvider() const override;
68
69 // Returns the alignment used for control labels in a GridLayout; for example,
70 // in this GridLayout:
71 // ---------------------------
72 // | Label 1 Checkbox 1 |
73 // | Label 2 Checkbox 2 |
74 // ---------------------------
75 // This value controls the alignment used for "Label 1" and "Label 2".
76 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const;
77
78 // Returns whether to use extra padding on dialogs. If this is false, content
79 // Views for dialogs should not insert extra padding at their own edges.
80 virtual bool UseExtraDialogPadding() const;
81
82 // Returns whether to show the icon next to the title text on a dialog.
83 virtual bool ShouldShowWindowIcon() const;
84
85 // DEPRECATED. Returns whether Harmony mode is enabled.
86 //
87 // Instead of using this, create a generic solution that works for all UI
88 // types, e.g. by adding a new LayoutDistance value that means what you need.
Peter Kasting 2017/04/12 21:37:43 Nit: LayoutDistance value -> distance metric
89 //
90 // TODO(pkasting): Fix callers and remove this.
91 virtual bool IsHarmonyMode() const;
92
93 // Returns the preferred width in DIPs for a dialog of the specified |width|.
94 // May return 0 if the dialog has no preferred width.
95 virtual int GetDialogPreferredWidth(DialogWidth width) const;
96
97 private:
98 DISALLOW_COPY_AND_ASSIGN(ChromeLayoutProvider);
99 };
100
101 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698