X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fbutton-impl.h;h=89f059159d00c7a2b3250d759a3e96fa2989adac;hb=7d1d83b6d0af227e5887cad6121344fe0ea2b145;hp=f9dee5aa3bd9fa5f9d4d6aa444f0d5f8397bd99a;hpb=2ec164cd618f93ccafe17b1d0b8ff16401ed4aef;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/buttons/button-impl.h b/dali-toolkit/internal/controls/buttons/button-impl.h index f9dee5a..89f0591 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 @@ -142,6 +143,11 @@ public: Actor GetLabel() const; /** + * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image ) + */ + void SetButtonImage( Actor image ); + + /** * @copydoc Dali::Toolkit::PushButton::GetButtonImage() */ Actor GetButtonImage() const; @@ -153,6 +159,11 @@ public: Actor& GetButtonImage(); /** + * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image ) + */ + void SetSelectedImage( Actor image ); + + /** * @copydoc Dali::Toolkit::PushButton::GetSelectedImage() */ Actor GetSelectedImage() const; @@ -164,6 +175,11 @@ public: Actor& GetSelectedImage(); /** + * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image ) + */ + void SetBackgroundImage( Actor image ); + + /** * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage() */ Actor GetBackgroundImage() const; @@ -175,6 +191,27 @@ public: Actor& GetBackgroundImage(); /** + * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image ) + */ + void SetSelectedBackgroundImage( Actor image ); + + /** + * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage() + */ + Actor GetSelectedBackgroundImage() const; + + /** + * Internal use only. + * @return A reference to the selected background image. + */ + Actor& GetSelectedBackgroundImage(); + + /** + * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image ) + */ + void SetDisabledImage( Actor image ); + + /** * @copydoc Dali::Toolkit::PushButton::GetDisabledImage() */ Actor GetDisabledImage() const; @@ -186,6 +223,11 @@ public: Actor& GetDisabledImage(); /** + * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image ) + */ + void SetDisabledSelectedImage( Actor image ); + + /** * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage() */ Actor GetDisabledSelectedImage() const; @@ -197,6 +239,11 @@ public: Actor& GetDisabledSelectedImage(); /** + * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image ) + */ + void SetDisabledBackgroundImage( Actor image ); + + /** * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage() */ Actor GetDisabledBackgroundImage() const; @@ -214,59 +261,69 @@ public: * @param[in] attributes The attributes with which to perfrom this action. * @return true if action has been accepted by this control */ - static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes ); + static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes ); + +protected: /** - * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image ) + * @return A reference to the label actor. */ - virtual void SetButtonImage( Actor image ) {} + Actor& GetLabel(); + +private: /** - * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image ) + * 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. */ - virtual void SetSelectedImage( Actor image ) {} + bool DoClickAction( const Property::Map& attributes ); /** - * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image ) + * This method is called after the button initialization. + * Could be reimplemented in subclasses to provide specific behaviour. */ - virtual void SetBackgroundImage( Actor image ) {} + virtual void OnButtonInitialize() { } /** - * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image ) + * This method is called when the label is set. */ - virtual void SetDisabledImage( Actor image ) {} + virtual void OnLabelSet() {} /** - * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image ) + * This method is called when the button image is set */ - virtual void SetDisabledSelectedImage( Actor image ) {} + virtual void OnButtonImageSet() {} /** - * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image ) + * This method is called when the selected image is set */ - virtual void SetDisabledBackgroundImage( Actor image ) {} + virtual void OnSelectedImageSet() {} -protected: + /** + * This method is called when the background image is set + */ + virtual void OnBackgroundImageSet() {} /** - * Internal use only. - * @return A reference to the label actor. + * This method is called when the selected background image is set */ - Actor& GetLabel(); + virtual void OnSelectedBackgroundImageSet() {} -private: + /** + * This method is called when the disabled button image is set + */ + virtual void OnDisabledImageSet() {} /** - * Perform the click action to click the button. - * @param[in] attributes The attributes to perfrom this action. + * This method is called when the disabled selected image is set */ - void DoClickAction( const PropertyValueContainer& attributes ); + virtual void OnDisabledSelectedImageSet() {} /** - * This method is called after the button initialization. - * Could be reimplemented in subclasses to provide specific behaviour. + * This method is called when the disabled background image is set */ - virtual void OnButtonInitialize() { } + virtual void OnDisabledBackgroundImageSet() {} /** * This method is called from the OnTouchEvent method when the button is down. @@ -300,19 +357,14 @@ private: virtual void OnButtonStageDisconnection(); /** - * This method is called when the label is set. - */ - virtual void OnLabelSet() {} - - /** * This method is called when the \e selected property is changed. */ - virtual void OnSelected( bool selected ) {} + virtual void OnSelected() {} /** * This method is called when the \e disabled property is changed. */ - virtual void OnDisabled( bool disabled ) {} + virtual void OnDisabled() {} /** * This method is called when the button is pressed. @@ -324,11 +376,6 @@ private: */ virtual void OnReleased() {} - /** - * This method is called when the button is clicked - */ - virtual void OnClicked() {} - public: /** @@ -395,9 +442,14 @@ private: // From Control virtual void OnInitialize(); /** - * @copydoc Toolkit::Control::OnActivated() + * @copydoc Toolkit::Control::OnAccessibilityActivated() */ - virtual void OnActivated(); + virtual bool OnAccessibilityActivated(); + + /** + * @copydoc Toolkit::Control::OnKeyboardEnter() + */ + virtual bool OnKeyboardEnter(); /** * Callback received when the button is disconnected from the stage. @@ -428,6 +480,23 @@ private: */ bool AutoRepeatingSlot(); + /** + * Sets the button as selected or unselected. + * @param[in] selected \e selected property value. + * @param[in] emitSignal Emit a signal if this value is \e true. + */ + void SetSelected( bool selected, bool emitSignal ); + + /** + * This method is called when the button is pressed. + */ + void Pressed(); + + /** + * This method is called when the button is released. + */ + void Released(); + protected: enum ButtonState @@ -445,17 +514,109 @@ 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 push 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. }; ButtonState GetState(); + PaintState GetPaintState(); + + /** + * 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 ); + + /** + * 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 in the actor, inserting the actor above childLower below the childUpper. + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInBetween( Actor childLower, Actor childUpper, Actor actor ); + + /** + * Transitions in the actor, inserting the actor above the child if the child exists or at the bottom otherwise + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInAbove( Actor child, Actor actor ); + + /** + * Transitions in the actor, inserting the actor at the index + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInAtIndex( unsigned int index, Actor actor ); + + /** + * Transitions out the actor + */ + void TransitionOut( Actor actor ); + + /** + * Inserts the actor to the button and prepares it to be transitioned out + * @return true if the child was inserted, false otherwise + */ + bool InsertButtonImage( unsigned int index, 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. + * If the actor doesn't exist, return the last index + 1. + */ + unsigned int FindChildIndex( Actor& actor ); + // Undefined Button( const Button& ); @@ -475,13 +636,16 @@ private: Actor mLabel; ///< Stores the button label. - Actor mButtonContent; ///< Stores the unselected content. + 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 mDisabledContent; ///< Stores the disabled 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; bool mDisabled; ///< Stores the disabled property. @@ -490,12 +654,14 @@ private: 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 bool mClickActionPerforming; ButtonState mState; ///< Stores the button state. + PaintState mPaintState; ///< Stores the paint state. }; } // namespace Internal