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

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

Issue 15111002: Allow STATE_NORMAL text buttons to animate (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 3 Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/text_button.cc
diff --git a/ui/views/controls/button/text_button.cc b/ui/views/controls/button/text_button.cc
index 647e0b0398d873ec4f06a661d5dbbdbc4c7f7d96..81dfe424f5a6cf20018b1cae624b386562bdeffa 100644
--- a/ui/views/controls/button/text_button.cc
+++ b/ui/views/controls/button/text_button.cc
@@ -118,18 +118,24 @@ TextButtonDefaultBorder::~TextButtonDefaultBorder() {
void TextButtonDefaultBorder::Paint(const View& view, gfx::Canvas* canvas) {
const TextButton* button = static_cast<const TextButton*>(&view);
int state = button->state();
+ bool animating = button->GetAnimation()->is_animating();
Painter* painter = normal_painter_.get();
+ // Use the hot painter when we're hovered. Also use the hot painter when we're
+ // STATE_NORMAL and |animating| so that we show throb animations started from
+ // CustomButton::StartThrobbing which should start throbbing the button
+ // regardless of whether it is hovered.
if (button->show_multiple_icon_states() &&
((state == TextButton::STATE_HOVERED) ||
- (state == TextButton::STATE_PRESSED))) {
- painter = (state == TextButton::STATE_HOVERED) ?
- hot_painter_.get() : pushed_painter_.get();
+ (state == TextButton::STATE_PRESSED) ||
+ ((state == TextButton::STATE_NORMAL) && animating))) {
+ painter = (state == TextButton::STATE_PRESSED) ?
+ pushed_painter_.get() : hot_painter_.get();
}
if (painter) {
- if (button->GetAnimation()->is_animating()) {
+ if (animating) {
// TODO(pkasting): Really this should crossfade between states so it could
- // handle the case of having a non-NULL |normal_set_|.
+ // handle the case of having a non-NULL |normal_painter_|.
canvas->SaveLayerAlpha(static_cast<uint8>(
button->GetAnimation()->CurrentValueBetween(0, 255)));
painter->Paint(canvas, view.size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698