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 #include "ui/views/controls/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <vector> | 10 #include <vector> |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 state->role = ui::AX_ROLE_STATIC_TEXT; | 316 state->role = ui::AX_ROLE_STATIC_TEXT; |
317 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 317 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
318 state->name = layout_text(); | 318 state->name = layout_text(); |
319 } | 319 } |
320 | 320 |
321 void Label::PaintText(gfx::Canvas* canvas, | 321 void Label::PaintText(gfx::Canvas* canvas, |
322 const base::string16& text, | 322 const base::string16& text, |
323 const gfx::Rect& text_bounds, | 323 const gfx::Rect& text_bounds, |
324 int flags) { | 324 int flags) { |
325 gfx::ShadowValues shadows; | 325 gfx::ShadowValues shadows; |
326 if (has_shadow_) | 326 if (has_shadow_) { |
327 shadows.push_back(gfx::ShadowValue(shadow_offset_, shadow_blur_, | 327 shadows.push_back(gfx::ShadowValue(shadow_offset_, shadow_blur_, |
328 enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); | 328 enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); |
329 canvas->DrawStringRectWithShadows(text, font_list_, | 329 } |
330 enabled() ? actual_enabled_color_ : actual_disabled_color_, | 330 SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_; |
331 text_bounds, line_height_, flags, shadows); | 331 canvas->DrawStringRectWithShadows(text, font_list_, color, text_bounds, |
| 332 line_height_, flags, shadows); |
| 333 |
| 334 if (SkColorGetA(halo_color_) != SK_AlphaTRANSPARENT) { |
| 335 canvas->DrawStringRectWithHalo(text, font_list_, color, halo_color_, |
| 336 text_bounds, flags); |
| 337 } |
332 | 338 |
333 if (HasFocus()) { | 339 if (HasFocus()) { |
334 gfx::Rect focus_bounds = text_bounds; | 340 gfx::Rect focus_bounds = text_bounds; |
335 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); | 341 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); |
336 canvas->DrawFocusRect(focus_bounds); | 342 canvas->DrawFocusRect(focus_bounds); |
337 } | 343 } |
338 } | 344 } |
339 | 345 |
340 gfx::Size Label::GetTextSize() const { | 346 gfx::Size Label::GetTextSize() const { |
341 if (!text_size_valid_) { | 347 if (!text_size_valid_) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 is_obscured_ = false; | 399 is_obscured_ = false; |
394 allow_character_break_ = false; | 400 allow_character_break_ = false; |
395 elide_behavior_ = ELIDE_AT_END; | 401 elide_behavior_ = ELIDE_AT_END; |
396 collapse_when_hidden_ = false; | 402 collapse_when_hidden_ = false; |
397 directionality_mode_ = USE_UI_DIRECTIONALITY; | 403 directionality_mode_ = USE_UI_DIRECTIONALITY; |
398 enabled_shadow_color_ = 0; | 404 enabled_shadow_color_ = 0; |
399 disabled_shadow_color_ = 0; | 405 disabled_shadow_color_ = 0; |
400 shadow_offset_.SetPoint(1, 1); | 406 shadow_offset_.SetPoint(1, 1); |
401 has_shadow_ = false; | 407 has_shadow_ = false; |
402 shadow_blur_ = 0; | 408 shadow_blur_ = 0; |
| 409 halo_color_ = SK_ColorTRANSPARENT; |
403 cached_heights_.resize(kCachedSizeLimit); | 410 cached_heights_.resize(kCachedSizeLimit); |
404 ResetCachedSize(); | 411 ResetCachedSize(); |
405 | 412 |
406 SetText(text); | 413 SetText(text); |
407 } | 414 } |
408 | 415 |
409 void Label::RecalculateColors() { | 416 void Label::RecalculateColors() { |
410 actual_enabled_color_ = auto_color_readability_ ? | 417 actual_enabled_color_ = auto_color_readability_ ? |
411 color_utils::GetReadableColor(requested_enabled_color_, | 418 color_utils::GetReadableColor(requested_enabled_color_, |
412 background_color_) : | 419 background_color_) : |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 cached_heights_[i] = gfx::Size(); | 565 cached_heights_[i] = gfx::Size(); |
559 } | 566 } |
560 | 567 |
561 bool Label::ShouldShowDefaultTooltip() const { | 568 bool Label::ShouldShowDefaultTooltip() const { |
562 return !is_multi_line_ && !is_obscured_ && | 569 return !is_multi_line_ && !is_obscured_ && |
563 gfx::GetStringWidth(layout_text(), font_list_) > | 570 gfx::GetStringWidth(layout_text(), font_list_) > |
564 GetAvailableRect().width(); | 571 GetAvailableRect().width(); |
565 } | 572 } |
566 | 573 |
567 } // namespace views | 574 } // namespace views |
OLD | NEW |