Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_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/layout_delegate.h" | |
| 14 | |
| 15 enum class ChromeInsetsMetric { | |
|
Peter Kasting
2017/04/06 08:13:36
Seems like we don't even need this class or the ch
kylix_rd
2017/04/06 16:48:19
As I worked on this patch, I saw several places in
kylix_rd
2017/04/07 18:33:36
I went ahead and removed the override for GetInset
| |
| 16 BUBBLE_DIALOG = views::InsetsMetric::BUBBLE_DIALOG, | |
| 17 DIALOG_BUTTON = views::InsetsMetric::DIALOG_BUTTON, | |
| 18 DIALOG_FRAME_VIEW = views::InsetsMetric::DIALOG_FRAME_VIEW, | |
| 19 PANEL = views::InsetsMetric::PANEL, | |
| 20 VECTOR_IMAGE_BUTTON = views::InsetsMetric::VECTOR_IMAGE_BUTTON, | |
| 21 }; | |
| 22 | |
| 23 enum class ChromeDistanceMetric { | |
| 24 BUTTON_HORIZONTAL_PADDING = views::DistanceMetric::BUTTON_HORIZONTAL_PADDING, | |
| 25 CLOSE_BUTTON_MARGIN = views::DistanceMetric::CLOSE_BUTTON_MARGIN, | |
| 26 DIALOG_BUTTON_MINIMUM_WIDTH = | |
| 27 views::DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH, | |
| 28 RELATED_BUTTON_HORIZONTAL = views::DistanceMetric::RELATED_BUTTON_HORIZONTAL, | |
| 29 RELATED_CONTROL_HORIZONTAL = | |
| 30 views::DistanceMetric::RELATED_CONTROL_HORIZONTAL, | |
| 31 RELATED_CONTROL_VERTICAL = views::DistanceMetric::RELATED_CONTROL_VERTICAL, | |
| 32 // Margin between the edge of a dialog and the left, right, or bottom of a | |
|
Peter Kasting
2017/04/06 08:13:36
Nit: Maybe blank line above this?
kylix_rd
2017/04/06 16:48:19
Done.
| |
| 33 // contained button. | |
| 34 DIALOG_BUTTON_MARGIN, | |
| 35 // Spacing between a dialog button and the content above it. | |
| 36 DIALOG_BUTTON_TOP, | |
| 37 // Horizontal or vertical margin between the edge of a panel and the | |
| 38 // contained content. | |
| 39 PANEL_CONTENT_MARGIN, | |
| 40 // The maximum width a button can have and still influence the sizes of | |
| 41 // other linked buttons. This allows short buttons to have linked widths | |
| 42 // without long buttons making things overly wide. | |
| 43 BUTTON_MAX_LINKABLE_WIDTH, | |
| 44 // Default minimum width of a button. | |
| 45 BUTTON_MINIMUM_WIDTH, | |
| 46 // Smaller horizontal spacing between other controls that are logically | |
| 47 // related. | |
| 48 RELATED_CONTROL_HORIZONTAL_SMALL, | |
| 49 // Smaller vertical spacing between controls that are logically related. | |
| 50 RELATED_CONTROL_VERTICAL_SMALL, | |
| 51 // Horizontal spacing between an item such as an icon or checkbox and a | |
| 52 // label related to it. | |
| 53 RELATED_LABEL_HORIZONTAL, | |
| 54 // Horizontal indent of a subsection relative to related items above, e.g. | |
| 55 // checkboxes below explanatory text/headings. | |
| 56 SUBSECTION_HORIZONTAL_INDENT, | |
| 57 // Horizontal spacing between controls that are logically unrelated. | |
| 58 UNRELATED_CONTROL_HORIZONTAL, | |
| 59 // Larger horizontal spacing between unrelated controls. | |
| 60 UNRELATED_CONTROL_HORIZONTAL_LARGE, | |
| 61 // Vertical spacing between controls that are logically unrelated. | |
| 62 UNRELATED_CONTROL_VERTICAL, | |
| 63 // Larger vertical spacing between unrelated controls. | |
| 64 UNRELATED_CONTROL_VERTICAL_LARGE, | |
| 65 }; | |
| 66 | |
| 67 enum class DialogWidth { | |
| 68 SMALL, | |
| 69 MEDIUM, | |
| 70 LARGE, | |
| 71 }; | |
| 72 | |
| 73 class ChromeLayoutDelegate : public views::LayoutDelegate { | |
| 74 public: | |
| 75 ChromeLayoutDelegate(); | |
| 76 ~ChromeLayoutDelegate() override; | |
| 77 | |
| 78 static ChromeLayoutDelegate* Get(); | |
| 79 static std::unique_ptr<views::LayoutDelegate> CreateLayoutDelegate(); | |
| 80 | |
| 81 virtual gfx::Insets GetInsetsMetric(ChromeInsetsMetric metric) const; | |
| 82 virtual int GetDistanceMetric(ChromeDistanceMetric metric) const; | |
| 83 | |
| 84 const views::TypographyProvider& GetTypographyProvider() const override; | |
| 85 | |
| 86 // Returns the alignment used for control labels in a GridLayout; for example, | |
| 87 // in this GridLayout: | |
| 88 // --------------------------- | |
| 89 // | Label 1 Checkbox 1 | | |
| 90 // | Label 2 Checkbox 2 | | |
| 91 // --------------------------- | |
| 92 // This value controls the alignment used for "Label 1" and "Label 2". | |
| 93 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const; | |
| 94 | |
| 95 // Returns whether to use extra padding on dialogs. If this is false, content | |
| 96 // Views for dialogs should not insert extra padding at their own edges. | |
| 97 virtual bool UseExtraDialogPadding() const; | |
| 98 | |
| 99 // Returns whether to show the icon next to the title text on a dialog. | |
| 100 virtual bool ShouldShowWindowIcon() const; | |
| 101 | |
| 102 // DEPRECATED. Returns whether Harmony mode is enabled. | |
| 103 // | |
| 104 // Instead of using this, create a generic solution that works for all UI | |
| 105 // types, e.g. by adding a new LayoutDistance value that means what you need. | |
| 106 // | |
| 107 // TODO(pkasting): Fix callers and remove this. | |
| 108 virtual bool IsHarmonyMode() const; | |
| 109 | |
| 110 // Returns the preferred width in DIPs for a dialog of the specified |width|. | |
| 111 // May return 0 if the dialog has no preferred width. | |
| 112 virtual int GetDialogPreferredWidth(DialogWidth width) const; | |
| 113 | |
| 114 private: | |
| 115 gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override; | |
| 116 int GetDistanceMetric(views::DistanceMetric metric) const override; | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(ChromeLayoutDelegate); | |
| 119 }; | |
| 120 | |
| 121 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_DELEGATE_H_ | |
| OLD | NEW |