*/
// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
*/
static Dali::Toolkit::PushButton New();
- /**
- * @copydoc Dali::Toolkit::PushButton::SetAutoRepeating( bool autoRepeating )
- */
- void SetAutoRepeating( bool autoRepeating );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::IsAutoRepeating() const
- */
- bool IsAutoRepeating() const;
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
- */
- void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::GetInitialAutoRepeatingDelay() const
- */
- float GetInitialAutoRepeatingDelay() const;
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
- */
- void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::GetNextAutoRepeatingDelay() const
- */
- float GetNextAutoRepeatingDelay() const;
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetToggleButton( bool toggle )
- */
- void SetToggleButton( bool toggle );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::IsToggleButton() const
- */
- bool IsToggleButton() const;
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetToggled( bool toggle )
- */
- void SetToggled( bool toggle );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::IsToggled() const
- */
- bool IsToggled() const;
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetButtonImage( const Image image )
- */
- void SetButtonImage( Image image );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
- */
- void SetButtonImage( Actor image );
-
- /**
- * Used by the painter only.
- * @return A reference to the button image.
- */
- Actor& GetButtonImage();
-
- /**
- * @copydoc Dali::Toolkit::PushButton::
- */
- Actor GetButtonImage() const;
+protected:
/**
- * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( const Image image )
+ * Construct a new PushButton.
*/
- void SetBackgroundImage( Image image );
+ PushButton();
/**
- * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+ * A reference counted object may only be deleted by calling Unreference()
*/
- void SetBackgroundImage( Actor image );
+ virtual ~PushButton();
- /**
- * Used by the painter only.
- * @return A reference to the background image.
- */
- Actor& GetBackgroundImage();
+public: // From Button
/**
- * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+ * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
*/
- Actor GetBackgroundImage() const;
+ virtual void SetButtonImage( Actor image );
/**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( const Image image )
+ * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
*/
- void SetSelectedImage( Image image );
+ virtual void SetSelectedImage( Actor image );
/**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
*/
- void SetSelectedImage( Actor image );
+ virtual void SetBackgroundImage( Actor image );
/**
- * Used by the painter only.
- * @return A reference to the selected image.
+ * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image )
*/
- Actor& GetSelectedImage();
+ virtual void SetDisabledImage( Actor image );
/**
- * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
+ * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
*/
- Actor GetSelectedImage() const;
+ virtual void SetDisabledBackgroundImage( Actor image );
- /**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Image image )
- */
- void SetDisabledBackgroundImage( Image image );
+private: // From Button
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
*/
- void SetDisabledBackgroundImage( Actor image );
+ virtual void OnButtonInitialize();
/**
- * Used by the painter only.
- * @return A reference to the disabled background image.
+ * @copydoc Toolkit::Internal::Button::OnLabelSet()
*/
- Actor& GetDisabledBackgroundImage();
+ virtual void OnLabelSet();
/**
- * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
+ * @copydoc Toolkit::Internal::Button::OnSelected()
*/
- Actor GetDisabledBackgroundImage() const;
+ virtual void OnSelected( bool selected );
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Image image )
+ * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
*/
- void SetDisabledImage( Image image );
+ virtual void OnDisabled( bool disabled );
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnPressed()
*/
- void SetDisabledImage( Actor image );
+ virtual void OnPressed();
/**
- * Used by the painter only.
- * @return A reference to the disabled button image.
+ * @copydoc Toolkit::Internal::Button::OnReleased()
*/
- Actor& GetDisabledImage();
+ virtual void OnReleased();
/**
- * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
+ * @copydoc Toolkit::Internal::Button::OnClicked()
*/
- Actor GetDisabledImage() const;
+ virtual void OnClicked();
- /**
- * @copydoc Dali::Toolkit::PushButton::SetLabel( const std::string& label )
- */
- void SetLabel( const std::string& label );
+private: // From Control
/**
- * @copydoc Dali::Toolkit::PushButton::SetLabel( Actor label )
+ * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
*/
- void SetLabel( Actor label );
+ virtual void OnControlSizeSet( const Vector3& targetSize );
/**
- * @copydoc Dali::Toolkit::PushButton::GetLabel()
+ * @copydoc Toolkit::Control::GetNaturalSize()
*/
- Actor GetLabel() const;
+ virtual Vector3 GetNaturalSize();
- /**
- * Used by the painter only.
- * @return A reference to the label actor.
- */
- Actor& GetLabel();
+private:
/**
- * Used by the painter only.
- * @return A reference to the background image that is fading out.
+ * Used in the FadeOut functions.
*/
- Actor& GetFadeOutBackgroundImage();
+ enum ImageLayer
+ {
+ Background, ///< Fade out the background.
+ Foreground ///< Fade out the foreground.
+ };
/**
- * Used by the painter only.
+ * Gets the button image that is fading out.
* @return A reference to the button image that is fading out.
*/
Actor& GetFadeOutButtonImage();
-public:
-
- // Signals
-
- /**
- * @copydoc Dali::Toolkit::PushButton::PressedSignal()
- */
- Toolkit::PushButton::PressedSignalType& PressedSignal();
-
- /**
- * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
- */
- Toolkit::PushButton::ReleasedSignalType& ReleasedSignal();
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
- // Properties
-
- /**
- * @copydoc Button::SetProperty
- */
- static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
-
- /**
- * @copydoc Button::GetProperty
- */
- static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-
-protected: // From Button
-
- /**
- * Sets the Leave signal.
- */
- virtual void OnButtonInitialize();
-
- /**
- * Emits signals and notifies the painter accordingly with the set button
- * properties when the button is pressed.
- */
- virtual void OnButtonDown();
-
/**
- * Emits signals and notifies the painter accordingly with the set button
- * properties when the button is released.
+ * Gets the background image that is fading out.
+ * @return A reference to the background image that is fading out.
*/
- virtual void OnButtonUp();
+ Actor& GetFadeOutBackgroundImage();
/**
- * Emits signals and notifies the painter accordingly with the set button
- * properties when the touch point leaves the boundary of the button.
+ * Adds the actor to the fade in animation. It creates a fade in animation if needed.
+ * @param[in] actor The actor.
*/
- virtual void OnTouchPointLeave();
+ void AddToFadeInAnimation( Actor& actor );
/**
- * Currently it doesn't need different behaviour than @see OnTouchPointLeave()
+ * Starts the fade in animation.
+ * PushButton::FadeInAnimationFinished slot is called when the animation finishes.
*/
- virtual void OnTouchPointInterrupted();
+ void StartFadeInAnimation();
/**
- * Sets the push button animation time.
- * @param animationTime The animation time in seconds.
+ * Stops the fade in animation.
*/
- virtual void OnAnimationTimeSet( float animationTime );
+ void StopFadeInAnimation();
/**
- * Retrieves the animation time.
- * @return The animation time in seconds.
+ * Adds the actor to the fade out animation. It creates a fade out animation if needed.
*/
- virtual float OnAnimationTimeRequested() const;
+ void AddToFadeOutAnimation( Actor& actor );
/**
- * This method is called when the button is removed from the stage.
+ * Starts the fade out animation.
+ * PushButton::FadeOutAnimationFinished slot is called when the animation finishes.
*/
- virtual void OnButtonStageDisconnection();
-
-protected: // From Control
+ void StartFadeOutAnimation();
/**
- * Respond the activate notification.
+ * 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.
*/
- virtual void OnActivated();
+ void StopFadeOutAnimation( bool remove = true );
/**
- * @copydoc Control::GetNaturalSize()
+ * 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.
*/
- virtual Vector3 GetNaturalSize();
-
-private:
+ void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
/**
- * Perform the click action to click the button.
- * @param[in] attributes The attributes to perfrom this action.
+ * 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.
*/
- void DoClickAction(const PropertyValueContainer& attributes);
+ void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f );
-public:
+ // slots
/**
- * 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
+ * Called when the fade out animation finishes.
+ * It changes the check button paint state and removes actors from the root.
*/
- static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
+ void FadeOutAnimationFinished( Dali::Animation& source );
/**
- * Construct a new PushButton.
+ * Called when the fade in animation finishes.
+ * It changes the check button paint state.
*/
- PushButton();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~PushButton();
+ void FadeInAnimationFinished( Dali::Animation& source );
private:
// Undefined
PushButton& operator=( const PushButton& );
- /**
- * Sets up the autorepeating timer.
- * @param[in] delay The delay time in seconds.
- */
- void SetUpTimer( float delay );
-
- /**
- * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
- */
- bool AutoRepeatingSlot();
-
private:
- bool mAutoRepeating; ///< Stores the autorepeating property.
- float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
- float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds.
- bool mToggleButton; ///< Stores the toggle property.
-
- // AutoRepeating
- Timer mAutoRepeatingTimer; ///< Timer used to implement the autorepeating property.
-
- // Toggle
- bool mToggled; ///< Stores the toggle state.
-
- // Signals
- Toolkit::PushButton::PressedSignalType mPressedSignal; ///< Signal emitted when the button is pressed.
- Toolkit::PushButton::ReleasedSignalType mReleasedSignal; ///< Signal emitted when the button is released.
- Actor mButtonImage; ///< Stores the unselected image.
- Actor mBackgroundImage; ///< Stores the background image.
- Actor mSelectedImage; ///< Stores the selected image.
- Actor mDisabledImage; ///< Stores the disabled image.
- Actor mDisabledBackgroundImage; ///< Stores the disabled background image.
+ Animation mFadeInAnimation; ///< Animation used in the state transitions.
+ Animation mFadeOutAnimation; ///< Animation used in the state transitions.
- Actor mLabel; ///< Stores the text label.
+ 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.
- Actor mFadeOutBackgroundImage; ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
- Actor mFadeOutButtonImage; ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
+ Vector3 mSize; ///< The button's size.
- // Actions
- bool mClickActionPerforming;
+ PaintState mPaintState; ///< The paint state.
};
} // namespace Internal