(Buttons) Ensure all button classes are informed when they are disconnected from... 27/28027/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 24 Sep 2014 12:50:15 +0000 (13:50 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 24 Sep 2014 14:24:51 +0000 (15:24 +0100)
Change-Id: Id1c720dee217bfd2a81b2647c2a8227351fc3616

base/dali-toolkit/internal/controls/buttons/button-impl.cpp
base/dali-toolkit/internal/controls/buttons/button-impl.h
base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
base/dali-toolkit/internal/controls/buttons/push-button-impl.h

index f2e4af1..ec78cba 100644 (file)
@@ -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 )
index 441a725..e3763e4 100644 (file)
@@ -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& );
 
index 46159ed..9d758b0 100644 (file)
@@ -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 ),
index a6c0b86..b4acfaf 100644 (file)
@@ -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
 
   /**