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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 void Label::PaintText(gfx::Canvas* canvas, | 345 void Label::PaintText(gfx::Canvas* canvas, |
346 const base::string16& text, | 346 const base::string16& text, |
347 const gfx::Rect& text_bounds, | 347 const gfx::Rect& text_bounds, |
348 int flags) { | 348 int flags) { |
349 SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_; | 349 SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_; |
350 if (elide_behavior_ == gfx::FADE_TAIL) { | 350 if (elide_behavior_ == gfx::FADE_TAIL && |
| 351 text_bounds.width() < GetTextSize().width()) { |
351 canvas->DrawFadedString(text, font_list_, color, text_bounds, flags); | 352 canvas->DrawFadedString(text, font_list_, color, text_bounds, flags); |
352 } else { | 353 } else { |
353 canvas->DrawStringRectWithShadows(text, font_list_, color, text_bounds, | 354 canvas->DrawStringRectWithShadows(text, font_list_, color, text_bounds, |
354 line_height_, flags, shadows_); | 355 line_height_, flags, shadows_); |
355 } | 356 } |
356 | 357 |
357 if (HasFocus()) { | 358 if (HasFocus()) { |
358 gfx::Rect focus_bounds = text_bounds; | 359 gfx::Rect focus_bounds = text_bounds; |
359 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); | 360 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); |
360 canvas->DrawFocusRect(focus_bounds); | 361 canvas->DrawFocusRect(focus_bounds); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 603 } |
603 | 604 |
604 bool Label::ShouldShowDefaultTooltip() const { | 605 bool Label::ShouldShowDefaultTooltip() const { |
605 const gfx::Size text_size = GetTextSize(); | 606 const gfx::Size text_size = GetTextSize(); |
606 const gfx::Size size = GetContentsBounds().size(); | 607 const gfx::Size size = GetContentsBounds().size(); |
607 return !obscured() && (text_size.width() > size.width() || | 608 return !obscured() && (text_size.width() > size.width() || |
608 (multi_line_ && text_size.height() > size.height())); | 609 (multi_line_ && text_size.height() > size.height())); |
609 } | 610 } |
610 | 611 |
611 } // namespace views | 612 } // namespace views |
OLD | NEW |