| 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_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_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_provider.h" |
| 14 |
| 15 enum ChromeDistanceMetric { |
| 16 // The maximum width a button can have and still influence the sizes of |
| 17 // other linked buttons. This allows short buttons to have linked widths |
| 18 // without long buttons making things overly wide. |
| 19 DISTANCE_BUTTON_MAX_LINKABLE_WIDTH = views::VIEWS_DISTANCE_END, |
| 20 // Default minimum width of a button. |
| 21 DISTANCE_BUTTON_MINIMUM_WIDTH, |
| 22 // Margin between the edge of a dialog and the left, right, or bottom of a |
| 23 // contained button. |
| 24 DISTANCE_DIALOG_BUTTON_MARGIN, |
| 25 // Spacing between a dialog button and the content above it. |
| 26 DISTANCE_DIALOG_BUTTON_TOP, |
| 27 // Horizontal or vertical margin between the edge of a panel and the |
| 28 // contained content. |
| 29 DISTANCE_PANEL_CONTENT_MARGIN, |
| 30 // Smaller horizontal spacing between other controls that are logically |
| 31 // related. |
| 32 DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL, |
| 33 // Smaller vertical spacing between controls that are logically related. |
| 34 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL, |
| 35 // Horizontal spacing between an item such as an icon or checkbox and a |
| 36 // label related to it. |
| 37 DISTANCE_RELATED_LABEL_HORIZONTAL, |
| 38 // Horizontal indent of a subsection relative to related items above, e.g. |
| 39 // checkboxes below explanatory text/headings. |
| 40 DISTANCE_SUBSECTION_HORIZONTAL_INDENT, |
| 41 // Horizontal spacing between controls that are logically unrelated. |
| 42 DISTANCE_UNRELATED_CONTROL_HORIZONTAL, |
| 43 // Larger horizontal spacing between unrelated controls. |
| 44 DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE, |
| 45 // Vertical spacing between controls that are logically unrelated. |
| 46 DISTANCE_UNRELATED_CONTROL_VERTICAL, |
| 47 // Larger vertical spacing between unrelated controls. |
| 48 DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE, |
| 49 }; |
| 50 |
| 51 enum class DialogWidth { |
| 52 SMALL, |
| 53 MEDIUM, |
| 54 LARGE, |
| 55 }; |
| 56 |
| 57 class ChromeLayoutProvider : public views::LayoutProvider { |
| 58 public: |
| 59 ChromeLayoutProvider() {} |
| 60 ~ChromeLayoutProvider() override {} |
| 61 |
| 62 static ChromeLayoutProvider* Get(); |
| 63 static std::unique_ptr<views::LayoutProvider> CreateLayoutProvider(); |
| 64 |
| 65 int GetDistanceMetric(int metric) const override; |
| 66 |
| 67 const views::TypographyProvider& GetTypographyProvider() const override; |
| 68 |
| 69 // Returns the alignment used for control labels in a GridLayout; for example, |
| 70 // in this GridLayout: |
| 71 // --------------------------- |
| 72 // | Label 1 Checkbox 1 | |
| 73 // | Label 2 Checkbox 2 | |
| 74 // --------------------------- |
| 75 // This value controls the alignment used for "Label 1" and "Label 2". |
| 76 virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const; |
| 77 |
| 78 // Returns whether to use extra padding on dialogs. If this is false, content |
| 79 // Views for dialogs should not insert extra padding at their own edges. |
| 80 virtual bool UseExtraDialogPadding() const; |
| 81 |
| 82 // Returns whether to show the icon next to the title text on a dialog. |
| 83 virtual bool ShouldShowWindowIcon() const; |
| 84 |
| 85 // DEPRECATED. Returns whether Harmony mode is enabled. |
| 86 // |
| 87 // Instead of using this, create a generic solution that works for all UI |
| 88 // types, e.g. by adding a new LayoutDistance value that means what you need. |
| 89 // |
| 90 // TODO(pkasting): Fix callers and remove this. |
| 91 virtual bool IsHarmonyMode() const; |
| 92 |
| 93 // Returns the preferred width in DIPs for a dialog of the specified |width|. |
| 94 // May return 0 if the dialog has no preferred width. |
| 95 virtual int GetDialogPreferredWidth(DialogWidth width) const; |
| 96 |
| 97 private: |
| 98 DISALLOW_COPY_AND_ASSIGN(ChromeLayoutProvider); |
| 99 }; |
| 100 |
| 101 #endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_H_ |
| OLD | NEW |