X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fbutton-impl.h;h=2ff121d219a15a4a6f2bfcc6784fcecd301e2a59;hp=5197acadbd4a5002ca7453828d193346e6454558;hb=e9d852fcdacc5788785bfe0b617bd757794e8208;hpb=56d412791a44c2a79135d2293c13fddb135c9d54 diff --git a/dali-toolkit/internal/controls/buttons/button-impl.h b/dali-toolkit/internal/controls/buttons/button-impl.h index 5197aca..2ff121d 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.h +++ b/dali-toolkit/internal/controls/buttons/button-impl.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -57,230 +58,281 @@ protected: public: /** - * @copydoc Dali::Toolkit::Button::SetDisabled( bool disabled ) + * @copydoc Dali::Toolkit::Button::SetDisabled */ void SetDisabled( bool disabled ); /** - * @copydoc Dali::Toolkit::Button::IsDisabled() const + * @copydoc Dali::Toolkit::Button::IsDisabled */ bool IsDisabled() const; /** - * @copydoc Dali::Toolkit::Button::SetAutoRepeating( bool autoRepeating ) + * @copydoc Dali::Toolkit::Button::SetAutoRepeating */ void SetAutoRepeating( bool autoRepeating ); /** - * @copydoc Dali::Toolkit::Button::IsAutoRepeating() const + * @copydoc Dali::Toolkit::Button::IsAutoRepeating */ bool IsAutoRepeating() const; /** - * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ) + * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay */ void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ); /** - * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay() const + * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay */ float GetInitialAutoRepeatingDelay() const; /** - * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ) + * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay */ void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ); /** - * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay() const + * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay */ float GetNextAutoRepeatingDelay() const; /** - * @copydoc Dali::Toolkit::Button::SetTogglableButton( bool togglable ) + * @copydoc Dali::Toolkit::Button::SetTogglableButton */ void SetTogglableButton( bool togglable ); /** - * @copydoc Dali::Toolkit::Button::IsTogglableButton() const + * @copydoc Dali::Toolkit::Button::IsTogglableButton */ bool IsTogglableButton() const; /** - * @copydoc Dali::Toolkit::Button::SetSelected( bool selected ) + * @copydoc Dali::Toolkit::Button::SetSelected */ void SetSelected( bool selected ); /** - * @copydoc Dali::Toolkit::Button::IsSelected() const + * @copydoc Dali::Toolkit::Button::IsSelected */ bool IsSelected() const; /** - * @copydoc Dali::Toolkit::Button::SetAnimationTime() + * @copydoc Dali::Toolkit::Button::SetAnimationTime */ void SetAnimationTime( float animationTime ); /** - * @copydoc Dali::Toolkit::Button::GetAnimationTime() + * @copydoc Dali::Toolkit::Button::GetAnimationTime */ 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() + * @brief Sets the specified properties on the button label. + * If the label does not exist yet, it is created. + * The derived buttons are notified if any properties are changed. + * @param[in] properties A Property::Map of key-value pairs of properties to set. */ - Actor GetDisabledImage() const; + void ModifyLabel( const Property::Map& properties ); /** - * Internal use only. - * @return A reference to the disabled button 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 */ - Actor& GetDisabledImage(); + static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes ); + +public: // Deprecated API /** - * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image ) + * @copydoc Dali::Toolkit::Button::SetLabel( Actor label ) */ - void SetDisabledSelectedImage( Actor image ); + void SetLabel( Actor label ); /** - * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage() + * @deprecated Sets the unselected image with an Actor. + * @param[in] image The Actor to use. */ - Actor GetDisabledSelectedImage() const; + void SetButtonImage( Actor image ); /** - * Internal use only. - * @return A reference to the disabled selected image. + * @deprecated Sets the selected image with an Actor. + * @param[in] image The Actor to use. */ - Actor& GetDisabledSelectedImage(); + void SetSelectedImage( Actor image ); /** - * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image ) + * @deprecated Sets the background image with an Actor. + * @param[in] image The Actor to use. */ - void SetDisabledBackgroundImage( Actor image ); + void SetBackgroundImage( Actor image ); /** - * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage() + * @deprecated Sets the selected background image with an Actor. + * @param[in] image The Actor to use. */ - Actor GetDisabledBackgroundImage() const; + void SetSelectedBackgroundImage( Actor image ); /** - * Internal use only. - * @return A reference to the disabled background image. + * @deprecated Sets the disabled image with an Actor. + * @param[in] image The Actor to use. */ - Actor& GetDisabledBackgroundImage(); + void SetDisabledImage( 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 selected image with an Actor. + * @param[in] image The Actor to use. + */ + void SetDisabledSelectedImage( Actor image ); + + /** + * @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(); + + /** + * @return A reference to the selected background image. + */ + Actor& GetSelectedBackgroundImage(); + + /** + * @return A reference to the disabled button image. + */ + Actor& GetDisabledImage(); + + /** + * @return A reference to the disabled selected image. + */ + Actor& GetDisabledSelectedImage(); /** - * It changes the transition state of the push button. + * @return A reference to the disabled background image. */ - void UpdatePaintTransitionState(); + 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. @@ -290,13 +342,14 @@ private: /** * 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 @@ -361,32 +414,23 @@ private: /** * 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: @@ -454,15 +498,20 @@ private: // From Control 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. * It resets the button status. */ - void OnControlStageDisconnection(); + void OnStageDisconnection(); private: @@ -504,6 +553,40 @@ private: */ 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 @@ -521,26 +604,92 @@ protected: 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 ) {} /** - * Inserts the actor to the button. + * Prepares the actor to be transitioned in. + * @param[in] actor The actor that will be transitioned out. */ - void InsertChild( unsigned int index, Actor& actor ); + virtual void PrepareForTranstionOut( Actor actor ) {} /** - * Removes the actor from the button. + * 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. */ - void RemoveChild( Actor& actor ); + 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 ); + + /** + * 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 ResetImageLayers(); + + /** + * Transitions out the 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. @@ -548,7 +697,28 @@ protected: */ 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& ); @@ -568,7 +738,9 @@ private: 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. @@ -576,14 +748,20 @@ private: 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