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