X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.h;h=b04f6b7da709aab599c71aab6573290034795ff9;hb=9c1f4310db72879676b5aca2875fbf67b97a4b0a;hp=cee57f6aea1f099fbea7ccdd82fa3bf3bc3a0f83;hpb=18088175cb55711d4675c6ea25b1b01022886be5;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 cee57f6..b04f6b7 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,214 +56,107 @@ protected: */ virtual ~PushButton(); -public: // From Button - - /** - * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image ) - */ - virtual void SetButtonImage( Actor image ); - - /** - * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image ) - */ - virtual void SetSelectedImage( Actor image ); - - /** - * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image ) - */ - virtual void SetBackgroundImage( Actor image ); - - /** - * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image ) - */ - virtual void SetDisabledImage( Actor image ); - - /** - * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image ) - */ - virtual void SetDisabledBackgroundImage( Actor image ); - -private: // From Button - - /** - * @copydoc Toolkit::Internal::Button::OnButtonInitialize() - */ - virtual void OnButtonInitialize(); - - /** - * @copydoc Toolkit::Internal::Button::OnLabelSet() - */ - virtual void OnLabelSet(); - - /** - * @copydoc Toolkit::Internal::Button::OnSelected() - */ - virtual void OnSelected( bool selected ); - - /** - * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled ) - */ - virtual void OnDisabled( bool disabled ); - - /** - * @copydoc Toolkit::Internal::Button::OnPressed() - */ - virtual void OnPressed(); - - /** - * @copydoc Toolkit::Internal::Button::OnReleased() - */ - virtual void OnReleased(); - - /** - * @copydoc Toolkit::Internal::Button::OnClicked() - */ - virtual void OnClicked(); - -private: // From Control - - /** - * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) - */ - virtual void OnControlSizeSet( const Vector3& targetSize ); - - /** - * @copydoc Toolkit::Control::GetNaturalSize() - */ - virtual Vector3 GetNaturalSize(); - -private: +public: + // Properties /** - * Used in the FadeOut functions. + * Enum for the alignment modes of the icon. */ - enum ImageLayer + enum IconAlignment { - Background, ///< Fade out the background. - Foreground ///< Fade out the foreground. + LEFT, + RIGHT, + TOP, + BOTTOM, + DEFAULT = RIGHT }; /** - * Gets the button image that is fading out. - * @return A reference to the button image that is fading out. - */ - Actor& GetFadeOutButtonImage(); - - /** - * Gets the background image that is fading out. - * @return A reference to the background image that is fading out. - */ - Actor& GetFadeOutBackgroundImage(); - - /** - * Adds the actor to the fade in animation. It creates a fade in animation if needed. - * @param[in] actor The actor. - */ - void AddToFadeInAnimation( Actor& actor ); - - /** - * Starts the fade in animation. - * PushButton::FadeInAnimationFinished slot is called when the animation finishes. + * 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. */ - void StartFadeInAnimation(); + static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value); /** - * Stops the fade in animation. + * 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. */ - void StopFadeInAnimation(); - - /** - * Adds the actor to the fade out animation. It creates a fade out animation if needed. - */ - void AddToFadeOutAnimation( Actor& actor ); - - /** - * Starts the fade out animation. - * PushButton::FadeOutAnimationFinished slot is called when the animation finishes. - */ - void StartFadeOutAnimation(); - - /** - * 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. - */ - void StopFadeOutAnimation( 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. - */ - void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 ); + static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex); +private: // From Button /** - * 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. + * @copydoc Toolkit::Internal::Button::OnInitialize */ - void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f ); - - // slots + void OnInitialize() override; +private: /** - * Called when the fade out animation finishes. - * It changes the check button paint state and removes actors from the root. + * @brief Sets the alignment mode to use to align the icon to the label. + * + * @param[in] iconAlignment The alignment mode to use */ - void FadeOutAnimationFinished( Dali::Animation& source ); + void SetIconAlignment(const PushButton::IconAlignment iconAlignment); /** - * Called when the fade in animation finishes. - * It changes the check button paint state. + * @brief Gets the alignment mode used to align the icon to the label. + * + * @return The alignment mode in use */ - void FadeInAnimationFinished( 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. - Animation mFadeInAnimation; ///< Animation used in the state transitions. - Animation mFadeOutAnimation; ///< Animation used in the state transitions. - - 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. +protected: + class PushButtonAccessible : public Button::ButtonAccessible + { + public: + using Button::ButtonAccessible::ButtonAccessible; - Vector3 mSize; ///< The button's size. + /** + * @copydoc Dali::Toolkit::DevelControl::ControlAccessible::CalculateStates() + */ + Dali::Accessibility::States CalculateStates() override; + }; - PaintState mPaintState; ///< The paint state. + 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