| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "ui/views/layout/grid_layout.h" | 8 #include "ui/views/layout/grid_layout.h" |
| 9 | 9 |
| 10 class LayoutDelegate { | 10 class LayoutDelegate { |
| 11 public: | 11 public: |
| 12 enum class LayoutDistanceType { | 12 enum class Metric { |
| 13 // Horizontal or vertical margin between the edge of a dialog and a | 13 // Horizontal or vertical margin between the edge of a dialog and a |
| 14 // contained button. | 14 // contained button. |
| 15 DIALOG_BUTTON_MARGIN, | 15 DIALOG_BUTTON_MARGIN, |
| 16 // Horizontal or vertical margin between the edge of a panel and the | 16 // Horizontal or vertical margin between the edge of a panel and the |
| 17 // contained content. | 17 // contained content. |
| 18 PANEL_CONTENT_MARGIN, | 18 PANEL_CONTENT_MARGIN, |
| 19 // Horizontal spacing between buttons that are logically related, e.g. | 19 // Horizontal spacing between buttons that are logically related, e.g. |
| 20 // for a button set. | 20 // for a button set. |
| 21 RELATED_BUTTON_HORIZONTAL_SPACING, | 21 RELATED_BUTTON_HORIZONTAL_SPACING, |
| 22 // Horizontal spacing between other controls that are logically related. | 22 // Horizontal spacing between other controls that are logically related. |
| 23 RELATED_CONTROL_HORIZONTAL_SPACING, | 23 RELATED_CONTROL_HORIZONTAL_SPACING, |
| 24 // Vertical spacing between controls that are logically related. | 24 // Vertical spacing between controls that are logically related. |
| 25 RELATED_CONTROL_VERTICAL_SPACING, | 25 RELATED_CONTROL_VERTICAL_SPACING, |
| 26 // Horizontal indent of a subsection relative to related items above, e.g. | 26 // Horizontal indent of a subsection relative to related items above, e.g. |
| 27 // checkboxes below explanatory text/headings. | 27 // checkboxes below explanatory text/headings. |
| 28 SUBSECTION_HORIZONTAL_INDENT, | 28 SUBSECTION_HORIZONTAL_INDENT, |
| 29 // Vertical spacing between controls that are logically unrelated. | 29 // Vertical spacing between controls that are logically unrelated. |
| 30 UNRELATED_CONTROL_VERTICAL_SPACING, | 30 UNRELATED_CONTROL_VERTICAL_SPACING, |
| 31 // Larger vertical spacing between unrelated controls. | 31 // Larger vertical spacing between unrelated controls. |
| 32 UNRELATED_CONTROL_VERTICAL_SPACING_LARGE, | 32 UNRELATED_CONTROL_VERTICAL_SPACING_LARGE, |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 enum class DialogWidthType { | 35 enum class DialogWidth { |
| 36 SMALL, | 36 SMALL, |
| 37 MEDIUM, | 37 MEDIUM, |
| 38 LARGE, | 38 LARGE, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 LayoutDelegate() {} | 41 LayoutDelegate() {} |
| 42 virtual ~LayoutDelegate() {} | 42 virtual ~LayoutDelegate() {} |
| 43 | 43 |
| 44 // Returns the active LayoutDelegate singleton, depending on UI configuration. | 44 // Returns the active LayoutDelegate singleton, depending on UI configuration. |
| 45 // This may be an instance of this class or a subclass, e.g. a | 45 // This may be an instance of this class or a subclass, e.g. a |
| 46 // HarmonyLayoutDelegate. | 46 // HarmonyLayoutDelegate. |
| 47 static LayoutDelegate* Get(); | 47 static LayoutDelegate* Get(); |
| 48 | 48 |
| 49 // Returns the requested distance in DIPs. | 49 // Returns the requested metric in DIPs. |
| 50 virtual int GetLayoutDistance(LayoutDistanceType type) const; | 50 virtual int GetMetric(Metric metric) const; |
| 51 | 51 |
| 52 // Returns the alignment used for control labels in a GridLayout; for example, | 52 // Returns the alignment used for control labels in a GridLayout; for example, |
| 53 // in this GridLayout: | 53 // in this GridLayout: |
| 54 // --------------------------- | 54 // --------------------------- |
| 55 // | Label 1 Checkbox 1 | | 55 // | Label 1 Checkbox 1 | |
| 56 // | Label 2 Checkbox 2 | | 56 // | Label 2 Checkbox 2 | |
| 57 // --------------------------- | 57 // --------------------------- |
| 58 // This value controls the alignment used for "Label 1" and "Label 2". | 58 // This value controls the alignment used for "Label 1" and "Label 2". |
| 59 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const; | 59 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const; |
| 60 | 60 |
| 61 // Returns whether to use extra padding on dialogs. If this is false, content | 61 // Returns whether to use extra padding on dialogs. If this is false, content |
| 62 // Views for dialogs should not insert extra padding at their own edges. | 62 // Views for dialogs should not insert extra padding at their own edges. |
| 63 virtual bool UseExtraDialogPadding() const; | 63 virtual bool UseExtraDialogPadding() const; |
| 64 | 64 |
| 65 // DEPRECATED. Returns whether Harmony mode is enabled. | 65 // DEPRECATED. Returns whether Harmony mode is enabled. |
| 66 // | 66 // |
| 67 // Instead of using this, create a generic solution that works for all UI | 67 // Instead of using this, create a generic solution that works for all UI |
| 68 // types, e.g. by adding a new LayoutDistance value that means what you need. | 68 // types, e.g. by adding a new LayoutDistance value that means what you need. |
| 69 // | 69 // |
| 70 // TODO(pkasting): Fix callers and remove this. | 70 // TODO(pkasting): Fix callers and remove this. |
| 71 virtual bool IsHarmonyMode() const; | 71 virtual bool IsHarmonyMode() const; |
| 72 | 72 |
| 73 // Returns the preferred width in DIPs for a dialog of the specified |type|. | 73 // Returns the preferred width in DIPs for a dialog of the specified |width|. |
| 74 // May return 0 if the dialog has no preferred width. | 74 // May return 0 if the dialog has no preferred width. |
| 75 virtual int GetDialogPreferredWidth(DialogWidthType type) const; | 75 virtual int GetDialogPreferredWidth(DialogWidth width) const; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(LayoutDelegate); | 78 DISALLOW_COPY_AND_ASSIGN(LayoutDelegate); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ | 81 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_LAYOUT_DELEGATE_H_ |
| OLD | NEW |