X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.h;h=6300fe27abc23520871585fa043df552693ae54b;hb=b8da2e53925b9abb9fa362560069e8ca4aa62f81;hp=3eddddc421f4fde77c45baa283daf9ea1d8e5a5b;hpb=cd7d41bc8e0a0816da28401207091344fbbe0b2c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.h b/dali-toolkit/internal/controls/buttons/push-button-impl.h index 3eddddc..6300fe2 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ -#define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ +#ifndef DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H +#define DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,7 @@ */ // EXTERNAL INCLUDES -#include -#include +#include // INTERNAL INCLUDES #include @@ -28,13 +27,10 @@ namespace Dali { - namespace Toolkit { - namespace Internal { - /** * PushButton implementation class. * @@ -43,7 +39,6 @@ namespace Internal class PushButton : public Button { public: - /** * Create a new PushButton. * @return A smart-pointer to the newly allocated PushButton. @@ -51,7 +46,6 @@ public: static Dali::Toolkit::PushButton New(); protected: - /** * Construct a new PushButton. */ @@ -62,161 +56,102 @@ protected: */ virtual ~PushButton(); -private: // From Button - - /** - * @copydoc Toolkit::Internal::Button::OnButtonInitialize() - */ - virtual void OnButtonInitialize(); - - /** - * @copydoc Toolkit::Internal::Button::OnLabelSet() - */ - virtual void OnLabelSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnButtonImageSet() - */ - virtual void OnButtonImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnSelectedImageSet() - */ - virtual void OnSelectedImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnBackgroundImage() - */ - virtual void OnBackgroundImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet() - */ - virtual void OnSelectedBackgroundImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnDisabledImageSet() - */ - virtual void OnDisabledImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet() - */ - virtual void OnDisabledBackgroundImageSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnSelected() - */ - virtual bool OnSelected(); - - /** - * @copydoc Toolkit::Internal::Button::OnDisabled() - */ - virtual bool OnDisabled(); - - /** - * @copydoc Toolkit::Internal::Button::OnPressed() - */ - virtual bool OnPressed(); +public: + // Properties /** - * @copydoc Toolkit::Internal::Button::OnReleased() + * Enum for the alignment modes of the icon. */ - virtual bool OnReleased(); + enum IconAlignment + { + LEFT, + RIGHT, + TOP, + BOTTOM, + DEFAULT = RIGHT + }; /** - * @copydoc Toolkit::Internal::Button::StopAllAnimations() + * 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. */ - virtual void StopAllAnimations(); - -private: // From Control + static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value); /** - * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + * 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. */ - virtual void OnControlSizeSet( const Vector3& targetSize ); + static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex); +private: // From Button /** - * @copydoc Toolkit::Control::GetNaturalSize() + * @copydoc Toolkit::Internal::Button::OnInitialize */ - virtual Vector3 GetNaturalSize(); + void OnInitialize() override; private: - - /** - * Starts the transition animation. - * PushButton::TransitionAnimationFinished slot is called when the animation finishes. - */ - void StartTransitionAnimation(); - - /** - * Stops the transition animation. - * @param[in] remove If true, removes the fadeout actor from root. - */ - void StopTransitionAnimation( bool remove = true ); - /** - * 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 Sets the alignment mode to use to align the icon to the label. + * + * @param[in] iconAlignment The alignment mode to use */ - void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) ); + void SetIconAlignment(const PushButton::IconAlignment iconAlignment); /** - * 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 Gets the alignment mode used to align the icon to the label. + * + * @return The alignment mode in use */ - void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) ); - - // slots - - /** - * Called when the transition animation finishes. - */ - void TransitionAnimationFinished( Dali::Animation& source ); + const PushButton::IconAlignment GetIconAlignment() const; private: - // Undefined - PushButton( const PushButton& ); + PushButton(const PushButton&); // Undefined - PushButton& operator=( const PushButton& ); + PushButton& operator=(const PushButton&); private: + IconAlignment mIconAlignment; ///< The alignment of the icon against the label. + +protected: + struct AccessibleImpl : public Button::AccessibleImpl + { + using Button::AccessibleImpl::AccessibleImpl; - Animation mTransitionAnimation; ///< Animation used in the state transitions. - Vector3 mSize; ///< The button's size. + Dali::Accessibility::States CalculateStates() override; + }; + void OnStateChange(State newState) override; }; } // namespace Internal // Helpers for public-api forwarding methods -inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button ) +inline Toolkit::Internal::PushButton& GetImplementation(Toolkit::PushButton& button) { - DALI_ASSERT_ALWAYS( button ); + DALI_ASSERT_ALWAYS(button); Dali::RefObject& handle = button.GetImplementation(); - return static_cast( handle ); + return static_cast(handle); } -inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button ) +inline const Toolkit::Internal::PushButton& GetImplementation(const Toolkit::PushButton& button) { - DALI_ASSERT_ALWAYS( button ); + DALI_ASSERT_ALWAYS(button); const Dali::RefObject& handle = button.GetImplementation(); - return static_cast( handle ); + return static_cast(handle); } } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ +#endif // DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H