From 851d77867958b738d9b587756eaf36c30560c523 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 24 Sep 2014 13:50:15 +0100 Subject: [PATCH] (Buttons) Ensure all button classes are informed when they are disconnected from the stage Change-Id: Id1c720dee217bfd2a81b2647c2a8227351fc3616 --- .../internal/controls/buttons/button-impl.cpp | 9 +++------ .../internal/controls/buttons/button-impl.h | 20 ++++++++++++-------- .../internal/controls/buttons/push-button-impl.cpp | 19 +++++++++++++++++++ .../internal/controls/buttons/push-button-impl.h | 5 +++++ 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/base/dali-toolkit/internal/controls/buttons/button-impl.cpp b/base/dali-toolkit/internal/controls/buttons/button-impl.cpp index f2e4af1..ec78cba 100644 --- a/base/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/base/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -224,13 +224,10 @@ void Button::OnTap(Actor actor, TapGesture tap) // Do nothing. } -void Button::OnStageDisconnection() +void Button::OnControlStageDisconnection() { - if( ButtonUp != mState ) - { - OnTouchPointLeave(); // Notification for derived classes. - mState = ButtonUp; - } + OnButtonStageDisconnection(); // Notification for derived classes. + mState = ButtonUp; } void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) diff --git a/base/dali-toolkit/internal/controls/buttons/button-impl.h b/base/dali-toolkit/internal/controls/buttons/button-impl.h index 441a725..e3763e4 100644 --- a/base/dali-toolkit/internal/controls/buttons/button-impl.h +++ b/base/dali-toolkit/internal/controls/buttons/button-impl.h @@ -130,6 +130,12 @@ private: */ virtual float OnAnimationTimeRequested() const; + /** + * This method is called when the button is removed from the stage. + * Could be reimplemented in subclasses to provide specific behaviour. + */ + virtual void OnButtonStageDisconnection() { } + public: /** @@ -185,6 +191,12 @@ private: // From Control */ virtual void OnControlSizeSet( const Vector3& targetSize ); + /** + * Callback received when the button is disconnected from the stage. + * It resets the button status. + */ + void OnControlStageDisconnection(); + private: /** @@ -199,14 +211,6 @@ private: private: - /** - * Callback received when the button is disconected from the stage. - * It resets the button status. - */ - void OnStageDisconnection(); - -private: - // Undefined Button( const Button& ); diff --git a/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 46159ed..9d758b0 100644 --- a/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -644,6 +644,25 @@ float PushButton::OnAnimationTimeRequested() const return GetPushButtonPainter( mPainter )->GetAnimationTime(); } +void PushButton::OnButtonStageDisconnection() +{ + if( ButtonDown == mState ) + { + if( !mToggleButton ) + { + Toolkit::PushButton handle( GetOwner() ); + + // Notifies the painter the button has been released. + GetPushButtonPainter( mPainter )->Released( handle ); + + if( mAutoRepeating ) + { + mAutoRepeatingTimer.Reset(); + } + } + } +} + PushButton::PushButton() : Button(), mAutoRepeating( false ), diff --git a/base/dali-toolkit/internal/controls/buttons/push-button-impl.h b/base/dali-toolkit/internal/controls/buttons/push-button-impl.h index a6c0b86..b4acfaf 100644 --- a/base/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/base/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -321,6 +321,11 @@ protected: // From Button */ virtual float OnAnimationTimeRequested() const; + /** + * This method is called when the button is removed from the stage. + */ + virtual void OnButtonStageDisconnection(); + protected: // From Control /** -- 2.7.4