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" | 13 #include "ui/views/controls/combobox/combobox.h" |
14 #include "ui/views/views_export.h" | 14 #include "ui/views/views_export.h" |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 | 17 |
18 class Border; | 18 class Border; |
19 class FocusableBorder; | 19 class FocusableBorder; |
20 class Label; | 20 class Label; |
21 class LabelButton; | 21 class LabelButton; |
22 class LabelButtonBorder; | |
23 class ScrollBar; | 22 class ScrollBar; |
24 | 23 |
25 // Cross-platform API for providing platform-specific styling for toolkit-views. | 24 // Cross-platform API for providing platform-specific styling for toolkit-views. |
26 class VIEWS_EXPORT PlatformStyle { | 25 class VIEWS_EXPORT PlatformStyle { |
27 public: | 26 public: |
28 // Type used by LabelButton to map button states to text colors. | 27 // Type used by LabelButton to map button states to text colors. |
29 using ButtonColorByState = SkColor[Button::STATE_COUNT]; | 28 using ButtonColorByState = SkColor[Button::STATE_COUNT]; |
30 | 29 |
31 // Padding to use on either side of the arrow for a Combobox when in | 30 // Padding to use on either side of the arrow for a Combobox when in |
32 // Combobox::STYLE_NORMAL. | 31 // Combobox::STYLE_NORMAL. |
(...skipping 30 matching lines...) Expand all Loading... |
63 static gfx::ImageSkia CreateComboboxArrow(bool is_enabled, | 62 static gfx::ImageSkia CreateComboboxArrow(bool is_enabled, |
64 Combobox::Style style); | 63 Combobox::Style style); |
65 | 64 |
66 // Creates the appropriate border for a focusable Combobox. | 65 // Creates the appropriate border for a focusable Combobox. |
67 static std::unique_ptr<FocusableBorder> CreateComboboxBorder(); | 66 static std::unique_ptr<FocusableBorder> CreateComboboxBorder(); |
68 | 67 |
69 // Creates the appropriate background for a Combobox. | 68 // Creates the appropriate background for a Combobox. |
70 static std::unique_ptr<Background> CreateComboboxBackground( | 69 static std::unique_ptr<Background> CreateComboboxBackground( |
71 int shoulder_width); | 70 int shoulder_width); |
72 | 71 |
73 // Creates the default label button border for the given |style|. Used when a | |
74 // custom default border is not provided for a particular LabelButton class. | |
75 static std::unique_ptr<LabelButtonBorder> CreateLabelButtonBorder( | |
76 Button::ButtonStyle style); | |
77 | |
78 // Creates the default scrollbar for the given orientation. | 72 // Creates the default scrollbar for the given orientation. |
79 static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal); | 73 static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal); |
80 | 74 |
81 // Returns the current text color for the current button state. | 75 // Returns the current text color for the current button state. |
82 static SkColor TextColorForButton(const ButtonColorByState& color_by_state, | 76 static SkColor TextColorForButton(const ButtonColorByState& color_by_state, |
83 const LabelButton& button); | 77 const LabelButton& button); |
84 | 78 |
85 // Applies platform styles to |label| and fills |color_by_state| with the text | 79 // Applies platform styles to |label| and fills |color_by_state| with the text |
86 // colors for normal, pressed, hovered, and disabled states, if the colors for | 80 // colors for normal, pressed, hovered, and disabled states, if the colors for |
87 // Button::STYLE_BUTTON buttons differ from those provided by ui::NativeTheme. | 81 // Button::STYLE_BUTTON buttons differ from those provided by ui::NativeTheme. |
88 static void ApplyLabelButtonTextStyle(Label* label, | 82 static void ApplyLabelButtonTextStyle(Label* label, |
89 ButtonColorByState* color_by_state); | 83 ButtonColorByState* color_by_state); |
90 | 84 |
91 // Applies the current system theme to the default border created by |button|. | 85 // Applies the current system theme to the default border created by |button|. |
92 static std::unique_ptr<Border> CreateThemedLabelButtonBorder( | 86 static std::unique_ptr<Border> CreateThemedLabelButtonBorder( |
93 LabelButton* button); | 87 LabelButton* button); |
94 | 88 |
95 // Called whenever a textfield keypress is unhandled for any reason. Gives | 89 // Called whenever a textfield keypress is unhandled for any reason. Gives |
96 // visual/audio feedback about the unhandled key if platform-appropriate. | 90 // visual/audio feedback about the unhandled key if platform-appropriate. |
97 static void OnTextfieldKeypressUnhandled(); | 91 static void OnTextfieldKeypressUnhandled(); |
98 | 92 |
99 private: | 93 private: |
100 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformStyle); | 94 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformStyle); |
101 }; | 95 }; |
102 | 96 |
103 } // namespace views | 97 } // namespace views |
104 | 98 |
105 #endif // UI_VIEWS_STYLE_PLATFORM_STYLE_H_ | 99 #endif // UI_VIEWS_STYLE_PLATFORM_STYLE_H_ |
OLD | NEW |