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

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

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 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_VIEWS_LAYOUT_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_VIEWS_LAYOUT_DELEGATE_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/views_layout_delegate.h"
14
15 enum class ChromeInsetsMetric {
Peter Kasting 2017/04/04 02:08:54 Looks like you stuck with the enum class route. D
kylix_rd 2017/04/04 20:28:23 Either way. I prefer to use an enum class since it
Peter Kasting 2017/04/05 19:30:10 Let's do it as a separate thread for clarity. Why
16 // The margins that should be applied around a bubble dialog.
Peter Kasting 2017/04/04 02:08:53 Nit: Even if we stick with the enum route, don't c
kylix_rd 2017/04/04 20:28:23 Done.
17 BUBBLE_DIALOG = views::InsetsMetric::BUBBLE_DIALOG,
18 // The insets that should be applied around a DialogClientView. Note that
19 // the top inset is used for the distance between the buttons and the
20 // DialogClientView's content view.
21 DIALOG_BUTTON = views::InsetsMetric::DIALOG_BUTTON,
22 // The insets that should be applied around a dialog's frame view.
23 DIALOG_FRAME_VIEW = views::InsetsMetric::DIALOG_FRAME_VIEW,
24 // Padding to add to vector image buttons to increase their click and touch
25 // target size.
26 VECTOR_IMAGE_BUTTON = views::InsetsMetric::VECTOR_IMAGE_BUTTON,
27 // The insets applied around a content panel
Peter Kasting 2017/04/04 02:08:54 Nit: Trailing period.
kylix_rd 2017/04/04 20:28:23 Done.
28 PANEL_LAYOUT,
29 };
30
31 enum class ChromeDistanceMetric {
32 // The default padding to add on each side of a button's label.
33 BUTTON_HORIZONTAL_PADDING = views::DistanceMetric::BUTTON_HORIZONTAL_PADDING,
34 // The distance between a dialog's edge and the close button in the upper
35 // trailing corner.
36 CLOSE_BUTTON_MARGIN = views::DistanceMetric::CLOSE_BUTTON_MARGIN,
37 // The default minimum width of a dialog button.
38 DIALOG_BUTTON_MINIMUM_WIDTH =
39 views::DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH,
40 // The spacing between a pair of related horizontal buttons, used for
41 // dialog layout.
42 RELATED_BUTTON_HORIZONTAL = views::DistanceMetric::RELATED_BUTTON_HORIZONTAL,
43 // Horizontal spacing between controls that are logically related.
44 RELATED_CONTROL_HORIZONTAL =
45 views::DistanceMetric::RELATED_CONTROL_HORIZONTAL,
46 // The spacing between a pair of related vertical controls, used for
47 // dialog layout.
48 RELATED_CONTROL_VERTICAL = views::DistanceMetric::RELATED_CONTROL_VERTICAL,
49 // Margin between the edge of a dialog and the left, right, or bottom of a
50 // contained button.
51 DIALOG_BUTTON_MARGIN,
52 // Spacing between a dialog button and the content above it.
53 DIALOG_BUTTON_TOP,
54 // Horizontal or vertical margin between the edge of a panel and the
55 // contained content.
56 PANEL_CONTENT_MARGIN,
57 // The maximum width a button can have and still influence the sizes of
58 // other linked buttons. This allows short buttons to have linked widths
59 // without long buttons making things overly wide.
60 BUTTON_MAX_LINKABLE_WIDTH,
61 // Default minimum width of a button.
62 BUTTON_MINIMUM_WIDTH,
63 // Smaller horizontal spacing between other controls that are logically
64 // related.
65 RELATED_CONTROL_HORIZONTAL_SMALL,
66 // Smaller vertical spacing between controls that are logically related.
67 RELATED_CONTROL_VERTICAL_SMALL,
68 // Horizontal spacing between an item such as an icon or checkbox and a
69 // label related to it.
70 RELATED_LABEL_HORIZONTAL,
71 // Horizontal indent of a subsection relative to related items above, e.g.
72 // checkboxes below explanatory text/headings.
73 SUBSECTION_HORIZONTAL_INDENT,
74 // Horizontal spacing between controls that are logically unrelated.
75 UNRELATED_CONTROL_HORIZONTAL,
76 // Larger horizontal spacing between unrelated controls.
77 UNRELATED_CONTROL_HORIZONTAL_LARGE,
78 // Vertical spacing between controls that are logically unrelated.
79 UNRELATED_CONTROL_VERTICAL,
80 // Larger vertical spacing between unrelated controls.
81 UNRELATED_CONTROL_VERTICAL_LARGE,
82 };
83
84 enum class DialogWidth {
85 SMALL,
86 MEDIUM,
87 LARGE,
88 };
89
90 class ChromeViewsLayoutDelegate : public views::ViewsLayoutDelegate {
91 public:
92 ChromeViewsLayoutDelegate();
93 ~ChromeViewsLayoutDelegate() override;
94
95 static ChromeViewsLayoutDelegate* Get();
96 static std::unique_ptr<views::ViewsLayoutDelegate> CreateLayoutDelegate();
97
98 virtual gfx::Insets GetInsetsMetric(ChromeInsetsMetric metric) const;
99 virtual int GetDistanceMetric(ChromeDistanceMetric metric) const;
100
101 const views::TypographyProvider& GetTypographyProvider() const override;
102
103 // Returns the alignment used for control labels in a GridLayout; for example,
104 // in this GridLayout:
105 // ---------------------------
106 // | Label 1 Checkbox 1 |
107 // | Label 2 Checkbox 2 |
108 // ---------------------------
109 // This value controls the alignment used for "Label 1" and "Label 2".
110 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const;
111
112 // Returns whether to use extra padding on dialogs. If this is false, content
113 // Views for dialogs should not insert extra padding at their own edges.
114 virtual bool UseExtraDialogPadding() const;
115
116 // Returns whether to show the icon next to the title text on a dialog.
117 virtual bool ShouldShowWindowIcon() const;
118
119 // DEPRECATED. Returns whether Harmony mode is enabled.
120 //
121 // Instead of using this, create a generic solution that works for all UI
122 // types, e.g. by adding a new LayoutDistance value that means what you need.
123 //
124 // TODO(pkasting): Fix callers and remove this.
125 virtual bool IsHarmonyMode() const;
126
127 // Returns the preferred width in DIPs for a dialog of the specified |width|.
128 // May return 0 if the dialog has no preferred width.
129 virtual int GetDialogPreferredWidth(DialogWidth width) const;
130
131 int GetDefaultDistanceMetric(views::DistanceMetric metric) const;
132
133 private:
134 gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override;
135 int GetDistanceMetric(views::DistanceMetric metric) const override;
136
137 DISALLOW_COPY_AND_ASSIGN(ChromeViewsLayoutDelegate);
138 };
139
140 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_VIEWS_LAYOUT_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698