Merge "Button SetLabel padding fix" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index da49f13..44e447c 100644 (file)
@@ -20,7 +20,6 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/animation/animation.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
@@ -62,72 +61,104 @@ protected:
    */
   virtual ~PushButton();
 
+public:
+
+  // Properties
+
+  /**
+   * Enum for the alignment modes of the icon.
+   */
+  enum IconAlignment
+  {
+    LEFT,
+    RIGHT,
+    TOP,
+    BOTTOM,
+    DEFAULT = RIGHT
+  };
+
+  /**
+   * 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.
+   */
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+  /**
+   * 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.
+   */
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
 private: // From Button
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
+   * @copydoc Toolkit::Internal::Button::OnButtonInitialize
    */
   virtual void OnButtonInitialize();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnLabelSet()
+   * @copydoc Toolkit::Internal::Button::OnLabelSet
    */
-  virtual void OnLabelSet();
+  virtual void OnLabelSet( bool noPadding );
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnButtonImageSet()
+   * @copydoc Toolkit::Internal::Button::OnButtonImageSet
    */
   virtual void OnButtonImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnSelectedImageSet()
+   * @copydoc Toolkit::Internal::Button::OnSelectedImageSet
    */
   virtual void OnSelectedImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnBackgroundImage()
+   * @copydoc Toolkit::Internal::Button::OnBackgroundImage
    */
   virtual void OnBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet()
+   * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet
    */
   virtual void OnSelectedBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnDisabledImageSet()
+   * @copydoc Toolkit::Internal::Button::OnDisabledImageSet
    */
   virtual void OnDisabledImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
+   * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet
    */
-  virtual void OnDisabledBackgroundImageSet();
+  virtual void OnDisabledSelectedImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnSelected()
+   * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet
    */
-  virtual bool OnSelected();
+  virtual void OnDisabledBackgroundImageSet();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnDisabled()
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
    */
-  virtual bool OnDisabled();
+  virtual void PrepareForTranstionIn( Actor actor );
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnPressed()
+   * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
    */
-  virtual bool OnPressed();
+  virtual void PrepareForTranstionOut( Actor actor );
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnReleased()
+   * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
    */
-  virtual bool OnReleased();
+  virtual void OnTransitionIn( Actor actor );
 
   /**
-   * @copydoc Toolkit::Internal::Button::StopAllAnimations()
+   * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
    */
-  virtual void StopAllAnimations();
+  virtual void OnTransitionOut( Actor actor );
 
 private: // From Control
 
@@ -149,54 +180,83 @@ private: // From Control
 private:
 
   /**
-   * Starts the transition animation.
-   * PushButton::TransitionAnimationFinished slot is called when the animation finishes.
+   * 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 StartTransitionAnimation();
+  void FadeImageTo( Actor actor, float opacity );
 
   /**
-   * Stops the transition animation.
-   * @param[in] remove If true, removes the fadeout actor from root.
+   * @brief Custom configuration for size negotiation
    */
-  void StopTransitionAnimation( bool remove = true );
+  void ConfigureSizeNegotiation();
 
   /**
-   * 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.
-   * @param[in] scale The initial scale.
+   * @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 FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
+  void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
 
   /**
-   * 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[in] scale The initial scale.
+   * @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 FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
+  void SetIcon( DecorationState state, const std::string iconFilename );
 
   /**
-   * @brief Custom configuration for size negotiation
+   * @brief Gets either the selected or unselected icon.
+   *
+   * @param[in] state The icon state to get
+   * @return    The filename of the icon
    */
-  void ConfigureSizeNegotiation();
+  std::string& GetIcon( DecorationState state );
 
   /**
-   * @brief Configure size negotiation for a given dimension
+   * @brief Sets the alignment mode to use to align the icon to the label.
    *
-   * @param[in] dimension The dimension to configure
-   * @param[in] images The list of images to configure
-   * @param[in] label The text label to configure
+   * @param[in] iconAlignment The alignment mode to use
    */
-  void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
+  void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
+
+  /**
+   * @brief Gets the alignment mode used to align the icon to the label.
+   *
+   * @return The alignment mode in use
+   */
+  const PushButton::IconAlignment GetIconAlignment() const;
 
-  // slots
+  /**
+   * @brief Sets the padding for the label.
+   *
+   * @param[in] padding The padding to set
+   */
+  void SetLabelPadding( const Vector4& padding );
+
+  /**
+   * @brief Gets the padding for the label.
+   *
+   * @return The label padding
+   */
+  Vector4 GetLabelPadding();
+
+  /**
+   * @brief Sets the padding for the icon.
+   *
+   * @param[in] padding The padding to set
+   */
+  void SetIconPadding( const Vector4& padding );
 
   /**
-   * Called when the transition animation finishes.
+   * @brief Gets the padding for the icon.
+   *
+   * @return The icon padding
    */
-  void TransitionAnimationFinished( Dali::Animation& source );
+  Vector4 GetIconPadding();
 
 private:
 
@@ -208,8 +268,11 @@ private:
 
 private:
 
-  Animation             mTransitionAnimation;       ///< Animation used in the state transitions.
-  Vector3               mSize;                      ///< The button's size.
+  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