X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fbuttons%2Fbutton.h;h=6bb9991c5610a4ebe2d8843458272f03bddf57dc;hp=abb119fb4d2aa167a6ad805bb646f5fac77d8ef9;hb=b694e7e2ae624e206e1548b1a863c554eb9cd4d7;hpb=615572d21ca43c37388d9de980a8d1265e8c21fd diff --git a/dali-toolkit/public-api/controls/buttons/button.h b/dali-toolkit/public-api/controls/buttons/button.h index abb119f..6bb9991 100644 --- a/dali-toolkit/public-api/controls/buttons/button.h +++ b/dali-toolkit/public-api/controls/buttons/button.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_BUTTON_H__ -#define __DALI_TOOLKIT_BUTTON_H__ +#ifndef DALI_TOOLKIT_BUTTON_H +#define DALI_TOOLKIT_BUTTON_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * 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. @@ -37,7 +37,7 @@ class Button; */ /** - * @brief Button is a base class for different kind of buttons. + * @brief Button is a base class for different kinds of buttons. * * This class provides the disabled property and the clicked signal. * @@ -59,321 +59,503 @@ class Button; * When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state. * * - * The button's appearance can be modified by setting properties for the various image filenames. + * 'Visual' describes not just traditional images like png, bmp but refers to whatever is used to show the button, it could be a color, gradient or some other kind of renderer. * - * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the - * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images. + * The button's appearance can be modified by setting properties for the various visuals/images. * - * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images. + * It is not mandatory to set all visuals. A button could be defined only by setting its \e background visual or by setting its \e background and \e selected visuals. + * + * The \e button visual is shown over the \e background visual. + * When pressed the unselected visuals are replaced by the \e selected visual. The text label is always placed on the top of all images. + * + * When the button is disabled, \e background, \e button and \e selected visuals are replaced by their \e disabled visuals. * - * Is not mandatory set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images. * * Signals - * | %Signal Name | Method | - * |-------------------|-----------------------------| - * | pressed | @ref PressedSignal() | - * | released | @ref ReleasedSignal() | - * | clicked | @ref ClickedSignal() | - * | state-changed | @ref StateChangedSignal() | + * | %Signal Name | Method | + * |------------------|-----------------------------| + * | pressed | @ref PressedSignal() | + * | released | @ref ReleasedSignal() | + * | clicked | @ref ClickedSignal() | + * | stateChanged | @ref StateChangedSignal() | * * Actions - * | %Action Name | %Button method called | - * |-------------------|-----------------------------| - * | button-click | %DoClickAction() | + * | %Action Name | Attributes | Description | + * |------------------|-------------------------|-----------------------------------------------| + * | buttonClick | Doesn't have attributes | Simulates a button click. See @ref DoAction() | + * @SINCE_1_0.0 */ -class DALI_IMPORT_API Button : public Control +class DALI_TOOLKIT_API Button : public Control { public: /** - * @brief The start and end property ranges for this control. + * @brief Enumeration for the start and end property ranges for this control. + * @SINCE_1_0.0 */ enum PropertyRange { - PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, - PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices + PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0 + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices @SINCE_1_0.0 }; /** - * @brief An enumeration of properties belonging to the Button class. + * @brief Enumeration for the instance of properties belonging to the Button class. + * @SINCE_1_0.0 */ struct Property { + /** + * @brief Enumeration for the instance of properties belonging to the Button class. + * @SINCE_1_0.0 + */ enum { - DISABLED = PROPERTY_START_INDEX, ///< name "disabled", @see SetDisabled(), type bool - AUTO_REPEATING, ///< name "auto-repeating", @see SetAutoRepeating(), type bool - INITIAL_AUTO_REPEATING_DELAY, ///< name "initial-auto-repeating-delay", @see SetInitialAutoRepeatingDelay(), type float - NEXT_AUTO_REPEATING_DELAY, ///< name "next-auto-repeating-delay", @see SetNextAutoRepeatingDelay(), type float - TOGGLABLE, ///< name "togglable", @see SetTogglableButton(), type bool - SELECTED, ///< name "selected", @see SetSelected(), type bool - UNSELECTED_STATE_IMAGE, ///< name "unselected-state-image", @see SetUnselectedImage(), type std::string - SELECTED_STATE_IMAGE, ///< name "selected-state-image", @see SetSelectedImage(), type std::string - DISABLED_STATE_IMAGE, ///< name "disabled-state-image", @see SetDisabledImage(), type std::string - UNSELECTED_COLOR, ///< name "unselected-color", type Vector4 - SELECTED_COLOR, ///< name "selected-color", type Vector4 - LABEL, ///< name "label", type Property::Map - - // Deprecated properties: - LABEL_TEXT, ///< name "label-text", @see SetLabelText(), type std::string + /** + * @brief name "disabled", type bool + * @details Sets the button as \e disabled. + * @SINCE_1_0.0 + */ + DISABLED = PROPERTY_START_INDEX, + + /** + * @brief name "autoRepeating", type bool + * @details If the \e autorepeating property is set to \e true then the \e togglable property is set to false + * @SINCE_1_0.0 + */ + AUTO_REPEATING, + + /** + * @brief name "initialAutoRepeatingDelay", type float + * @details By default this value is set to 0.15 seconds. + * @SINCE_1_0.0 + */ + INITIAL_AUTO_REPEATING_DELAY, + + /** + * @brief name "nextAutoRepeatingDelay", type float + * @details default this value is set to 0.05 seconds + * @SINCE_1_0.0 + */ + NEXT_AUTO_REPEATING_DELAY, + + /** + * @brief name "togglable", type bool + * @details If the \e togglable property is set to \e true, then the \e autorepeating property is set to false. + * @SINCE_1_0.0 + */ + TOGGLABLE, + + /** + * @brief name "selected", type bool + * @details Sets the togglable button as either selected or unselected, \e togglable property must be set to \e true. + * @SINCE_1_0.0 + */ + SELECTED, + + /** + * @DEPRECATED_1_1.XX Use UNSELECTED_VISUAL + * @brief name "unselectedStateImage", type string if it is a url, map otherwise + * @details Sets the unselected button foreground image + * @SINCE_1_0.0 + */ + UNSELECTED_STATE_IMAGE, + + /** + * @DEPRECATED_1_1.XX Use SELECTED_VISUAL + * @brief name "selectedStateImage", type string if it is a url, map otherwise + * @details Sets the selected button foreground image + * @SINCE_1_0.0 + */ + SELECTED_STATE_IMAGE, + + /** + * @DEPRECATED_1_1.XX Use DISABLED_UNSELECTED_VISUAL + * @brief name "disabledStateImage", type string if it is a url, map otherwise + * @details Sets the disabled whilst unselected foreground button visual + * @SINCE_1_0.0 + */ + DISABLED_STATE_IMAGE, + + /** + * @DEPRECATED_1_1.XX Use UNSELECTED_BACKGROUND_VISUAL + * @brief name "unselectedColor", type Vector4 + * @SINCE_1_0.0 + */ + UNSELECTED_COLOR, + + /** + * @DEPRECATED_1_1.XX Use SELECTED_BACKGROUND_VISUAL + * @brief name "selectedColor", type Vector4 + * @SINCE_1_0.0 + */ + SELECTED_COLOR, + + /** + * @brief name "label", type Property::Map or std::string + * @SINCE_1_0.0 + */ + LABEL, + + /** + * @DEPRECATED_1_1.32 Use LABEL + * @brief name "labelText", type std::string + * @SINCE_1_0.0 + */ + LABEL_TEXT }; }; public: /** - * @brief Create an uninitialized Button. + * @brief Creates an uninitialized Button. * * Only derived versions can be instantiated. Calling member * functions with an uninitialized Dali::Object is not allowed. + * @SINCE_1_0.0 */ Button(); /** * @brief Copy constructor. + * @SINCE_1_0.0 + * @param[in] button Handle to an object */ Button( const Button& button ); /** * @brief Assignment operator. + * @SINCE_1_0.0 + * @param[in] button Handle to an object + * @return A reference to this */ Button& operator=( const Button& button ); /** - * @brief Downcast an Object handle to Button. + * @brief Downcasts a handle to Button handle. * - * If handle points to a Button the downcast produces valid - * handle. If not the returned handle is left uninitialized. + * If handle points to a Button, the downcast produces valid handle. + * If not the returned handle is left uninitialized. * + * @SINCE_1_0.0 * @param[in] handle Handle to an object - * @return handle to a Button or an uninitialized handle + * @return A handle to a Button or an uninitialized handle */ static Button DownCast( BaseHandle handle ); /** - * @brief Destructor + * @brief Destructor. * * This is non-virtual since derived Handle types must not contain data or virtual methods. + * @SINCE_1_0.0 */ ~Button(); + // Deprecated API + /** + * @DEPRECATED_1_1.32 Use SetProperty DISABLED or Styling file + * * @brief Sets the button as \e disabled. * * No signals are emitted when the \e disabled property is set. * - * @param[in] disabled property. + * @SINCE_1_0.0 + * @param[in] disabled Disabled property */ - void SetDisabled( bool disabled ); + void SetDisabled( bool disabled ) DALI_DEPRECATED_API; /** - * @return \e true if the button is \e disabled. + * @DEPRECATED_1_1.32 Use GetProperty DISABLED + * + * @brief Returns if the button is disabled. + * @SINCE_1_0.0 + * @return \e true if the button is \e disabled */ - bool IsDisabled() const; + bool IsDisabled() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 SetProperty AUTO_REPEATING or Styling file + * * @brief Sets the \e autorepeating property. * * If the \e autorepeating property is set to \e true, then the \e togglable property is set to false * but no signal is emitted. * - * @param[in] autoRepeating \e autorepeating property. + * @SINCE_1_0.0 + * @param[in] autoRepeating \e autorepeating property */ - void SetAutoRepeating( bool autoRepeating ); + void SetAutoRepeating( bool autoRepeating ) DALI_DEPRECATED_API; /** - * @return \e true if the \e autorepeating property is set. + * @DEPRECATED_1_1.32 GetProperty AUTO_REPEATING + * + * @brief Returns if the autorepeating property is set. + * @SINCE_1_0.0 + * @return \e true if the \e autorepeating property is set */ - bool IsAutoRepeating() const; + bool IsAutoRepeating() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 SetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file + * * @brief Sets the initial autorepeating delay. * - * By default this value is set to 0.15 seconds. + * By default, this value is set to 0.15 seconds. * + * @SINCE_1_0.0 + * @param[in] initialAutoRepeatingDelay in seconds * @pre initialAutoRepeatingDelay must be greater than zero. - * @param[in] initialAutoRepeatingDelay in seconds. */ - void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ); + void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ) DALI_DEPRECATED_API; /** - * @return the initial autorepeating delay in seconds. + * @DEPRECATED_1_1.32 GetProperty INITIAL_AUTO_REPEATING_DELAY + * + * @brief Gets the initial autorepeating delay in seconds. + * @SINCE_1_0.0 + * @return The initial autorepeating delay in seconds */ - float GetInitialAutoRepeatingDelay() const; + float GetInitialAutoRepeatingDelay() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 SetProperty NEXT_AUTO_REPEATING_DELAY or Styling file + * * @brief Sets the next autorepeating delay. * - * By default this value is set to 0.05 seconds. + * By default, this value is set to 0.05 seconds. * + * @SINCE_1_0.0 + * @param[in] nextAutoRepeatingDelay in seconds * @pre nextAutoRepeatingDelay must be greater than zero. - * @param[in] nextAutoRepeatingDelay in seconds. */ - void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ); + void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ) DALI_DEPRECATED_API; /** - * @return the next autorepeating delay in seconds. + * @DEPRECATED_1_1.32 GetProperty NEXT_AUTO_REPEATING_DELAY + * + * @brief Gets the next autorepeating delay in seconds. + * @SINCE_1_0.0 + * @return The next autorepeating delay in seconds */ - float GetNextAutoRepeatingDelay() const; + float GetNextAutoRepeatingDelay() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 SetProperty TOGGLABLE or Styling file + * * @brief Sets the \e togglable property. * * If the \e togglable property is set to \e true, then the \e autorepeating property is set to false. * - * @param[in] togglable property. + * @SINCE_1_0.0 + * @param[in] togglable Togglable property */ - void SetTogglableButton( bool togglable ); + void SetTogglableButton( bool togglable ) DALI_DEPRECATED_API; /** - * @return \e true if the \e togglable property is set. + * @DEPRECATED_1_1.32 GetProperty TOGGLABLE + * + * @brief Returns if the togglable property is set. + * @SINCE_1_0.0 + * @return \e true if the \e togglable property is set */ - bool IsTogglableButton() const; + bool IsTogglableButton() const DALI_DEPRECATED_API; /** - * Sets the button as selected or unselected. + * @DEPRECATED_1_1.32 SetProperty SELECTED + * + * @brief Sets the button as selected or unselected. * * \e togglable property must be set to \e true. * * Emits a Button::StateChangedSignal() signal. * - * @param[in] selected property. + * @SINCE_1_0.0 + * @param[in] selected Selected property */ - void SetSelected( bool selected ); + void SetSelected( bool selected ) DALI_DEPRECATED_API; /** - * @return \e true if the \e selected property is set and the button is togglable. + * DEPRECATED_1_1.32 GetProperty SELECTED + * + * @brief Returns if the selected property is set and the button is togglable. + * @SINCE_1_0.0 + * @return \e true if the button is \e selected */ - bool IsSelected() const; + bool IsSelected() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use Styling file to set animation + * * @brief Sets the animation time. * - * @param[in] animationTime The animation time in seconds. + * @SINCE_1_0.0 + * @param[in] animationTime The animation time in seconds */ - void SetAnimationTime( float animationTime ); + void SetAnimationTime( float animationTime ) DALI_DEPRECATED_API; /** + * DEPRECATED_1_1.32 Use Styling file to set animation + * * @brief Retrieves button's animation time. * - * @return The animation time in seconds. + * @SINCE_1_0.0 + * @return The animation time in seconds */ - float GetAnimationTime() const; + float GetAnimationTime() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 SetProperty Property::LABEL or Styling file + * * @brief Sets the button's label. * - * @param[in] label The label text. + * @SINCE_1_0.0 + * @param[in] label The label text */ - void SetLabelText( const std::string& label ); + void SetLabelText( const std::string& label ) DALI_DEPRECATED_API; /** + * DEPRECATED_1_1.32 GetProperty LABEL + * * @brief Gets the label. * - * @return The label text. + * @SINCE_1_0.0 + * @return The label text */ - std::string GetLabelText() const; + std::string GetLabelText() const DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use Styling file Property::UNSELECTED_STATE_IMAGE + * * @brief Sets the unselected button image. * - * @param[in] filename The button image. + * @SINCE_1_0.0 + * @param[in] filename The button image */ - void SetUnselectedImage( const std::string& filename ); + void SetUnselectedImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use styling Set Control::Property::BACKGROUND which is same as un-selected background + * Or use DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL + * * @brief Sets the background image. * - * @param[in] filename The background image. + * @SINCE_1_0.0 + * @param[in] filename The background image */ - void SetBackgroundImage( const std::string& filename ); + void SetBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use styling file, Property::SELECTED_STATE_IMAGE + * * @brief Sets the selected image. * - * @param[in] filename The selected image. + * @SINCE_1_0.0 + * @param[in] filename The selected image */ - void SetSelectedImage( const std::string& filename ); + void SetSelectedImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Set Control::Property::BACKGROUND which is same as un-selected background + * Or use DevelButton::Property::SELECTED_BACKGROUND_VISUAL + * * @brief Sets the selected background image. * - * @param[in] filename The selected background image. + * @SINCE_1_0.0 + * @param[in] filename The selected background image */ - void SetSelectedBackgroundImage( const std::string& filename ); + void SetSelectedBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Only able to set Property::DISABLED_STATE_IMAGE + * Or use DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL + * * @brief Sets the disabled background image. * - * @param[in] filename The disabled background image. + * @SINCE_1_0.0 + * @param[in] filename The disabled background image */ - void SetDisabledBackgroundImage( const std::string& filename ); + void SetDisabledBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use styling file Property::DISABLED_STATE_IMAGE + * * @brief Sets the disabled button image. * - * @param[in] filename The disabled button image. + * @SINCE_1_0.0 + * @param[in] filename The disabled button image */ - void SetDisabledImage( const std::string& filename ); + void SetDisabledImage( const std::string& filename ) DALI_DEPRECATED_API; /** + * @DEPRECATED_1_1.32 Use Property::DISABLED_STATE_IMAGE which provides same disabled image for un/selected + * Or DevelButton::Property::DISABLED_SELECTED_VISUAL to disable selected visual. + * * @brief Sets the disabled selected button image. * - * @param[in] filename The disabled selected button image. + * @SINCE_1_0.0 + * @param[in] filename The disabled selected button image */ - void SetDisabledSelectedImage( const std::string& filename ); - - // Deprecated API + void SetDisabledSelectedImage( const std::string& filename ) DALI_DEPRECATED_API; /** - * @deprecated DALi 1.0.50 + * @DEPRECATED_1_0.50. Instead, use SetLabelText * * @brief Sets the label with an actor. * - * @param[in] label The actor to use as a label + * @SINCE_1_0.0 + * @param[in] label The actor to use as a label */ - void SetLabel( Actor label ); + void SetLabel( Actor label ) DALI_DEPRECATED_API; /** - * @deprecated DALi 1.0.50 + * @DEPRECATED_1_0.50. Instead, use SetUnselectedImage. * * @brief Sets the button image. * - * @param[in] image The button image. + * @SINCE_1_0.0 + * @param[in] image The button image */ - void SetButtonImage( Image image ); + void SetButtonImage( Image image ) DALI_DEPRECATED_API; /** - * @deprecated DALi 1.0.50 + * @DEPRECATED_1_0.50. Instead, use SetSelectedImage( const std::string& filename ). * * @brief Sets the selected image. * - * @param[in] image The selected image. + * @SINCE_1_0.0 + * @param[in] image The selected image */ - void SetSelectedImage( Image image ); + void SetSelectedImage( Image image ) DALI_DEPRECATED_API; /** - * @deprecated DALi 1.0.50 + * @DEPRECATED_1_0.50 * * @brief Gets the button image. * - * @return An actor with the button image. + * @SINCE_1_0.0 + * @remarks Avoid using this method as it's a legacy code. + * @return An actor with the button image */ - Actor GetButtonImage() const; + Actor GetButtonImage() const DALI_DEPRECATED_API; /** - * @deprecated DALi 1.0.50 + * @DEPRECATED_1_0.50 * * @brief Gets the selected image. * - * @return An actor with the selected image. + * @SINCE_1_0.0 + * @remarks Avoid using this method as it's a legacy code. + * @return An actor with the selected image */ - Actor GetSelectedImage() const; + Actor GetSelectedImage() const DALI_DEPRECATED_API; public: //Signals /** - * @brief Button signal type + * @brief Button signal type. + * @SINCE_1_0.0 */ typedef Signal< bool ( Button ) > ButtonSignalType; @@ -384,7 +566,8 @@ public: //Signals * @code * bool YourCallbackName( Button button ); * @endcode - * @return The signal to connect to. + * @SINCE_1_0.0 + * @return The signal to connect to */ ButtonSignalType& PressedSignal(); @@ -395,7 +578,8 @@ public: //Signals * @code * bool YourCallbackName( Button button ); * @endcode - * @return The signal to connect to. + * @SINCE_1_0.0 + * @return The signal to connect to */ ButtonSignalType& ReleasedSignal(); @@ -406,37 +590,44 @@ public: //Signals * @code * bool YourCallbackName( Button button ); * @endcode - * @return The signal to connect to. + * @SINCE_1_0.0 + * @return The signal to connect to */ ButtonSignalType& ClickedSignal(); /** * @brief This signal is emitted when the button's state is changed. + * * The application can get the state by calling IsSelected(). * * A callback of the following type may be connected: * @code * bool YourCallbackName( Button button ); * @endcode - * @return The signal to connect to. + * @SINCE_1_0.0 + * @return The signal to connect to */ ButtonSignalType& StateChangedSignal(); public: // Not intended for application developers + /// @cond internal /** * @brief Creates a handle using the Toolkit::Internal implementation. * - * @param[in] implementation The Control implementation. + * @SINCE_1_0.0 + * @param[in] implementation The Control implementation */ DALI_INTERNAL Button( Internal::Button& implementation ); /** * @brief Allows the creation of this Control from an Internal::CustomActor pointer. * - * @param[in] internal A pointer to the internal CustomActor. + * @SINCE_1_0.0 + * @param[in] internal A pointer to the internal CustomActor */ DALI_INTERNAL Button( Dali::Internal::CustomActor* internal ); + /// @endcond }; /** @@ -446,4 +637,4 @@ public: // Not intended for application developers } // namespace Dali -#endif // __DALI_TOOLKIT_BUTTON_H__ +#endif // DALI_TOOLKIT_BUTTON_H