| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" | |
| 8 #include "gfx/canvas.h" | 7 #include "gfx/canvas.h" |
| 9 #include "gfx/color_utils.h" | 8 #include "gfx/color_utils.h" |
| 10 | 9 |
| 11 using views::Label; | 10 using views::Label; |
| 12 | 11 |
| 13 namespace chromeos { | 12 namespace chromeos { |
| 14 | 13 |
| 15 static const int kDefaultDropShadowSize = 2; | 14 static const int kDefaultDropShadowSize = 2; |
| 16 | 15 |
| 17 // Default color is black. | 16 // Default color is black. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 38 void DropShadowLabel::PaintText(gfx::Canvas* canvas, | 37 void DropShadowLabel::PaintText(gfx::Canvas* canvas, |
| 39 const std::wstring& text, | 38 const std::wstring& text, |
| 40 const gfx::Rect& text_bounds, | 39 const gfx::Rect& text_bounds, |
| 41 int flags) { | 40 int flags) { |
| 42 if (drop_shadow_size_ > 0) { | 41 if (drop_shadow_size_ > 0) { |
| 43 SkColor color = SkColorSetARGB(kShadowOpacity * SkColorGetA(GetColor()), | 42 SkColor color = SkColorSetARGB(kShadowOpacity * SkColorGetA(GetColor()), |
| 44 SkColorGetR(kDefaultColor), | 43 SkColorGetR(kDefaultColor), |
| 45 SkColorGetG(kDefaultColor), | 44 SkColorGetG(kDefaultColor), |
| 46 SkColorGetB(kDefaultColor)); | 45 SkColorGetB(kDefaultColor)); |
| 47 for (int i = 0; i < drop_shadow_size_; i++) { | 46 for (int i = 0; i < drop_shadow_size_; i++) { |
| 48 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, | 47 canvas->DrawStringInt(text, font(), color, |
| 49 text_bounds.x() + i, text_bounds.y(), | 48 text_bounds.x() + i, text_bounds.y(), |
| 50 text_bounds.width(), text_bounds.height(), flags); | 49 text_bounds.width(), text_bounds.height(), flags); |
| 51 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, | 50 canvas->DrawStringInt(text, font(), color, |
| 52 text_bounds.x() + i, text_bounds.y() + i, | 51 text_bounds.x() + i, text_bounds.y() + i, |
| 53 text_bounds.width(), text_bounds.height(), flags); | 52 text_bounds.width(), text_bounds.height(), flags); |
| 54 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, | 53 canvas->DrawStringInt(text, font(), color, |
| 55 text_bounds.x(), text_bounds.y() + i, | 54 text_bounds.x(), text_bounds.y() + i, |
| 56 text_bounds.width(), text_bounds.height(), flags); | 55 text_bounds.width(), text_bounds.height(), flags); |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 | 58 |
| 60 canvas->DrawStringInt(WideToUTF16Hack(text), font(), GetColor(), | 59 canvas->DrawStringInt(text, font(), GetColor(), |
| 61 text_bounds.x(), text_bounds.y(), | 60 text_bounds.x(), text_bounds.y(), |
| 62 text_bounds.width(), text_bounds.height(), flags); | 61 text_bounds.width(), text_bounds.height(), flags); |
| 63 | 62 |
| 64 if (HasFocus() || paint_as_focused()) { | 63 if (HasFocus() || paint_as_focused()) { |
| 65 gfx::Rect focus_bounds = text_bounds; | 64 gfx::Rect focus_bounds = text_bounds; |
| 66 focus_bounds.Inset(-Label::kFocusBorderPadding, | 65 focus_bounds.Inset(-Label::kFocusBorderPadding, |
| 67 -Label::kFocusBorderPadding); | 66 -Label::kFocusBorderPadding); |
| 68 canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(), | 67 canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(), |
| 69 focus_bounds.width(), focus_bounds.height()); | 68 focus_bounds.width(), focus_bounds.height()); |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 gfx::Size DropShadowLabel::GetTextSize() const { | 72 gfx::Size DropShadowLabel::GetTextSize() const { |
| 74 gfx::Size text_size = Label::GetTextSize(); | 73 gfx::Size text_size = Label::GetTextSize(); |
| 75 text_size.SetSize(text_size.width() + drop_shadow_size_, | 74 text_size.SetSize(text_size.width() + drop_shadow_size_, |
| 76 text_size.height() + drop_shadow_size_); | 75 text_size.height() + drop_shadow_size_); |
| 77 return text_size; | 76 return text_size; |
| 78 } | 77 } |
| 79 | 78 |
| 80 } // namespace chromeos | 79 } // namespace chromeos |
| OLD | NEW |