summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 20:32:50 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 20:32:50 +0000
commite1fe3dafdb3fd61b6fbcff576cb625dcef2a71c2 (patch)
treec44cc0e27bc103d88b1da7a48c6bcaba9ae65526 /views
parent5f449baa69a92ea2ce4f62f5d10732e5c5dfc1ce (diff)
downloadchromium_src-e1fe3dafdb3fd61b6fbcff576cb625dcef2a71c2.zip
chromium_src-e1fe3dafdb3fd61b6fbcff576cb625dcef2a71c2.tar.gz
chromium_src-e1fe3dafdb3fd61b6fbcff576cb625dcef2a71c2.tar.bz2
The start of the instant opt-in mocks.
I also had to make it so you can turn off animations in CustomButton. BUG=54833 TEST=none Review URL: http://codereview.chromium.org/3544015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/custom_button.cc8
-rw-r--r--views/controls/button/custom_button.h11
2 files changed, 14 insertions, 5 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index a1f4e62..ebca6ff 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -23,8 +23,9 @@ void CustomButton::SetState(ButtonState state) {
if (state == state_)
return;
- if (animate_on_state_change_ || !hover_animation_->is_animating()) {
- animate_on_state_change_ = true;
+ if (animate_on_state_change_ &&
+ (!is_throbbing_ || !hover_animation_->is_animating())) {
+ is_throbbing_ = false;
if (state_ == BS_NORMAL && state == BS_HOT) {
// Button is hovered from a normal state, start hover animation.
hover_animation_->Show();
@@ -42,7 +43,7 @@ void CustomButton::SetState(ButtonState state) {
}
void CustomButton::StartThrobbing(int cycles_til_stop) {
- animate_on_state_change_ = false;
+ is_throbbing_ = true;
hover_animation_->StartThrobbing(cycles_til_stop);
}
@@ -109,6 +110,7 @@ CustomButton::CustomButton(ButtonListener* listener)
: Button(listener),
state_(BS_NORMAL),
animate_on_state_change_(true),
+ is_throbbing_(false),
triggerable_event_flags_(MouseEvent::EF_LEFT_BUTTON_DOWN),
request_focus_on_press_(true) {
hover_animation_.reset(new ThrobAnimation(this));
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index f5a1b85..4de3bd6 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -63,6 +63,11 @@ class CustomButton : public Button,
}
bool request_focus_on_press() const { return request_focus_on_press_; }
+ // See description above field.
+ void set_animate_on_state_change(bool value) {
+ animate_on_state_change_ = value;
+ }
+
// Returns true if the mouse pointer is over this control. Note that this
// isn't the same as IsHotTracked() because the mouse may be over the control
// when it's disabled.
@@ -108,10 +113,12 @@ class CustomButton : public Button,
scoped_ptr<ThrobAnimation> hover_animation_;
private:
- // Should we animate when the state changes? Defaults to true, but false while
- // throbbing.
+ // Should we animate when the state changes? Defaults to true.
bool animate_on_state_change_;
+ // Is the hover animation running because StartThrob was invoked?
+ bool is_throbbing_;
+
// Mouse event flags which can trigger button actions.
int triggerable_event_flags_;