// EXTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/button.h>
float GetAnimationTime() const;
/**
- * @copydoc Dali::Toolkit::Button::SetLabel( const std::string& label )
+ * @copydoc Dali::Toolkit::Button::SetLabelText
*/
- void SetLabel( const std::string& label );
+ void SetLabelText( const std::string& label );
/**
- * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
+ * @copydoc Dali::Toolkit::Button::GetLabelText
*/
- void SetLabel( Actor label );
+ std::string GetLabelText() const;
/**
- * @copydoc Dali::Toolkit::Button::GetLabel()
+ * @copydoc Dali::Toolkit::PushButton::SetUnselectedImage
*/
- Actor GetLabel() const;
+ void SetUnselectedImage( const std::string& filename );
/**
- * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+ * @copydoc Dali::Toolkit::PushButton::SetSelectedImage
*/
- void SetButtonImage( Actor image );
+ void SetSelectedImage( const std::string& filename );
/**
- * @copydoc Dali::Toolkit::PushButton::GetButtonImage()
+ * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage
*/
- Actor GetButtonImage() const;
+ void SetBackgroundImage( const std::string& filename );
/**
- * Internal use only.
- * @return A reference to the button image.
+ * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage
*/
- Actor& GetButtonImage();
+ void SetSelectedBackgroundImage( const std::string& filename );
/**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+ * @copydoc Dali::Toolkit::PushButton::SetDisabledImage
*/
- void SetSelectedImage( Actor image );
+ void SetDisabledImage( const std::string& filename );
/**
- * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
+ * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage
*/
- Actor GetSelectedImage() const;
+ void SetDisabledSelectedImage( const std::string& filename );
/**
- * Internal use only.
- * @return A reference to the selected image.
+ * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage
*/
- Actor& GetSelectedImage();
+ void SetDisabledBackgroundImage( const std::string& filename );
/**
- * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+ * @return The filename used for the button image.
*/
- void SetBackgroundImage( Actor image );
+ std::string GetUnselectedImageFilename() const;
/**
- * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+ * @return The filename used for the selected image.
*/
- Actor GetBackgroundImage() const;
+ std::string GetSelectedImageFilename() const;
/**
- * Internal use only.
- * @return A reference to the background image.
+ * @return The filename used for the background image.
*/
- Actor& GetBackgroundImage();
+ std::string GetBackgroundImageFilename() const;
/**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image )
+ * @return The filename used for the selected background image.
*/
- void SetSelectedBackgroundImage( Actor image );
+ std::string GetSelectedBackgroundImageFilename() const;
/**
- * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage()
+ * @return The filename used for the disabled button image.
*/
- Actor GetSelectedBackgroundImage() const;
+ std::string GetDisabledImageFilename() const;
/**
- * Internal use only.
- * @return A reference to the selected background image.
+ * @return The filename used for the disabled selected image.
*/
- Actor& GetSelectedBackgroundImage();
+ std::string GetDisabledSelectedImageFilename() const;
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+ * @return The filename used for the disabled background image.
*/
- void SetDisabledImage( Actor image );
+ std::string GetDisabledBackgroundImageFilename() const;
/**
- * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
+ * 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
*/
- Actor GetDisabledImage() const;
+ static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+
+public: // Deprecated API
/**
- * Internal use only.
- * @return A reference to the disabled button image.
+ * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
*/
- Actor& GetDisabledImage();
+ void SetLabel( Actor label );
/**
- * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+ * @deprecated Sets the unselected image with an Actor.
+ * @param[in] image The Actor to use.
*/
- void SetDisabledSelectedImage( Actor image );
+ void SetButtonImage( Actor image );
/**
- * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
+ * @deprecated Sets the selected image with an Actor.
+ * @param[in] image The Actor to use.
*/
- Actor GetDisabledSelectedImage() const;
+ void SetSelectedImage( Actor image );
/**
- * Internal use only.
- * @return A reference to the disabled selected image.
+ * @deprecated Sets the background image with an Actor.
+ * @param[in] image The Actor to use.
*/
- Actor& GetDisabledSelectedImage();
+ void SetBackgroundImage( Actor image );
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+ * @deprecated Sets the selected background image with an Actor.
+ * @param[in] image The Actor to use.
*/
- void SetDisabledBackgroundImage( Actor image );
+ void SetSelectedBackgroundImage( Actor image );
/**
- * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
+ * @deprecated Sets the disabled image with an Actor.
+ * @param[in] image The Actor to use.
*/
- Actor GetDisabledBackgroundImage() const;
+ void SetDisabledImage( Actor image );
/**
- * Internal use only.
- * @return A reference to the disabled background image.
+ * @deprecated Sets the disabled selected image with an Actor.
+ * @param[in] image The Actor to use.
*/
- Actor& GetDisabledBackgroundImage();
+ void SetDisabledSelectedImage( Actor image );
/**
- * 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
+ * @deprecated Sets the disabled background image with an Actor.
+ * @param[in] image The Actor to use.
+ */
+ void SetDisabledBackgroundImage( Actor image );
+
+ /**
+ * @copydoc Dali::Toolkit::Button::GetButtonImage()
*/
- static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes );
+ Actor GetButtonImage() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Button::GetSelectedImage()
+ */
+ Actor GetSelectedImage() const;
protected:
/**
* @return A reference to the label actor.
*/
- Actor& GetLabel();
+ Actor& GetLabelActor();
+
+ /**
+ * @return A reference to the unselected button image.
+ */
+ Actor& GetUnselectedImage();
+
+ /**
+ * @return A reference to the selected image.
+ */
+ Actor& GetSelectedImage();
+
+ /**
+ * @return A reference to the background image.
+ */
+ Actor& GetBackgroundImage();
/**
- * It changes the transition state of the push button.
+ * @return A reference to the selected background image.
*/
- void UpdatePaintTransitionState();
+ Actor& GetSelectedBackgroundImage();
+
+ /**
+ * @return A reference to the disabled button image.
+ */
+ Actor& GetDisabledImage();
+
+ /**
+ * @return A reference to the disabled selected image.
+ */
+ Actor& GetDisabledSelectedImage();
+
+ /**
+ * @return A reference to the disabled background image.
+ */
+ Actor& GetDisabledBackgroundImage();
private:
/**
* Perform the click action to click the button.
* @param[in] attributes The attributes to perfrom this action.
+ * @return true if this control can perform action.
*/
- void DoClickAction( const PropertyValueContainer& attributes );
+ bool DoClickAction( const Property::Map& attributes );
/**
* This method is called after the button initialization.
/**
* This method is called when the label is set.
+ * @param[in] noPadding Used to bypass padding if the label is to be treated generically.
*/
- virtual void OnLabelSet() {}
+ virtual void OnLabelSet( bool noPadding ) {}
/**
- * This method is called when the button image is set
+ * This method is called when the unselected button image is set
*/
- virtual void OnButtonImageSet() {}
+ virtual void OnUnselectedImageSet() {}
/**
* This method is called when the selected image is set
/**
* This method is called when the \e selected property is changed.
- * @return true if the transition animation is started.
*/
- virtual bool OnSelected() { return false; }
+ virtual void OnSelected() {}
/**
* This method is called when the \e disabled property is changed.
- * @return true if the transition animation is started.
*/
- virtual bool OnDisabled() { return false; }
+ virtual void OnDisabled() {}
/**
* This method is called when the button is pressed.
- * @return true if the transition animation is started.
*/
- virtual bool OnPressed() { return false; }
+ virtual void OnPressed() {}
/**
* This method is called when the button is released.
- * @return true if the transition animation is started.
- */
- virtual bool OnReleased() { return false; }
-
- /**
- * This method stops all animations
*/
- virtual void StopAllAnimations() {}
+ virtual void OnReleased() {}
public:
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnActivated()
+ * @copydoc Toolkit::Control::OnAccessibilityActivated()
+ */
+ virtual bool OnAccessibilityActivated();
+
+ /**
+ * @copydoc Toolkit::Control::OnKeyboardEnter()
*/
- virtual void OnActivated();
+ virtual bool OnKeyboardEnter();
/**
* Callback received when the button is disconnected from the stage.
*/
void Released();
+ /**
+ * Used to perform common setup applied to images within button.
+ * This will replace the current image with the specifed one.
+ * @param[in] actorToModify The image to replace.
+ * @param[out] newActor The new image to use.
+ */
+ void SetupContent( Actor& actorToModify, Actor newActor );
+
+ /**
+ * Sets the color of the unselected image.
+ * If no image exists, it is created.
+ * @param[in] color The color to use.
+ */
+ void SetUnselectedColor( const Vector4& color );
+
+ /**
+ * Gets the unselected content color.
+ * @return The currently used unselected color.
+ */
+ const Vector4 GetUnselectedColor() const;
+
+ /**
+ * Sets the color of the selected image.
+ * If no image exists, it is created.
+ * @param[in] color The color to use.
+ */
+ void SetSelectedColor( const Vector4& color );
+
+ /**
+ * Gets the selected content color.
+ * @return The currently used selected color.
+ */
+ const Vector4 GetSelectedColor() const;
+
protected:
enum ButtonState
SelectedState, ///< The button is selected.
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 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.
- DisabledSelectedTransition ///< The button is in transition from disabled to selected.
+ };
+
+ /**
+ * Enum to specify which decoration when getting and setting decorations.
+ */
+ enum DecorationState
+ {
+ UNSELECTED_DECORATION = 0,
+ SELECTED_DECORATION,
+ DECORATION_STATES
};
ButtonState GetState();
PaintState GetPaintState();
+ void SetDecoration( DecorationState state, Actor actor );
+ Actor& GetDecoration( DecorationState state );
+
+
+ /**
+ * Returns the animation to be used for transitioning creating the animation if needed.
+ * @return The initialised transition animation.
+ */
+ Dali::Animation GetTransitionAnimation();
+
+ /**
+ * Prepares the actor to be transitioned in.
+ * @param[in] actor The actor that will be transitioned in.
+ */
+ virtual void PrepareForTranstionIn( Actor actor ) {}
+
+ /**
+ * Prepares the actor to be transitioned in.
+ * @param[in] actor The actor that will be transitioned out.
+ */
+ virtual void PrepareForTranstionOut( Actor actor ) {}
+
+ /**
+ * Transitions the actor in, allowing derived classes to configure
+ * the GetTransitionAnimation() animation ready.
+ * Button is in charge of calling Dali::Animation::Play and so derived classes
+ * only need to add the animation.
+ */
+ virtual void OnTransitionIn( Actor actor ) {}
+
+ /**
+ * Transitions the actor out, allowing derived classes to configure
+ * the GetTransitionAnimation() animation ready.
+ * Button is in charge of calling Dali::Animation::Play and so derived classes
+ * only need to add the animation.
+ */
+ virtual void OnTransitionOut( Actor actor ) {}
+
+private:
+
+ /**
+ * Starts the transition animation.
+ * Button::TransitionFinished is called when the animation finishes.
+ */
+ void StartTransitionAnimation();
+
+ /**
+ * This method stops all transition animations
+ */
+ void StopTransitionAnimation();
+
+ /**
+ * Called when the transition animation finishes.
+ */
+ void TransitionAnimationFinished( Dali::Animation& source );
/**
- * Inserts the actor to the button.
+ * Resets the Button to the base state for the current paint state.
+ * Any additionally inserted images needed for transitions that are
+ * no longer needed and the removed.
*/
- void InsertChild( unsigned int index, Actor& actor );
+ void ResetImageLayers();
/**
- * Removes the actor from the button.
+ * Transitions out the actor
*/
- void RemoveChild( Actor& actor );
+ void TransitionOut( Actor actor );
+
+ /**
+ * Removes the actor from the button and prepares it to be transitioned out
+ */
+ void RemoveButtonImage( Actor& actor );
/**
* Finds the index of the actor.
*/
unsigned int FindChildIndex( Actor& actor );
-private:
+ /**
+ * Adds an actor to the hierarchy and prepares it to be transitioned.
+ * @param[in] actor The actor to add
+ */
+ void PrepareAddButtonImage( Actor& actor );
+
+ /**
+ * Adds an actor to the hierarchy and marks it to be transitioned.
+ * @param[in] actor The actor to add
+ */
+ void TransitionButtonImage( Actor& actor );
+
+ /**
+ * Adds an actor to the hierarchy.
+ * @param[in] actor The actor to add
+ */
+ void AddButtonImage( Actor& actor );
+
+ /**
+ * (Re)Adds the label (if exists) to the hierarchy (so it is always on top).
+ */
+ void ReAddLabel();
// Undefined
Button( const Button& );
Actor mLabel; ///< Stores the button label.
- Actor mButtonContent; ///< Stores the unselected content.
+ Actor mDecoration[ DECORATION_STATES ]; ///< Stores the decorations for both selected and unselected states.
+
+ Actor mUnselectedContent; ///< Stores the unselected content.
Actor mSelectedContent; ///< Stores the selected content.
Actor mBackgroundContent; ///< Stores the background content.
Actor mSelectedBackgroundContent; ///< Stores the selected background content.
Actor mDisabledSelectedContent; ///< Stores the disabled selected content.
Actor mDisabledBackgroundContent; ///< Stores the disabled background content.
+ Animation mTransitionAnimation; ///< Animation used in the state transitions.
+
TapGestureDetector mTapDetector;
+ Vector4 mUnselectedColor; ///< Color to use for unselected content.
+ Vector4 mSelectedColor; ///< Color to use for selected content.
+
bool mDisabled; ///< Stores the disabled property.
bool mAutoRepeating; ///< Stores the autorepeating property.
bool mTogglableButton; ///< Stores the togglable property.
bool mSelected; ///< Stores the selected state.
float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds.
+
float mAnimationTime; ///< The animation time.
// Actions