summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 13:35:24 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 13:35:24 +0000
commit19d69b5d79048a3d69f6a0fbc5863eb74e547a5e (patch)
treeeaa6d1790b38ddd72b20f35d4e0aaf33056e1951 /views/controls
parent59d9fd1530bfa4a43eb77ef07a72efa50d554118 (diff)
downloadchromium_src-19d69b5d79048a3d69f6a0fbc5863eb74e547a5e.zip
chromium_src-19d69b5d79048a3d69f6a0fbc5863eb74e547a5e.tar.gz
chromium_src-19d69b5d79048a3d69f6a0fbc5863eb74e547a5e.tar.bz2
Add the ability to have shadowed text to the TextButton, in preparation for the multiprofile menu_button. The color of the shadow should also depend on whether the browser frame is active or inactive, so allow for two different shadow colors.
BUG=74731 TEST=none Review URL: http://codereview.chromium.org/6597118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/text_button.cc33
-rw-r--r--views/controls/button/text_button.h9
2 files changed, 41 insertions, 1 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 812377d..97704c9 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/canvas_skia.h"
#include "views/controls/button/button.h"
#include "views/events/event.h"
+#include "views/widget/widget.h"
#include "grit/app_resources.h"
namespace views {
@@ -194,6 +195,9 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text)
color_hover_(kHoverColor),
text_halo_color_(0),
has_text_halo_(false),
+ active_text_shadow_color_(0),
+ inactive_text_shadow_color_(0),
+ has_shadow_(false),
has_hover_icon_(false),
has_pushed_icon_(false),
max_width_(0),
@@ -257,6 +261,13 @@ void TextButton::SetTextHaloColor(SkColor color) {
has_text_halo_ = true;
}
+void TextButton::SetTextShadowColors(SkColor active_color,
+ SkColor inactive_color) {
+ active_text_shadow_color_ = active_color;
+ inactive_text_shadow_color_ = inactive_color;
+ has_shadow_ = true;
+}
+
void TextButton::ClearMaxTextSize() {
max_text_size_ = text_size_;
}
@@ -338,7 +349,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
// canvas, we can not mirror the button by simply flipping the canvas as
// doing this will mirror the text itself. Flipping the canvas will also
// make the icons look wrong because icons are almost always represented as
- // direction insentisive bitmaps and such bitmaps should never be flipped
+ // direction-insensitive bitmaps and such bitmaps should never be flipped
// horizontally.
//
// Due to the above, we must perform the flipping manually for RTL UIs.
@@ -374,6 +385,26 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
text_, font_, text_color, text_halo_color_,
text_bounds.x(), text_bounds.y(), text_bounds.width(),
text_bounds.height(), draw_string_flags);
+ } else if (has_shadow_) {
+ SkColor shadow_color =
+ GetWidget()->IsActive() ? active_text_shadow_color_ :
+ inactive_text_shadow_color_;
+ canvas->DrawStringInt(text_,
+ font_,
+ shadow_color,
+ text_bounds.x() + 1,
+ text_bounds.y() + 1,
+ text_bounds.width(),
+ text_bounds.height(),
+ draw_string_flags);
+ canvas->DrawStringInt(text_,
+ font_,
+ text_color,
+ text_bounds.x(),
+ text_bounds.y(),
+ text_bounds.width(),
+ text_bounds.height(),
+ draw_string_flags);
} else {
canvas->DrawStringInt(text_,
font_,
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index badf0b4..71fdd9a 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -148,6 +148,10 @@ class TextButton : public CustomButton {
void SetHighlightColor(SkColor color);
void SetHoverColor(SkColor color);
void SetTextHaloColor(SkColor color);
+ // The shadow color used is determined by whether the widget is active or
+ // inactive. Both possible colors are set in this method, and the
+ // appropriate one is chosen during Paint.
+ void SetTextShadowColors(SkColor active_color, SkColor inactive_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.
@@ -217,6 +221,11 @@ class TextButton : public CustomButton {
SkColor text_halo_color_;
bool has_text_halo_;
+ // Optional shadow text colors for active and inactive widget states.
+ SkColor active_text_shadow_color_;
+ SkColor inactive_text_shadow_color_;
+ bool has_shadow_;
+
// An icon displayed with the text.
SkBitmap icon_;