Merge "Multi-line layout." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index cee57f6..f1925a3 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,32 +61,37 @@ protected:
    */
   virtual ~PushButton();
 
-public: // From Button
+public:
 
-  /**
-   * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
-   */
-  virtual void SetButtonImage( Actor image );
+  // Properties
 
   /**
-   * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
+   * Enum for the alignment modes of the icon.
    */
-  virtual void SetSelectedImage( Actor image );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
-   */
-  virtual void SetBackgroundImage( Actor image );
+  enum IconAlignment
+  {
+    LEFT,
+    RIGHT,
+    TOP,
+    BOTTOM,
+    DEFAULT = RIGHT
+  };
 
   /**
-   * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image )
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
    */
-  virtual void SetDisabledImage( Actor image );
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
 
   /**
-   * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
    */
-  virtual void SetDisabledBackgroundImage( Actor image );
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
 
 private: // From Button
 
@@ -102,128 +106,157 @@ 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();
+  virtual void OnDisabledImageSet();
 
-private: // From Control
+  /**
+   * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet()
+   */
+  virtual void OnDisabledSelectedImageSet();
 
   /**
-   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
    */
-  virtual void OnControlSizeSet( const Vector3& targetSize );
+  virtual void OnDisabledBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Control::GetNaturalSize()
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
    */
-  virtual Vector3 GetNaturalSize();
+  virtual void PrepareForTranstionIn( Actor actor );
 
-private:
+  /**
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
+   */
+  virtual void PrepareForTranstionOut( Actor actor );
 
   /**
-   * Used in the FadeOut functions.
+   * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
    */
-  enum ImageLayer
-  {
-    Background, ///< Fade out the background.
-    Foreground  ///< Fade out the foreground.
-  };
+  virtual void OnTransitionIn( 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::OnTransitionOut( Actor actor )
    */
-  Actor& GetFadeOutButtonImage();
+  virtual void OnTransitionOut( Actor actor );
+
+private: // From Control
 
   /**
-   * Gets the background image that is fading out.
-   * @return A reference to the background image that is fading out.
+   * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
    */
-  Actor& GetFadeOutBackgroundImage();
+  virtual void OnSizeSet( const Vector3& targetSize );
 
   /**
-   * Adds the actor to the fade in animation. It creates a fade in animation if needed.
-   * @param[in] actor The actor.
+   * @copydoc Toolkit::Control::GetNaturalSize
    */
-  void AddToFadeInAnimation( Actor& actor );
+  virtual Vector3 GetNaturalSize();
 
   /**
-   * Starts the fade in animation.
-   * PushButton::FadeInAnimationFinished slot is called when the animation finishes.
+   * @copydoc Toolkit::Control::OnSetResizePolicy
    */
-  void StartFadeInAnimation();
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
+
+private:
 
   /**
-   * Stops the fade in animation.
+   * It adds the actor to the root actor and to the fade in animation.
+   * @param[inout] actor The actor.
+   * @param[in] opacity The opacity to fade to
    */
-  void StopFadeInAnimation();
+  void FadeImageTo( Actor actor, float opacity );
 
   /**
-   * Adds the actor to the fade out animation. It creates a fade out animation if needed.
+   * @brief Custom configuration for size negotiation
    */
-  void AddToFadeOutAnimation( Actor& actor );
+  void ConfigureSizeNegotiation();
 
   /**
-   * Starts the fade out animation.
-   * PushButton::FadeOutAnimationFinished slot is called when the animation finishes.
+   * @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 StartFadeOutAnimation();
+  void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
 
   /**
-   * 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.
+   * @brief Sets either the selected or unselected icon.
+   *
+   * @param[in] state The icon state to set
+   * @param[in] iconFilename The filename of the icon
    */
-  void StopFadeOutAnimation( bool remove = true );
+  void SetIcon( DecorationState state, const std::string iconFilename );
 
   /**
-   * 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.
+   * @brief Gets either the selected or unselected icon.
+   *
+   * @param[in] state The icon state to get
+   * @return    The filename of the icon
    */
-  void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
+  std::string& GetIcon( DecorationState state );
 
   /**
-   * 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.
+   * @brief Sets the alignment mode to use to align the icon to the label.
+   *
+   * @param[in] iconAlignment The alignment mode to use
    */
-  void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f );
+  void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
 
-  // slots
+  /**
+   * @brief Gets the alignment mode used to align the icon to the label.
+   *
+   * @return The alignment mode in use
+   */
+  const PushButton::IconAlignment GetIconAlignment() const;
 
   /**
-   * Called when the fade out animation finishes.
-   * It changes the check button paint state and removes actors from the root.
+   * @brief Sets the padding for the label.
+   *
+   * @param[in] padding The padding to set
    */
-  void FadeOutAnimationFinished( Dali::Animation& source );
+  void SetLabelPadding( const Vector4& padding );
 
   /**
-   * Called when the fade in animation finishes.
-   * It changes the check button paint state.
+   * @brief Gets the padding for the label.
+   *
+   * @return The label padding
    */
-  void FadeInAnimationFinished( Dali::Animation& source );
+  Vector4 GetLabelPadding();
+
+  /**
+   * @brief Sets the padding for the icon.
+   *
+   * @param[in] padding The padding to set
+   */
+  void SetIconPadding( const Vector4& padding );
+
+  /**
+   * @brief Gets the padding for the icon.
+   *
+   * @return The icon padding
+   */
+  Vector4 GetIconPadding();
 
 private:
 
@@ -235,15 +268,11 @@ 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.
+  std::string    mIconName[ DECORATION_STATES ]; ///< The original filenames for the icons.
+  Padding        mLabelPadding;                  ///< The padding around the label (if present).
+  Padding        mIconPadding;                   ///< The padding around the icon (if present).
+  IconAlignment  mIconAlignment;                 ///< The alignment of the icon against the label.
+  Vector3        mSize;                          ///< The button's size.
 };
 
 } // namespace Internal