diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-18 17:45:01 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-18 17:45:01 +0000 |
commit | 37edba0810da1caae3ba493531e00834224c4cad (patch) | |
tree | a20fa46327ccf617150857e7b2f8d1228b0320e3 /views | |
parent | 65d52b9b218a016bb62067b3d495d430a7d4b3af (diff) | |
download | chromium_src-37edba0810da1caae3ba493531e00834224c4cad.zip chromium_src-37edba0810da1caae3ba493531e00834224c4cad.tar.gz chromium_src-37edba0810da1caae3ba493531e00834224c4cad.tar.bz2 |
Add 1px black border for ChromeOS status button.
- Move Linux's CanvasSkia::DrawStringInt into DrawStringWithHalo and
added code to support text halo and change DrawStringInt to use it;
- Make views::TextButton support text halo;
- Use the text halo for chromeos::StatusButton;
BUG=chromium-os:8657
TEST=Verify 1px black border is added to ChromeOS status buttons.
Review URL: http://codereview.chromium.org/5071002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/text_button.cc | 19 | ||||
-rw-r--r-- | views/controls/button/text_button.h | 5 |
2 files changed, 24 insertions, 0 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index e64d3dc..f758910 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -190,6 +190,8 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text) color_disabled_(kDisabledColor), color_highlight_(kHighlightColor), color_hover_(kHoverColor), + text_halo_color_(0), + has_text_halo_(false), has_hover_icon_(false), has_pushed_icon_(false), max_width_(0), @@ -248,6 +250,11 @@ void TextButton::SetHoverColor(SkColor color) { color_hover_ = color; } +void TextButton::SetTextHaloColor(SkColor color) { + text_halo_color_ = color; + has_text_halo_ = true; +} + void TextButton::ClearMaxTextSize() { max_text_size_ = text_size_; } @@ -360,6 +367,11 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { text_bounds.height(), draw_string_flags); #endif + } else if (has_text_halo_) { + canvas->AsCanvasSkia()->DrawStringWithHalo( + text_, font_, text_color, text_halo_color_, text_bounds.x(), + text_bounds.y(), text_bounds.width(), text_bounds.height(), + draw_string_flags); } else { canvas->DrawStringInt(text_, font_, @@ -391,6 +403,13 @@ void TextButton::UpdateTextSize() { gfx::CanvasSkia::SizeStringInt( text_, font_, &width, &height, gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_)); + + // Add 2 extra pixels to width and height when text halo is used. + if (has_text_halo_) { + width += 2; + height += 2; + } + text_size_.SetSize(width, font_.GetHeight()); max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()), std::max(max_text_size_.height(), diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h index 7e204d4..fc821f4 100644 --- a/views/controls/button/text_button.h +++ b/views/controls/button/text_button.h @@ -142,6 +142,7 @@ class TextButton : public CustomButton { void SetDisabledColor(SkColor color); void SetHighlightColor(SkColor color); void SetHoverColor(SkColor color); + void SetTextHaloColor(SkColor color); void SetNormalHasBorder(bool normal_has_border); // Sets whether or not to show the hot and pushed states for the button icon // (if present) in addition to the normal state. Defaults to true. @@ -207,6 +208,10 @@ class TextButton : public CustomButton { SkColor color_highlight_; SkColor color_hover_; + // An optional halo around text. + SkColor text_halo_color_; + bool has_text_halo_; + // An icon displayed with the text. SkBitmap icon_; |