| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 UI_VIEWS_STYLE_PLATFORM_STYLE_H_ | 5 #ifndef UI_VIEWS_STYLE_PLATFORM_STYLE_H_ |
| 6 #define UI_VIEWS_STYLE_PLATFORM_STYLE_H_ | 6 #define UI_VIEWS_STYLE_PLATFORM_STYLE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/controls/button/custom_button.h" | 12 #include "ui/views/controls/button/custom_button.h" |
| 13 #include "ui/views/controls/combobox/combobox.h" | |
| 14 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
| 15 | 14 |
| 16 namespace views { | 15 namespace views { |
| 17 | 16 |
| 18 class Border; | 17 class Border; |
| 19 class Label; | 18 class Label; |
| 20 class LabelButton; | 19 class LabelButton; |
| 21 class ScrollBar; | 20 class ScrollBar; |
| 22 | 21 |
| 23 // Cross-platform API for providing platform-specific styling for toolkit-views. | 22 // Cross-platform API for providing platform-specific styling for toolkit-views. |
| 24 class VIEWS_EXPORT PlatformStyle { | 23 class VIEWS_EXPORT PlatformStyle { |
| 25 public: | 24 public: |
| 26 // Type used by LabelButton to map button states to text colors. | 25 // Type used by LabelButton to map button states to text colors. |
| 27 using ButtonColorByState = SkColor[Button::STATE_COUNT]; | 26 using ButtonColorByState = SkColor[Button::STATE_COUNT]; |
| 28 | 27 |
| 29 // Padding to use on either side of the arrow for a Combobox when in | |
| 30 // Combobox::STYLE_NORMAL. | |
| 31 static const int kComboboxNormalArrowPadding; | |
| 32 | |
| 33 // Minimum size for platform-styled buttons (Button::STYLE_BUTTON). | 28 // Minimum size for platform-styled buttons (Button::STYLE_BUTTON). |
| 34 static const int kMinLabelButtonWidth; | 29 static const int kMinLabelButtonWidth; |
| 35 static const int kMinLabelButtonHeight; | 30 static const int kMinLabelButtonHeight; |
| 36 | 31 |
| 37 // Whether dialog-default buttons are given a bold font style. | 32 // Whether dialog-default buttons are given a bold font style. |
| 38 static const bool kDefaultLabelButtonHasBoldFont; | 33 static const bool kDefaultLabelButtonHasBoldFont; |
| 39 | 34 |
| 40 // Whether the default button for a dialog can be the Cancel button. | 35 // Whether the default button for a dialog can be the Cancel button. |
| 41 static const bool kDialogDefaultButtonCanBeCancel; | 36 static const bool kDialogDefaultButtonCanBeCancel; |
| 42 | 37 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 // ancestors. | 59 // ancestors. |
| 65 static const bool kTreeViewUsesOpenIcon; | 60 static const bool kTreeViewUsesOpenIcon; |
| 66 | 61 |
| 67 // Whether ripples should be used for visual feedback on control activation. | 62 // Whether ripples should be used for visual feedback on control activation. |
| 68 static const bool kUseRipples; | 63 static const bool kUseRipples; |
| 69 | 64 |
| 70 // Whether to mirror the arrow of bubble dialogs in RTL, such that the bubble | 65 // Whether to mirror the arrow of bubble dialogs in RTL, such that the bubble |
| 71 // opens in the opposite direction. | 66 // opens in the opposite direction. |
| 72 static const bool kMirrorBubbleArrowInRTLByDefault; | 67 static const bool kMirrorBubbleArrowInRTLByDefault; |
| 73 | 68 |
| 74 // Creates an ImageSkia containing the image to use for the combobox arrow. | |
| 75 // The |is_enabled| argument is true if the control the arrow is for is | |
| 76 // enabled, and false if the control is disabled. The |style| argument is the | |
| 77 // style of the combobox the arrow is being drawn for. | |
| 78 static gfx::ImageSkia CreateComboboxArrow(bool is_enabled, | |
| 79 Combobox::Style style); | |
| 80 | |
| 81 // Creates the default scrollbar for the given orientation. | 69 // Creates the default scrollbar for the given orientation. |
| 82 static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal); | 70 static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal); |
| 83 | 71 |
| 84 // Returns the current text color for the current button state. | 72 // Returns the current text color for the current button state. |
| 85 static SkColor TextColorForButton(const ButtonColorByState& color_by_state, | 73 static SkColor TextColorForButton(const ButtonColorByState& color_by_state, |
| 86 const LabelButton& button); | 74 const LabelButton& button); |
| 87 | 75 |
| 88 // Applies platform styles to |label| and fills |color_by_state| with the text | 76 // Applies platform styles to |label| and fills |color_by_state| with the text |
| 89 // colors for normal, pressed, hovered, and disabled states, if the colors for | 77 // colors for normal, pressed, hovered, and disabled states, if the colors for |
| 90 // Button::STYLE_BUTTON buttons differ from those provided by ui::NativeTheme. | 78 // Button::STYLE_BUTTON buttons differ from those provided by ui::NativeTheme. |
| 91 static void ApplyLabelButtonTextStyle(Label* label, | 79 static void ApplyLabelButtonTextStyle(Label* label, |
| 92 ButtonColorByState* color_by_state); | 80 ButtonColorByState* color_by_state); |
| 93 | 81 |
| 94 // Applies the current system theme to the default border created by |button|. | 82 // Applies the current system theme to the default border created by |button|. |
| 95 static std::unique_ptr<Border> CreateThemedLabelButtonBorder( | 83 static std::unique_ptr<Border> CreateThemedLabelButtonBorder( |
| 96 LabelButton* button); | 84 LabelButton* button); |
| 97 | 85 |
| 98 // Called whenever a textfield edit fails. Gives visual/audio feedback about | 86 // Called whenever a textfield edit fails. Gives visual/audio feedback about |
| 99 // the failed edit if platform-appropriate. | 87 // the failed edit if platform-appropriate. |
| 100 static void OnTextfieldEditFailed(); | 88 static void OnTextfieldEditFailed(); |
| 101 | 89 |
| 102 private: | 90 private: |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformStyle); | 91 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformStyle); |
| 104 }; | 92 }; |
| 105 | 93 |
| 106 } // namespace views | 94 } // namespace views |
| 107 | 95 |
| 108 #endif // UI_VIEWS_STYLE_PLATFORM_STYLE_H_ | 96 #endif // UI_VIEWS_STYLE_PLATFORM_STYLE_H_ |
| OLD | NEW |