X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.h;h=d7e91d3af1357bd3cbfbf118eb3b02139a8e7adc;hp=b463513038c86da0f84881d03f8a28e4ed42cc38;hb=b694e7e2ae624e206e1548b1a863c554eb9cd4d7;hpb=3fbada5f2ec43d9b0ea3e63eb54223cf7b3056f4 diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.h b/dali-toolkit/internal/controls/buttons/push-button-impl.h index b463513..d7e91d3 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -1,27 +1,28 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ -#define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ - -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +#ifndef DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H +#define DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H -// INTERNAL INCLUDES -#include +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ -#include +// EXTERNAL INCLUDES +#include +// INTERNAL INCLUDES +#include #include "button-impl.h" namespace Dali @@ -48,313 +49,114 @@ public: */ 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; - - /** - * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( const Image image ) - */ - void SetBackgroundImage( Image image ); +protected: /** - * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image ) - */ - void SetBackgroundImage( Actor image ); - - /** - * Used by the painter only. - * @return A reference to the background image. - */ - Actor& GetBackgroundImage(); - - /** - * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage() - */ - Actor GetBackgroundImage() const; - - /** - * @copydoc Dali::Toolkit::PushButton::SetPressedImage( const Image image ) - */ - void SetPressedImage( Image image ); - - /** - * @copydoc Dali::Toolkit::PushButton::SetPressedImage( Actor image ) - */ - void SetPressedImage( Actor image ); - - /** - * Used by the painter only. - * @return A reference to the pressed image. - */ - Actor& GetPressedImage(); - - /** - * @copydoc Dali::Toolkit::PushButton::GetPressedImage() - */ - Actor GetPressedImage() const; - - /** - * @copydoc Dali::Toolkit::PushButton::SetDimmedBackgroundImage( Image image ) - */ - void SetDimmedBackgroundImage( Image image ); - - /** - * @copydoc Dali::Toolkit::PushButton::SetDimmedBackgroundImage( Actor image ) - */ - void SetDimmedBackgroundImage( Actor image ); - - /** - * Used by the painter only. - * @return A reference to the dimmed background image. - */ - Actor& GetDimmedBackgroundImage(); - - /** - * @copydoc Dali::Toolkit::PushButton::GetDimmedBackgroundImage() - */ - Actor GetDimmedBackgroundImage() const; - - /** - * @copydoc Dali::Toolkit::PushButton::SetDimmedImage( Image image ) - */ - void SetDimmedImage( Image image ); - - /** - * @copydoc Dali::Toolkit::PushButton::SetDimmedImage( Actor image ) - */ - void SetDimmedImage( Actor image ); - - /** - * Used by the painter only. - * @return A reference to the dimmed button image. - */ - Actor& GetDimmedImage(); - - /** - * @copydoc Dali::Toolkit::PushButton::GetDimmedImage() - */ - Actor GetDimmedImage() const; - - /** - * @copydoc Dali::Toolkit::PushButton::SetLabelText( const std::string& text ) - */ - void SetLabelText( const std::string& text ); - - /** - * @copydoc Dali::Toolkit::PushButton::SetLabelText( Actor text ) - */ - void SetLabelText( Actor text ); - - /** - * Used by the painter only. - * @return A reference to the label actor. - */ - Actor& GetLabel(); - - /** - * @copydoc Dali::Toolkit::PushButton::GetLabelText() - */ - Actor GetLabelText() const; - - /** - * Used by the painter only. - * @return A reference to the background image that is fading out. + * Construct a new PushButton. */ - Actor& GetFadeOutBackgroundImage(); + PushButton(); /** - * Used by the painter only. - * @return A reference to the button image that is fading out. + * A reference counted object may only be deleted by calling Unreference() */ - Actor& GetFadeOutButtonImage(); + virtual ~PushButton(); public: - // Signals - - /** - * @copydoc Dali::Toolkit::PushButton::ToggledSignal() - */ - Toolkit::PushButton::ToggledSignalV2& ToggledSignal(); - - /** - * @copydoc Dali::Toolkit::PushButton::PressedSignal() - */ - Toolkit::PushButton::PressedSignalV2& PressedSignal(); + // Properties /** - * @copydoc Dali::Toolkit::PushButton::ReleasedSignal() + * Enum for the alignment modes of the icon. */ - Toolkit::PushButton::ReleasedSignalV2& ReleasedSignal(); + enum IconAlignment + { + LEFT, + RIGHT, + TOP, + BOTTOM, + DEFAULT = RIGHT + }; /** - * 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. + * 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. */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - - // Properties + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); /** - * @copydoc Button::SetProperty - */ - static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ); - - /** - * @copydoc Button::GetProperty + * 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. */ static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ); -protected: // From Button - /** - * Sets the Leave signal. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnButtonInitialize(); + void SetButtonImage( Actor image ); /** - * Emits signals and notifies the painter accordingly with the set button - * properties when the button is pressed. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnButtonDown(); + void SetBackgroundImage( Actor image ); /** - * Emits signals and notifies the painter accordingly with the set button - * properties when the button is released. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnButtonUp(); + void SetSelectedImage( Actor image ); /** - * Emits signals and notifies the painter accordingly with the set button - * properties when the touch point leaves the boundary of the button. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnTouchPointLeave(); + void SetSelectedBackgroundImage( Actor image ); /** - * Currently it doesn't need different behaviour than @see OnTouchPointLeave() + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnTouchPointInterrupted(); + void SetDisabledBackgroundImage( Actor image ); /** - * Sets the push button animation time. - * @param animationTime The animation time in seconds. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual void OnAnimationTimeSet( float animationTime ); + void SetDisabledImage( Actor image ); /** - * Retrieves the animation time. - * @return The animation time in seconds. + * Deprecated API for Setting Pushbutton image using an Actor + * @param[in] image, Image Actor that has a url which can be used to create an image visual */ - virtual float OnAnimationTimeRequested() const; + void SetDisabledSelectedImage( Actor image ); -protected: // From ControlImpl +private: // From Button /** - * Respond the activate notification. + * @copydoc Toolkit::Internal::Button::OnInitialize */ - virtual void OnActivated(); + virtual void OnInitialize(); private: /** - * Perform the click action to click the button. - * @param[in] attributes The attributes to perfrom this action. - */ - void DoClickAction(const PropertyValueContainer& attributes); - -public: - - /** - * 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 + * @brief Sets the alignment mode to use to align the icon to the label. + * + * @param[in] iconAlignment The alignment mode to use */ - static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector& attributes); + void SetIconAlignment( const PushButton::IconAlignment iconAlignment ); /** - * Construct a new PushButton. - */ - PushButton(); - - /** - * A reference counted object may only be deleted by calling Unreference() + * @brief Gets the alignment mode used to align the icon to the label. + * + * @return The alignment mode in use */ - virtual ~PushButton(); + const PushButton::IconAlignment GetIconAlignment() const; private: @@ -364,47 +166,9 @@ 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::ToggledSignalV2 mToggledSignalV2; ///< Signal emitted when the button is toggled. - Toolkit::PushButton::PressedSignalV2 mPressedSignalV2; ///< Signal emitted when the button is pressed. - Toolkit::PushButton::ReleasedSignalV2 mReleasedSignalV2; ///< Signal emitted when the button is released. - - Actor mButtonImage; ///< Stores the released image. - Actor mBackgroundImage; ///< Stores the background image. - Actor mPressedImage; ///< Stores the pressed image. - Actor mDimmedImage; ///< Stores the dimmed image. - Actor mDimmedBackgroundImage; ///< Stores the dimmed background image. - - Actor mLabel; ///< Stores the text label. - - 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. - // Actions - bool mClickActionPerforming; + IconAlignment mIconAlignment; ///< The alignment of the icon against the label. }; } // namespace Internal @@ -433,4 +197,4 @@ inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::Pu } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__ +#endif // DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H