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