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

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: 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 fa250ab54b9f80c6b1444d1798163d51d5da0950..7ed50f5a0f61a5970cf64ab555fec0ef8be6ad88 100644
--- a/ui/views/controls/button/text_button.cc
+++ b/ui/views/controls/button/text_button.cc
@@ -119,26 +119,26 @@ TextButtonDefaultBorder::~TextButtonDefaultBorder() {
////////////////////////////////////////////////////////////////////////////////
void TextButtonDefaultBorder::Paint(const View& view, gfx::Canvas* canvas) {
const TextButton* button = static_cast<const TextButton*>(&view);
- int state = button->state();
+ const int state = button->state();
+ const bool animating = button->GetAnimation()->is_animating();
Painter* painter = normal_painter_.get();
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_HOVERED ||
Peter Kasting 2013/05/13 22:40:35 Nit: Please leave in place parens around all binar
ckocagil 2013/05/14 11:28:27 Done.
+ state == TextButton::STATE_PRESSED ||
+ state == TextButton::STATE_NORMAL && animating)) {
Peter Kasting 2013/05/13 22:40:35 Nit: Add a comment about why the animating flag me
ckocagil 2013/05/14 11:28:27 Done.
+ painter = (state == TextButton::STATE_PRESSED) ?
+ pushed_painter_.get() : hot_painter_.get();
}
- if (painter) {
- if (button->GetAnimation()->is_animating()) {
- // TODO(pkasting): Really this should crossfade between states so it could
- // handle the case of having a non-NULL |normal_set_|.
- canvas->SaveLayerAlpha(static_cast<uint8>(
- button->GetAnimation()->CurrentValueBetween(0, 255)));
- painter->Paint(canvas, view.size());
- canvas->Restore();
- } else {
- painter->Paint(canvas, view.size());
- }
+ if (painter && animating) {
Peter Kasting 2013/05/13 22:40:35 Nit: Don't flatten the old nested conditional this
ckocagil 2013/05/14 11:28:27 Done.
+ // TODO(pkasting): Really this should crossfade between states so it could
+ // handle the case of having a non-NULL |normal_set_|.
ckocagil 2013/05/12 16:50:46 There doesn't seem to be a |normal_set_| anymore,
msw 2013/05/12 21:40:36 The TODO is still valid, just rename |normal_set_|
ckocagil 2013/05/14 11:28:27 Done.
+ canvas->SaveLayerAlpha(static_cast<uint8>(
+ button->GetAnimation()->CurrentValueBetween(0, 255)));
+ painter->Paint(canvas, view.size());
+ canvas->Restore();
+ } else if (painter) {
+ 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