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

Side by Side Diff: views/controls/button/custom_button.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 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 unified diff | Download patch
« no previous file with comments | « views/animation/bounds_animator.cc ('k') | views/controls/button/image_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/button/custom_button.h" 5 #include "views/controls/button/custom_button.h"
6 6
7 #include "app/throb_animation.h" 7 #include "app/throb_animation.h"
8 #include "base/keyboard_codes.h" 8 #include "base/keyboard_codes.h"
9 9
10 namespace views { 10 namespace views {
11 11
12 // How long the hover animation takes if uninterrupted. 12 // How long the hover animation takes if uninterrupted.
13 static const int kHoverFadeDurationMs = 150; 13 static const int kHoverFadeDurationMs = 150;
14 14
15 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
16 // CustomButton, public: 16 // CustomButton, public:
17 17
18 CustomButton::~CustomButton() { 18 CustomButton::~CustomButton() {
19 } 19 }
20 20
21 void CustomButton::SetState(ButtonState state) { 21 void CustomButton::SetState(ButtonState state) {
22 if (state != state_) { 22 if (state != state_) {
23 if (animate_on_state_change_ || !hover_animation_->IsAnimating()) { 23 if (animate_on_state_change_ || !hover_animation_->is_animating()) {
24 animate_on_state_change_ = true; 24 animate_on_state_change_ = true;
25 if (state_ == BS_NORMAL && state == BS_HOT) { 25 if (state_ == BS_NORMAL && state == BS_HOT) {
26 // Button is hovered from a normal state, start hover animation. 26 // Button is hovered from a normal state, start hover animation.
27 hover_animation_->Show(); 27 hover_animation_->Show();
28 } else if (state_ == BS_HOT && state == BS_NORMAL) { 28 } else if (state_ == BS_HOT && state == BS_NORMAL) {
29 // Button is returning to a normal state from hover, start hover 29 // Button is returning to a normal state from hover, start hover
30 // fade animation. 30 // fade animation.
31 hover_animation_->Hide(); 31 hover_animation_->Hide();
32 } else { 32 } else {
33 hover_animation_->Stop(); 33 hover_animation_->Stop();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 bool CustomButton::IsHighlighted() const { 248 bool CustomButton::IsHighlighted() const {
249 return state_ == BS_HOT; 249 return state_ == BS_HOT;
250 } 250 }
251 251
252 bool CustomButton::IsPushed() const { 252 bool CustomButton::IsPushed() const {
253 return state_ == BS_PUSHED; 253 return state_ == BS_PUSHED;
254 } 254 }
255 255
256 } // namespace views 256 } // namespace views
OLDNEW
« no previous file with comments | « views/animation/bounds_animator.cc ('k') | views/controls/button/image_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698