Refactored Button and derived classes, moving state change and transition logic to...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index 89bce4b..51164b5 100644 (file)
@@ -19,8 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/vector-wrapper.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
@@ -62,33 +61,6 @@ protected:
    */
   virtual ~PushButton();
 
-public: // From Button
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
-   */
-  virtual void SetButtonImage( Actor image );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
-   */
-  virtual void SetSelectedImage( Actor image );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
-   */
-  virtual void SetBackgroundImage( Actor image );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image )
-   */
-  virtual void SetDisabledImage( Actor image );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
-   */
-  virtual void SetDisabledBackgroundImage( Actor image );
-
 private: // From Button
 
   /**
@@ -102,128 +74,99 @@ private: // From Button
   virtual void OnLabelSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnSelected()
+   * @copydoc Toolkit::Internal::Button::OnButtonImageSet()
    */
-  virtual void OnSelected( bool selected );
+  virtual void OnButtonImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
+   * @copydoc Toolkit::Internal::Button::OnSelectedImageSet()
    */
-  virtual void OnDisabled( bool disabled );
+  virtual void OnSelectedImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnPressed()
+   * @copydoc Toolkit::Internal::Button::OnBackgroundImage()
    */
-  virtual void OnPressed();
+  virtual void OnBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnReleased()
+   * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet()
    */
-  virtual void OnReleased();
+  virtual void OnSelectedBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnClicked()
+   * @copydoc Toolkit::Internal::Button::OnDisabledImageSet()
    */
-  virtual void OnClicked();
-
-private: // From Control
+  virtual void OnDisabledImageSet();
 
   /**
-   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet()
    */
-  virtual void OnControlSizeSet( const Vector3& targetSize );
+  virtual void OnDisabledSelectedImageSet();
 
   /**
-   * @copydoc Toolkit::Control::GetNaturalSize()
+   * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
    */
-  virtual Vector3 GetNaturalSize();
-
-private:
+  virtual void OnDisabledBackgroundImageSet();
 
   /**
-   * Used in the FadeOut functions.
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
    */
-  enum ImageLayer
-  {
-    Background, ///< Fade out the background.
-    Foreground  ///< Fade out the foreground.
-  };
+  virtual void PrepareForTranstionIn( Actor actor );
 
   /**
-   * Gets the button image that is fading out.
-   * @return A reference to the button image that is fading out.
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
    */
-  Actor& GetFadeOutButtonImage();
+  virtual void PrepareForTranstionOut( Actor actor );
 
   /**
-   * Gets the background image that is fading out.
-   * @return A reference to the background image that is fading out.
+   * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
    */
-  Actor& GetFadeOutBackgroundImage();
+  virtual void OnTransitionIn( Actor actor );
 
   /**
-   * Adds the actor to the fade in animation. It creates a fade in animation if needed.
-   * @param[in] actor The actor.
+   * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
    */
-  void AddToFadeInAnimation( const Actor& actor );
+  virtual void OnTransitionOut( Actor actor );
 
-  /**
-   * Starts the fade in animation.
-   * PushButton::FadeInAnimationFinished slot is called when the animation finishes.
-   */
-  void StartFadeInAnimation();
+private: // From Control
 
   /**
-   * Stops the fade in animation.
+   * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
    */
-  void StopFadeInAnimation();
+  virtual void OnSizeSet( const Vector3& targetSize );
 
   /**
-   * Adds the actor to the fade out animation. It creates a fade out animation if needed.
+   * @copydoc Toolkit::Control::GetNaturalSize
    */
-  void AddToFadeOutAnimation( const Actor& actor );
+  virtual Vector3 GetNaturalSize();
 
   /**
-   * Starts the fade out animation.
-   * PushButton::FadeOutAnimationFinished slot is called when the animation finishes.
+   * @copydoc Toolkit::Control::OnSetResizePolicy
    */
-  void StartFadeOutAnimation();
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
 
-  /**
-   * Stops the fade out animation.
-   * It removes the actor stored in PushButton::mFadeOutBackgroundImage and PushButton::mFadeOutCheckedImage.
-   * @param[in] remove If true, removes the fadeout actor from root.
-   */
-  void StopFadeOutAnimation( bool remove = true );
+private:
 
   /**
    * It adds the actor to the root actor and to the fade in animation.
-   * @param[inout] image The actor.
-   * @param[in] opacity The initial opacity.
-   */
-  void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
-
-  /**
-   * It adds the actor fade out animation and stores it to be removed when the animation finishes.
-   * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
-   * @param[inout] image The actor.
-   * @param[in] opacity The initial opacity.
+   * @param[inout] actor The actor.
+   * @param[in] opacity The opacity to fade to
    */
-  void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f );
-
-  // slots
+  void FadeImageTo( Actor actor, float opacity );
 
   /**
-   * Called when the fade out animation finishes.
-   * It changes the check button paint state and removes actors from the root.
+   * @brief Custom configuration for size negotiation
    */
-  void FadeOutAnimationFinished( Dali::Animation& source );
+  void ConfigureSizeNegotiation();
 
   /**
-   * Called when the fade in animation finishes.
-   * It changes the check button paint state.
+   * @brief Configure size negotiation for a given dimension
+   *
+   * @param[in] dimension The dimension to configure
+   * @param[in] images The list of images to configure
+   * @param[in] label The text label to configure
    */
-  void FadeInAnimationFinished( Dali::Animation& source );
+  void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
 
 private:
 
@@ -235,15 +178,7 @@ private:
 
 private:
 
-  Animation             mFadeInAnimation;           ///< Animation used in the state transitions.
-  Animation             mFadeOutAnimation;          ///< Animation used in the state transitions.
-
-  Actor                 mFadeOutButtonContent;      ///< Stores a foreground content, which is in a fade out animation, to be removed when the animation finishes.
-  Actor                 mFadeOutBackgroundContent;  ///< Stores a background content, which is in a fade out animation, to be removed when the animation finishes.
-
   Vector3               mSize;                      ///< The button's size.
-
-  PaintState            mPaintState;                ///< The paint state.
 };
 
 } // namespace Internal