Refactoring Button: remove painter
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.h
index cb5e08c..9d4335a 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/animation/animation.h>
 
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
+#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
 
 #include "button-impl.h"
 
@@ -49,173 +52,95 @@ public:
    */
   static Dali::Toolkit::CheckBoxButton New();
 
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetChecked( bool checked )
-   */
-  void SetChecked( bool checked );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::IsChecked()
-   */
-  bool IsChecked() const;
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Image image )
-   */
-  void SetBackgroundImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Actor image )
-   */
-  void SetBackgroundImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the background image.
-   */
-  Actor& GetBackgroundImage();
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetBackgroundImage()
-   */
-  Actor GetBackgroundImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Image image )
-   */
-  void SetCheckedImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Actor image )
-   */
-  void SetCheckedImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the checked image.
-   */
-  Actor& GetCheckedImage();
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetCheckedImage()
-   */
-  Actor GetCheckedImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledBackgroundImage( Image image )
-   */
-  void SetDisabledBackgroundImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledBackgroundImage( Actor image )
-   */
-  void SetDisabledBackgroundImage( Actor image );
+public: // From Button
 
   /**
-   * Used by the painter only.
-   * @return A reference to the disabled background image.
+   * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
    */
-  Actor& GetDisabledBackgroundImage();
+  virtual void SetSelectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledBackgroundImage()
+   * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
    */
-  Actor GetDisabledBackgroundImage() const;
+  virtual void SetBackgroundImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledCheckedImage( Image image )
+   * @copydoc Toolkit::Internal::Button::SetDisabledSelectedImage( Actor image )
    */
-  void SetDisabledCheckedImage( Image image );
+  virtual void SetDisabledSelectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledCheckedImage( Actor image )
+   * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
    */
-  void SetDisabledCheckedImage( Actor image );
+  virtual void SetDisabledBackgroundImage( Actor image );
 
-  /**
-   * Used by the painter only.
-   * @return A reference to the disabled checked image.
-   */
-  Actor& GetDisabledCheckedImage();
+private: // From Button
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledCheckedImage()
+   * @copydoc Toolkit::Internal::Button::OnLabelSet()
    */
-  Actor GetDisabledCheckedImage() const;
+  virtual void OnLabelSet();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the background image that is fading out.
+   * @copydoc Toolkit::Internal::Button::OnSelected()
    */
-  Actor& GetFadeOutBackgroundImage();
+  virtual void OnSelected( bool selected );
 
   /**
-   * Used by the painter only.
-   * @return A reference to the checked image that is fading out.
+   * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
    */
-  Actor& GetFadeOutCheckedImage();
+  virtual void OnDisabled( bool disabled );
 
-protected: // From Control
+private: // From Control
 
   /**
-   * Respond the activate notification.
+   * @copydoc Dali::Toolkit::Control::OnRelayout()
    */
-  virtual void OnActivated();
+  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
 
 private:
 
   /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
+   * Construct a new CheckBoxButton.
    */
-  void DoClickAction(const PropertyValueContainer& attributes);
+  CheckBoxButton();
 
-public:
   /**
-   * Performs actions as requested using the action name.
-   * @param[in] object The object on which to perform the action.
-   * @param[in] actionName The action to perform.
-   * @param[in] attributes The attributes with which to perfrom this action.
-   * @return true if action has been accepted by this control
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
+  virtual ~CheckBoxButton();
 
-protected: // From Button
+private:
 
   /**
-   * Registers properties
+   * Adds the actor to the button.
    */
-  virtual void OnButtonInitialize();
+  void AddChild( Actor& actor );
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the button is released.
+   * Removes the actor from the button.
    */
-  virtual void OnButtonUp();
+  void RemoveChild( Actor& actor );
 
   /**
-   * Sets the push button animation time.
-   * @param animationTime The animation time in seconds.
+   * Adds the actor to the check in animation.
+   * It creates a check in animation if needed and starts the check in animation.
+   * @param[in] actor The actor.
    */
-  virtual void OnAnimationTimeSet( float animationTime );
+  void StartCheckInAnimation( Actor& actor );
 
   /**
-   * Retrieves the animation time.
-   * @return The animation time in seconds.
+   * Stops the check in animation.
    */
-  virtual float OnAnimationTimeRequested() const;
+  void StopCheckInAnimation();
 
-protected:
+  // slots
 
   /**
-   * Construct a new CheckBoxButton.
+   * Called when the check in animation finishes.
+   * It changes the check button paint state.
    */
-  CheckBoxButton();
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  virtual ~CheckBoxButton();
+  void CheckInAnimationFinished( Dali::Animation& source );
 
 private:
 
@@ -225,19 +150,11 @@ private:
   // Undefined
   CheckBoxButton& operator=( const CheckBoxButton& );
 
-
 private:
-  bool  mChecked;                 ///< Stores the check state.
-
-  Actor mBackgroundImage;         ///< Stores the background image.
-  Actor mCheckedImage;            ///< Stores the checked image.
-  Actor mDisabledCheckedImage;    ///< Stores the disabled checked image.
-  Actor mDisabledBackgroundImage; ///< Stores the disabled background image.
-  Actor mFadeOutBackgroundImage;  ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
-  Actor mFadeOutCheckedImage;     ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
+  Animation                 mCheckInAnimation;  ///< Animation used in the state transitions.
+  ImageRegionEffect         mTickUVEffect;      ///< ImageRegionEffect to expand the tick across
 
-  // Actions
-  bool mClickActionPerforming;
+  PaintState                mPaintState;        ///< The paint state.
 };
 
 } // namespace Internal