| 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), |
| 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 // Horizontal indent of a subsection relative to related items above, e.g. |
| 70 // checkboxes below explanatory text/headings. |
| 71 SUBSECTION_HORIZONTAL_INDENT, |
| 72 // Horizontal spacing between controls that are logically unrelated. |
| 73 UNRELATED_CONTROL_HORIZONTAL, |
| 74 // Larger horizontal spacing between unrelated controls. |
| 75 UNRELATED_CONTROL_HORIZONTAL_LARGE, |
| 76 // Vertical spacing between controls that are logically unrelated. |
| 77 UNRELATED_CONTROL_VERTICAL, |
| 78 // Larger vertical spacing between unrelated controls. |
| 79 UNRELATED_CONTROL_VERTICAL_LARGE, |
| 80 }; |
| 81 |
| 82 enum class DialogWidth { |
| 83 SMALL, |
| 84 MEDIUM, |
| 85 LARGE, |
| 86 }; |
| 87 |
| 88 class ChromeViewsLayoutDelegate : public views::ViewsLayoutDelegate { |
| 89 public: |
| 90 ChromeViewsLayoutDelegate(); |
| 91 ~ChromeViewsLayoutDelegate() override; |
| 92 |
| 93 static ChromeViewsLayoutDelegate* Get(); |
| 94 static std::unique_ptr<views::ViewsLayoutDelegate> CreateLayoutDelegate(); |
| 95 |
| 96 virtual gfx::Insets GetInsetsMetric(ChromeInsetsMetric metric) const; |
| 97 virtual int GetDistanceMetric(ChromeDistanceMetric metric) const; |
| 98 |
| 99 const views::TypographyProvider& GetTypographyProvider() const override; |
| 100 |
| 101 // Returns the alignment used for control labels in a GridLayout; for example, |
| 102 // in this GridLayout: |
| 103 // --------------------------- |
| 104 // | Label 1 Checkbox 1 | |
| 105 // | Label 2 Checkbox 2 | |
| 106 // --------------------------- |
| 107 // This value controls the alignment used for "Label 1" and "Label 2". |
| 108 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const; |
| 109 |
| 110 // Returns whether to use extra padding on dialogs. If this is false, content |
| 111 // Views for dialogs should not insert extra padding at their own edges. |
| 112 virtual bool UseExtraDialogPadding() const; |
| 113 |
| 114 // Returns whether to show the icon next to the title text on a dialog. |
| 115 virtual bool ShouldShowWindowIcon() const; |
| 116 |
| 117 // DEPRECATED. Returns whether Harmony mode is enabled. |
| 118 // |
| 119 // Instead of using this, create a generic solution that works for all UI |
| 120 // types, e.g. by adding a new LayoutDistance value that means what you need. |
| 121 // |
| 122 // TODO(pkasting): Fix callers and remove this. |
| 123 virtual bool IsHarmonyMode() const; |
| 124 |
| 125 // Returns the preferred width in DIPs for a dialog of the specified |width|. |
| 126 // May return 0 if the dialog has no preferred width. |
| 127 virtual int GetDialogPreferredWidth(DialogWidth width) const; |
| 128 |
| 129 int GetDefaultDistanceMetric(views::DistanceMetric metric) const; |
| 130 |
| 131 private: |
| 132 gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override; |
| 133 int GetDistanceMetric(views::DistanceMetric metric) const override; |
| 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(ChromeViewsLayoutDelegate); |
| 136 }; |
| 137 |
| 138 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_VIEWS_LAYOUT_DELEGATE_H_ |
| OLD | NEW |