Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: views/controls/button/text_button.cc

Issue 3058011: Add "pushed" as a state a TextButton can show (alongside "normal" and "hover"... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« views/controls/button/text_button.h ('K') | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/text_button.cc
===================================================================
--- views/controls/button/text_button.cc (revision 53742)
+++ views/controls/button/text_button.cc (working copy)
@@ -188,9 +188,10 @@
color_highlight_(kHighlightColor),
color_hover_(kHoverColor),
has_hover_icon_(false),
+ has_pushed_icon_(false),
max_width_(0),
normal_has_border_(false),
- show_highlighted_(true),
+ show_multiple_states_(true),
prefix_type_(PREFIX_NONE) {
SetText(text);
set_border(new TextButtonBorder);
@@ -214,6 +215,11 @@
has_hover_icon_ = true;
}
+void TextButton::SetPushedIcon(const SkBitmap& icon) {
+ icon_pushed_ = icon;
+ has_pushed_icon_ = true;
+}
+
void TextButton::SetFont(const gfx::Font& font) {
font_ = font;
UpdateTextSize();
@@ -245,15 +251,15 @@
normal_has_border_ = normal_has_border;
}
-void TextButton::SetShowHighlighted(bool show_highlighted) {
- show_highlighted_ = show_highlighted;
+void TextButton::SetShowMultipleStates(bool show_multiple_states) {
+ show_multiple_states_ = show_multiple_states;
}
void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
if (!for_drag) {
PaintBackground(canvas);
- if (show_highlighted_ && hover_animation_->is_animating()) {
+ if (show_multiple_states_ && hover_animation_->is_animating()) {
// Draw the hover bitmap into an offscreen buffer, then blend it
// back into the current canvas.
canvas->SaveLayerAlpha(
@@ -262,7 +268,7 @@
SkXfermode::kClear_Mode);
PaintBorder(canvas);
canvas->Restore();
- } else if ((show_highlighted_ &&
+ } else if ((show_multiple_states_ &&
(state_ == BS_HOT || state_ == BS_PUSHED)) ||
(state_ == BS_NORMAL && normal_has_border_)) {
PaintBorder(canvas);
@@ -272,9 +278,10 @@
}
SkBitmap icon;
- if (has_hover_icon_ && show_highlighted_ &&
- (state() == BS_HOT || state() == BS_PUSHED))
+ if (show_multiple_states_ && has_hover_icon_ && (state() == BS_HOT))
icon = icon_hover_;
+ else if (show_multiple_states_ && has_pushed_icon_ && (state() == BS_PUSHED))
+ icon = icon_pushed_;
else
icon = icon_;
@@ -325,7 +332,7 @@
text_bounds.set_x(MirroredLeftPointForRect(text_bounds));
SkColor text_color;
- if (show_highlighted_ && (state() == BS_HOT || state() == BS_PUSHED))
+ if (show_multiple_states_ && (state() == BS_HOT || state() == BS_PUSHED))
text_color = color_hover_;
else
text_color = color_;
« views/controls/button/text_button.h ('K') | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698