OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/drop_shadow_label.h" | 5 #include "chrome/browser/chromeos/drop_shadow_label.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 drop_shadow_size_ = drop_shadow_size; | 22 drop_shadow_size_ = drop_shadow_size; |
23 invalidate_text_size(); | 23 invalidate_text_size(); |
24 SchedulePaint(); | 24 SchedulePaint(); |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 void DropShadowLabel::PaintText(gfx::Canvas* canvas, | 28 void DropShadowLabel::PaintText(gfx::Canvas* canvas, |
29 const string16& text, | 29 const string16& text, |
30 const gfx::Rect& text_bounds, | 30 const gfx::Rect& text_bounds, |
31 int flags) { | 31 int flags) { |
32 SkColor text_color = IsEnabled() ? enabled_color() : disabled_color(); | 32 SkColor text_color = enabled() ? enabled_color() : disabled_color(); |
33 if (drop_shadow_size_ > 0) { | 33 if (drop_shadow_size_ > 0) { |
34 const float kShadowOpacity = 0.2; | 34 const float kShadowOpacity = 0.2; |
35 const SkColor shadow_color = | 35 const SkColor shadow_color = |
36 SkColorSetA(SK_ColorBLACK, kShadowOpacity * SkColorGetA(text_color)); | 36 SkColorSetA(SK_ColorBLACK, kShadowOpacity * SkColorGetA(text_color)); |
37 for (int i = 0; i < drop_shadow_size_; i++) { | 37 for (int i = 0; i < drop_shadow_size_; i++) { |
38 canvas->DrawStringInt(text, font(), shadow_color, | 38 canvas->DrawStringInt(text, font(), shadow_color, |
39 text_bounds.x() + i, text_bounds.y(), | 39 text_bounds.x() + i, text_bounds.y(), |
40 text_bounds.width(), text_bounds.height(), flags); | 40 text_bounds.width(), text_bounds.height(), flags); |
41 canvas->DrawStringInt(text, font(), shadow_color, | 41 canvas->DrawStringInt(text, font(), shadow_color, |
42 text_bounds.x() + i, text_bounds.y() + i, | 42 text_bounds.x() + i, text_bounds.y() + i, |
(...skipping 16 matching lines...) Expand all Loading... |
59 } | 59 } |
60 | 60 |
61 gfx::Size DropShadowLabel::GetTextSize() const { | 61 gfx::Size DropShadowLabel::GetTextSize() const { |
62 gfx::Size text_size = Label::GetTextSize(); | 62 gfx::Size text_size = Label::GetTextSize(); |
63 text_size.SetSize(text_size.width() + drop_shadow_size_, | 63 text_size.SetSize(text_size.width() + drop_shadow_size_, |
64 text_size.height() + drop_shadow_size_); | 64 text_size.height() + drop_shadow_size_); |
65 return text_size; | 65 return text_size; |
66 } | 66 } |
67 | 67 |
68 } // namespace chromeos | 68 } // namespace chromeos |
OLD | NEW |