| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 UI_VIEWS_LAYOUT_LAYOUT_PROVIDER_H_ |
| 6 #define UI_VIEWS_LAYOUT_LAYOUT_PROVIDER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "ui/gfx/geometry/insets.h" |
| 10 #include "ui/views/style/typography_provider.h" |
| 11 #include "ui/views/views_export.h" |
| 12 |
| 13 namespace views { |
| 14 |
| 15 enum InsetsMetric { |
| 16 // Embedders can extend this enum with additional values that are understood |
| 17 // by the LayoutProvider implementation. Embedders define enum values from |
| 18 // VIEWS_INSETS_END. Values named beginning with "INSETS_" represent the |
| 19 // actual Insets: the rest are markers. |
| 20 VIEWS_INSETS_START = 0, |
| 21 |
| 22 // The margins around the contents area of a bubble (popover)-style dialog. |
| 23 INSETS_BUBBLE_CONTENTS = VIEWS_INSETS_START, |
| 24 // The margins around the button row of a dialog. |
| 25 INSETS_DIALOG_BUTTON, |
| 26 // The margins around the icon/title of a dialog. |
| 27 INSETS_DIALOG_TITLE, |
| 28 // The margins that should be applied around a panel GridLayout. |
| 29 INSETS_PANEL, |
| 30 // Padding to add to vector image buttons to increase their click and touch |
| 31 // target size. |
| 32 INSETS_VECTOR_IMAGE_BUTTON, |
| 33 |
| 34 // Embedders must start Insets enum values from this value. |
| 35 VIEWS_INSETS_END, |
| 36 |
| 37 // All Insets enum values must be below this value. |
| 38 VIEWS_INSETS_MAX = 0x1000 |
| 39 }; |
| 40 |
| 41 enum DistanceMetric { |
| 42 // DistanceMetric enum values must always be greater than any InsetsMetric |
| 43 // value. This allows the code to verify at runtime that arguments of the |
| 44 // two types have not been interchanged. |
| 45 VIEWS_DISTANCE_START = VIEWS_INSETS_MAX, |
| 46 |
| 47 // The default padding to add on each side of a button's label. |
| 48 DISTANCE_BUTTON_HORIZONTAL_PADDING = VIEWS_DISTANCE_START, |
| 49 // The distance between a dialog's edge and the close button in the upper |
| 50 // trailing corner. |
| 51 DISTANCE_CLOSE_BUTTON_MARGIN, |
| 52 // The default minimum width of a dialog button. |
| 53 DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH, |
| 54 // The spacing between a pair of related horizontal buttons, used for |
| 55 // dialog layout. |
| 56 DISTANCE_RELATED_BUTTON_HORIZONTAL, |
| 57 // Horizontal spacing between controls that are logically related. |
| 58 DISTANCE_RELATED_CONTROL_HORIZONTAL, |
| 59 // The spacing between a pair of related vertical controls, used for |
| 60 // dialog layout. |
| 61 DISTANCE_RELATED_CONTROL_VERTICAL, |
| 62 |
| 63 // Embedders must start DistanceMetric enum values from here. |
| 64 VIEWS_DISTANCE_END |
| 65 }; |
| 66 |
| 67 class VIEWS_EXPORT LayoutProvider { |
| 68 public: |
| 69 LayoutProvider(); |
| 70 virtual ~LayoutProvider(); |
| 71 |
| 72 // This should never return nullptr. |
| 73 static LayoutProvider* Get(); |
| 74 |
| 75 // Returns the insets metric according to the given enumeration element. |
| 76 virtual gfx::Insets GetInsetsMetric(int metric) const; |
| 77 |
| 78 // Returns the distance metric between elements according to the given |
| 79 // enumeration element. |
| 80 virtual int GetDistanceMetric(int metric) const; |
| 81 |
| 82 // Returns the TypographyProvider, used to configure text properties such as |
| 83 // font, weight, color, size, and line height. Never null. |
| 84 virtual const TypographyProvider& GetTypographyProvider() const; |
| 85 |
| 86 private: |
| 87 DefaultTypographyProvider typography_provider_; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(LayoutProvider); |
| 90 }; |
| 91 |
| 92 } // namespace views |
| 93 |
| 94 #endif // UI_VIEWS_LAYOUT_LAYOUT_PROVIDER_H_ |
| OLD | NEW |