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_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_LABEL_H_ |
6 #define UI_VIEWS_CONTROLS_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_LABEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "ui/gfx/font_list.h" | 15 #include "ui/gfx/font_list.h" |
| 16 #include "ui/gfx/shadow_value.h" |
16 #include "ui/gfx/text_constants.h" | 17 #include "ui/gfx/text_constants.h" |
17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 | 21 |
21 // A view subclass that can display a string. | 22 // A view subclass that can display a string. |
22 class VIEWS_EXPORT Label : public View { | 23 class VIEWS_EXPORT Label : public View { |
23 public: | 24 public: |
24 // Internal class name. | 25 // Internal class name. |
25 static const char kViewClassName[]; | 26 static const char kViewClassName[]; |
(...skipping 25 matching lines...) Expand all Loading... |
51 virtual void SetEnabledColor(SkColor color); | 52 virtual void SetEnabledColor(SkColor color); |
52 void SetDisabledColor(SkColor color); | 53 void SetDisabledColor(SkColor color); |
53 | 54 |
54 SkColor enabled_color() const { return actual_enabled_color_; } | 55 SkColor enabled_color() const { return actual_enabled_color_; } |
55 | 56 |
56 // Sets the background color. This won't be explicitly drawn, but the label | 57 // Sets the background color. This won't be explicitly drawn, but the label |
57 // will force the text color to be readable over it. | 58 // will force the text color to be readable over it. |
58 void SetBackgroundColor(SkColor color); | 59 void SetBackgroundColor(SkColor color); |
59 SkColor background_color() const { return background_color_; } | 60 SkColor background_color() const { return background_color_; } |
60 | 61 |
61 // Enables a drop shadow underneath the text. | 62 // Set drop shadows underneath the text. |
62 void SetShadowColors(SkColor enabled_color, SkColor disabled_color); | 63 void set_shadows(const gfx::ShadowValues& shadows) { shadows_ = shadows; } |
63 | |
64 // Sets the drop shadow's offset from the text. | |
65 void SetShadowOffset(int x, int y); | |
66 | |
67 // Sets the shadow blur. Default is zero. | |
68 void set_shadow_blur(double shadow_blur) { shadow_blur_ = shadow_blur; } | |
69 | |
70 // Disables shadows. | |
71 void ClearEmbellishing(); | |
72 | 64 |
73 // Set the color of a halo on the painted text (use transparent for none). | 65 // Set the color of a halo on the painted text (use transparent for none). |
74 void set_halo_color(SkColor halo_color) { halo_color_ = halo_color; } | 66 void set_halo_color(SkColor halo_color) { halo_color_ = halo_color; } |
75 | 67 |
76 // Sets the horizontal alignment; the argument value is mirrored in RTL UI. | 68 // Sets the horizontal alignment; the argument value is mirrored in RTL UI. |
77 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); | 69 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); |
78 gfx::HorizontalAlignment GetHorizontalAlignment() const; | 70 gfx::HorizontalAlignment GetHorizontalAlignment() const; |
79 | 71 |
80 // Sets the directionality mode. The default value is DIRECTIONALITY_FROM_UI, | 72 // Sets the directionality mode. The default value is DIRECTIONALITY_FROM_UI, |
81 // which should be suitable for most text originating from UI string assets. | 73 // which should be suitable for most text originating from UI string assets. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 bool is_obscured_; | 226 bool is_obscured_; |
235 bool allow_character_break_; | 227 bool allow_character_break_; |
236 gfx::ElideBehavior elide_behavior_; | 228 gfx::ElideBehavior elide_behavior_; |
237 gfx::HorizontalAlignment horizontal_alignment_; | 229 gfx::HorizontalAlignment horizontal_alignment_; |
238 base::string16 tooltip_text_; | 230 base::string16 tooltip_text_; |
239 // Whether to collapse the label when it's not visible. | 231 // Whether to collapse the label when it's not visible. |
240 bool collapse_when_hidden_; | 232 bool collapse_when_hidden_; |
241 // Controls whether the directionality is auto-detected based on first strong | 233 // Controls whether the directionality is auto-detected based on first strong |
242 // directionality character or is determined by the application UI's locale. | 234 // directionality character or is determined by the application UI's locale. |
243 gfx::DirectionalityMode directionality_mode_; | 235 gfx::DirectionalityMode directionality_mode_; |
244 | 236 gfx::ShadowValues shadows_; |
245 // Colors for shadow. | |
246 SkColor enabled_shadow_color_; | |
247 SkColor disabled_shadow_color_; | |
248 | |
249 // Space between text and shadow. | |
250 gfx::Point shadow_offset_; | |
251 | |
252 // Should a shadow be drawn behind the text? | |
253 bool has_shadow_; | |
254 | |
255 // Indicates the level of shadow blurring. Default is zero. | |
256 double shadow_blur_; | |
257 | 237 |
258 // The halo color drawn around the text if it is not transparent. | 238 // The halo color drawn around the text if it is not transparent. |
259 SkColor halo_color_; | 239 SkColor halo_color_; |
260 | 240 |
261 // The cached heights to avoid recalculation in GetHeightForWidth(). | 241 // The cached heights to avoid recalculation in GetHeightForWidth(). |
262 mutable std::vector<gfx::Size> cached_heights_; | 242 mutable std::vector<gfx::Size> cached_heights_; |
263 mutable int cached_heights_cursor_; | 243 mutable int cached_heights_cursor_; |
264 | 244 |
265 DISALLOW_COPY_AND_ASSIGN(Label); | 245 DISALLOW_COPY_AND_ASSIGN(Label); |
266 }; | 246 }; |
267 | 247 |
268 } // namespace views | 248 } // namespace views |
269 | 249 |
270 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 250 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |