diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/custom_button.cc | 8 | ||||
-rw-r--r-- | views/controls/button/custom_button.h | 11 |
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_; |