Change button rendering
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.h
index f9dee5a..5197aca 100644 (file)
@@ -142,6 +142,11 @@ public:
   Actor GetLabel() const;
 
   /**
+   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+   */
+  void SetButtonImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::PushButton::GetButtonImage()
    */
   Actor GetButtonImage() const;
@@ -153,6 +158,11 @@ public:
   Actor& GetButtonImage();
 
   /**
+   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+   */
+  void SetSelectedImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
    */
   Actor GetSelectedImage() const;
@@ -164,6 +174,11 @@ public:
   Actor& GetSelectedImage();
 
   /**
+   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+   */
+  void SetBackgroundImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
    */
   Actor GetBackgroundImage() const;
@@ -175,6 +190,27 @@ public:
   Actor& GetBackgroundImage();
 
   /**
+   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image )
+   */
+  void SetSelectedBackgroundImage( Actor image );
+
+  /**
+   * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage()
+   */
+  Actor GetSelectedBackgroundImage() const;
+
+  /**
+   * Internal use only.
+   * @return A reference to the selected background image.
+   */
+  Actor& GetSelectedBackgroundImage();
+
+  /**
+   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+   */
+  void SetDisabledImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
    */
   Actor GetDisabledImage() const;
@@ -186,6 +222,11 @@ public:
   Actor& GetDisabledImage();
 
   /**
+   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+   */
+  void SetDisabledSelectedImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
    */
   Actor GetDisabledSelectedImage() const;
@@ -197,6 +238,11 @@ public:
   Actor& GetDisabledSelectedImage();
 
   /**
+   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+   */
+  void SetDisabledBackgroundImage( Actor image );
+
+  /**
    * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
    */
   Actor GetDisabledBackgroundImage() const;
@@ -216,57 +262,71 @@ public:
    */
   static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes );
 
+protected:
+
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+   * @return A reference to the label actor.
    */
-  virtual void SetButtonImage( Actor image ) {}
+  Actor& GetLabel();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+   * It changes the transition state of the push button.
    */
-  virtual void SetSelectedImage( Actor image ) {}
+  void UpdatePaintTransitionState();
+
+private:
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+   * Perform the click action to click the button.
+   * @param[in] attributes The attributes to perfrom this action.
    */
-  virtual void SetBackgroundImage( Actor image ) {}
+  void DoClickAction( const PropertyValueContainer& attributes );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+   * This method is called after the button initialization.
+   * Could be reimplemented in subclasses to provide specific behaviour.
    */
-  virtual void SetDisabledImage( Actor image ) {}
+  virtual void OnButtonInitialize() { }
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+   * This method is called when the label is set.
    */
-  virtual void SetDisabledSelectedImage( Actor image ) {}
+  virtual void OnLabelSet() {}
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+   * This method is called when the button image is set
    */
-  virtual void SetDisabledBackgroundImage( Actor image ) {}
+  virtual void OnButtonImageSet() {}
 
-protected:
+  /**
+   * This method is called when the selected image is set
+   */
+  virtual void OnSelectedImageSet() {}
 
   /**
-   * Internal use only.
-   * @return A reference to the label actor.
+   * This method is called when the background image is set
    */
-  Actor& GetLabel();
+  virtual void OnBackgroundImageSet() {}
 
-private:
+  /**
+   * This method is called when the selected background image is set
+   */
+  virtual void OnSelectedBackgroundImageSet() {}
 
   /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
+   * This method is called when the disabled button image is set
    */
-  void DoClickAction( const PropertyValueContainer& attributes );
+  virtual void OnDisabledImageSet() {}
 
   /**
-   * This method is called after the button initialization.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * This method is called when the disabled selected image is set
    */
-  virtual void OnButtonInitialize() { }
+  virtual void OnDisabledSelectedImageSet() {}
+
+  /**
+   * This method is called when the disabled background image is set
+   */
+  virtual void OnDisabledBackgroundImageSet() {}
 
   /**
    * This method is called from the OnTouchEvent method when the button is down.
@@ -300,34 +360,33 @@ private:
   virtual void OnButtonStageDisconnection();
 
   /**
-   * This method is called when the label is set.
-   */
-  virtual void OnLabelSet() {}
-
-  /**
    * This method is called when the \e selected property is changed.
+   * @return true if the transition animation is started.
    */
-  virtual void OnSelected( bool selected ) {}
+  virtual bool OnSelected() { return false; }
 
   /**
    * This method is called when the \e disabled property is changed.
+   * @return true if the transition animation is started.
    */
-  virtual void OnDisabled( bool disabled ) {}
+  virtual bool OnDisabled() { return false; }
 
   /**
    * This method is called when the button is pressed.
+   * @return true if the transition animation is started.
    */
-  virtual void OnPressed() {}
+  virtual bool OnPressed() { return false; }
 
   /**
    * This method is called when the button is released.
+   * @return true if the transition animation is started.
    */
-  virtual void OnReleased() {}
+  virtual bool OnReleased() { return false; }
 
   /**
-   * This method is called when the button is clicked
+   * This method stops all animations
    */
-  virtual void OnClicked() {}
+  virtual void StopAllAnimations() {}
 
 public:
 
@@ -428,6 +487,23 @@ private:
    */
   bool AutoRepeatingSlot();
 
+  /**
+   * Sets the button as selected or unselected.
+   * @param[in] selected \e selected property value.
+   * @param[in] emitSignal Emit a signal if this value is \e true.
+   */
+  void SetSelected( bool selected, bool emitSignal );
+
+  /**
+   * This method is called when the button is pressed.
+   */
+  void Pressed();
+
+  /**
+   * This method is called when the button is released.
+   */
+  void Released();
+
 protected:
 
   enum ButtonState
@@ -446,7 +522,7 @@ protected:
     DisabledUnselectedState,      ///< The button is disabled and unselected.
     DisabledSelectedState,        ///< The button is disabled and selected.
     UnselectedSelectedTransition, ///< The button is in transition from unselected to selected.
-    SelectedUnselectedTransition, ///< The push button is in transition from selected to unselected.
+    SelectedUnselectedTransition, ///< The button is in transition from selected to unselected.
     UnselectedDisabledTransition, ///< The button is in transition from unselected to disabled.
     DisabledUnselectedTransition, ///< The button is in transition from disabled to unselected.
     SelectedDisabledTransition,   ///< The button is in transition from selected to disabled.
@@ -454,6 +530,23 @@ protected:
   };
 
   ButtonState GetState();
+  PaintState GetPaintState();
+
+  /**
+   * Inserts the actor to the button.
+   */
+  void InsertChild( unsigned int index, Actor& actor );
+
+  /**
+   * Removes the actor from the button.
+   */
+  void RemoveChild( Actor& actor );
+
+  /**
+   * Finds the index of the actor.
+   * If the actor doesn't exist, return the last index + 1.
+   */
+  unsigned int FindChildIndex( Actor& actor );
 
 private:
 
@@ -478,6 +571,7 @@ private:
   Actor mButtonContent;                        ///< Stores the unselected content.
   Actor mSelectedContent;                      ///< Stores the selected content.
   Actor mBackgroundContent;                    ///< Stores the background content.
+  Actor mSelectedBackgroundContent;            ///< Stores the selected background content.
   Actor mDisabledContent;                      ///< Stores the disabled content.
   Actor mDisabledSelectedContent;              ///< Stores the disabled selected content.
   Actor mDisabledBackgroundContent;            ///< Stores the disabled background content.
@@ -496,6 +590,7 @@ private:
   bool             mClickActionPerforming;
 
   ButtonState      mState;                     ///< Stores the button state.
+  PaintState       mPaintState;                ///< Stores the paint state.
 };
 
 } // namespace Internal