OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
7 | 7 |
| 8 #include <array> |
8 #include <memory> | 9 #include <memory> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
14 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
15 #include "ui/views/controls/button/custom_button.h" | 16 #include "ui/views/controls/button/custom_button.h" |
16 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
17 #include "ui/views/controls/label.h" | 18 #include "ui/views/controls/label.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Updates the image view to contain the appropriate button state image. | 144 // Updates the image view to contain the appropriate button state image. |
144 void UpdateImage(); | 145 void UpdateImage(); |
145 | 146 |
146 // Updates the border as per the NativeTheme, unless a different border was | 147 // Updates the border as per the NativeTheme, unless a different border was |
147 // set with SetBorder. | 148 // set with SetBorder. |
148 void UpdateThemedBorder(); | 149 void UpdateThemedBorder(); |
149 | 150 |
150 // NativeThemeDelegate: | 151 // NativeThemeDelegate: |
151 gfx::Rect GetThemePaintRect() const override; | 152 gfx::Rect GetThemePaintRect() const override; |
152 | 153 |
| 154 const std::array<bool, STATE_COUNT>& explicitly_set_colors() const { |
| 155 return explicitly_set_colors_; |
| 156 } |
| 157 void set_explicitly_set_colors(const std::array<bool, STATE_COUNT>& colors) { |
| 158 explicitly_set_colors_ = colors; |
| 159 } |
| 160 |
153 private: | 161 private: |
154 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init); | 162 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init); |
155 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label); | 163 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label); |
156 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image); | 164 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image); |
157 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage); | 165 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage); |
158 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList); | 166 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList); |
159 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, ResetColorsFromNativeTheme); | 167 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, ResetColorsFromNativeTheme); |
160 | 168 |
161 void SetTextInternal(const base::string16& text); | 169 void SetTextInternal(const base::string16& text); |
162 | 170 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 205 |
198 // The cached font lists in the normal and bold style. | 206 // The cached font lists in the normal and bold style. |
199 gfx::FontList cached_normal_font_list_; | 207 gfx::FontList cached_normal_font_list_; |
200 gfx::FontList cached_bold_font_list_; | 208 gfx::FontList cached_bold_font_list_; |
201 | 209 |
202 // The images and colors for each button state. | 210 // The images and colors for each button state. |
203 gfx::ImageSkia button_state_images_[STATE_COUNT]; | 211 gfx::ImageSkia button_state_images_[STATE_COUNT]; |
204 SkColor button_state_colors_[STATE_COUNT]; | 212 SkColor button_state_colors_[STATE_COUNT]; |
205 | 213 |
206 // Used to track whether SetTextColor() has been invoked. | 214 // Used to track whether SetTextColor() has been invoked. |
207 bool explicitly_set_colors_[STATE_COUNT]; | 215 std::array<bool, STATE_COUNT> explicitly_set_colors_; |
208 | 216 |
209 // |min_size_| increases monotonically with the preferred size. | 217 // |min_size_| increases monotonically with the preferred size. |
210 mutable gfx::Size min_size_; | 218 mutable gfx::Size min_size_; |
211 // |max_size_| may be set to clamp the preferred size. | 219 // |max_size_| may be set to clamp the preferred size. |
212 gfx::Size max_size_; | 220 gfx::Size max_size_; |
213 | 221 |
214 // Cache the last computed preferred size. | 222 // Cache the last computed preferred size. |
215 mutable gfx::Size cached_preferred_size_; | 223 mutable gfx::Size cached_preferred_size_; |
216 mutable bool cached_preferred_size_valid_; | 224 mutable bool cached_preferred_size_valid_; |
217 | 225 |
(...skipping 18 matching lines...) Expand all Loading... |
236 gfx::HorizontalAlignment horizontal_alignment_; | 244 gfx::HorizontalAlignment horizontal_alignment_; |
237 | 245 |
238 std::unique_ptr<Painter> focus_painter_; | 246 std::unique_ptr<Painter> focus_painter_; |
239 | 247 |
240 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 248 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
241 }; | 249 }; |
242 | 250 |
243 } // namespace views | 251 } // namespace views |
244 | 252 |
245 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 253 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
OLD | NEW |