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%2Fpush-button.h;h=603601d6a8d9d1ee67a95dfa6f8735ea6f0735cb;hp=09c480c2c0f9b8105efbfb1b4232130abc4bd739;hb=938ea2d2a1a42930cf12c743d839aded892949ea;hpb=306d2f61a1b64179e801fa8a0bb2bd7b4e9dd682 diff --git a/dali-toolkit/public-api/controls/buttons/push-button.h b/dali-toolkit/public-api/controls/buttons/push-button.h index 09c480c..603601d 100644 --- a/dali-toolkit/public-api/controls/buttons/push-button.h +++ b/dali-toolkit/public-api/controls/buttons/push-button.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_PUSH_BUTTON_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -35,56 +35,85 @@ namespace Internal DALI_INTERNAL class PushButton; } +/** + * @addtogroup dali_toolkit_controls_buttons + * @{ + */ /** * @brief A PushButton changes its appearance when is pressed and returns to its original when is released. * - * By default a PushButton emits a PushButton::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked - * and a PushButton::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button. - * - * PushButton provides the following properties which modify signals emitted: - * + * // Connect to button signals emitted by the button + * button.ClickedSignal().Connect( this, &HelloWorldExample::OnButtonClicked ); + * button.PressedSignal().Connect( this, &HelloWorldExample::OnButtonPressed ); + * button.ReleasedSignal().Connect( this, &HelloWorldExample::OnButtonReleased ); + * } * - * The button's appearance could be modified by setting images or actors with PushButton::SetButtonImage, PushButton::SetBackgroundImage, - * PushButton::SetSelectedImage, PushButton::SetDisabledBackgroundImage and PushButton::SetDisabledImage or setting a text with - * PushButton::SetLabel. + * bool HelloWorldExample::OnButtonClicked( Button button ) + * { + * // Do something when the button is clicked + * return true; + * } * - * 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. + * bool HelloWorldExample::OnButtonPressed( Button button ) + * { + * // Do something when the button is pressed + * return true; + * } * - * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images. + * bool HelloWorldExample::OnButtonReleased( Button button ) + * { + * // Do something when the button is released + * return true; + * } + * @endcode * - * The methods used to modify the button's appearance could receive Dali::Actor objects as a parameter, so more complex images could be defined. - * - * 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. + * See Button for more detail on signals and modifying appearance via properties. + * @SINCE_1_0.0 */ class DALI_IMPORT_API PushButton : public Button { public: - //Signal Names - static const char* const SIGNAL_PRESSED; ///< name "pressed" - static const char* const SIGNAL_RELEASED; ///< name "released" + /** + * @brief The start and end property ranges for this control. + * @SINCE_1_0.0 + */ + enum PropertyRange + { + PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0 + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices @SINCE_1_0.0 + }; - //Action Names - static const char* const ACTION_PUSH_BUTTON_CLICK; ///< name "push-button-click" + /** + * @brief An enumeration of properties belonging to the PushButton class. + * @SINCE_1_0.0 + */ + struct Property + { + enum + { + UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon", type std::string @SINCE_1_0.0 + SELECTED_ICON, ///< Property, name "selectedIcon", type std::string @SINCE_1_0.0 + ICON_ALIGNMENT, ///< Property, name "iconAlignment", type std::string @SINCE_1_0.0 + LABEL_PADDING, ///< Property, name "labelPadding", type Vector4 @SINCE_1_0.0 + ICON_PADDING, ///< Property, name "iconPadding", type Vector4 @SINCE_1_0.0 + }; + }; public: @@ -92,16 +121,19 @@ public: * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New(). * * Calling member functions with an uninitialized Dali::Object is not allowed. + * @SINCE_1_0.0 */ PushButton(); /** * @brief Copy constructor. + * @SINCE_1_0.0 */ PushButton( const PushButton& pushButton ); /** * @brief Assignment operator. + * @SINCE_1_0.0 */ PushButton& operator=( const PushButton& pushButton ); @@ -109,239 +141,125 @@ public: * @brief Destructor * * This is non-virtual since derived Handle types must not contain data or virtual methods. + * @SINCE_1_0.0 */ ~PushButton(); /** * @brief Create an initialized PushButton. * + * @SINCE_1_0.0 * @return A handle to a newly allocated Dali resource. */ static PushButton New(); /** - * @brief Downcast an Object handle to PushButton. + * @brief Downcast a handle to PushButton handle. * * If handle points to a PushButton 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 PushButton or an uninitialized handle */ static PushButton DownCast( BaseHandle handle ); - /** - * @brief Sets the \e autorepeating property. - * - * If the \e autorepeating property is set to \e true, then the \e toggled property is set to false - * but no signal is emitted. - * - * @param[in] autoRepeating \e autorepeating property. - */ - void SetAutoRepeating( bool autoRepeating ); - - /** - * @return \e true if the \e autorepeating property is set. - */ - bool IsAutoRepeating() const; - - /** - * @brief Sets the initial autorepeating delay. - * - * By default this value is set to 0.15 seconds. - * - * @pre initialAutoRepeatingDelay must be greater than zero. - * @param[in] initialAutoRepeatingDelay in seconds. - */ - void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ); - - /** - * @return the initial autorepeating delay in seconds. - */ - float GetInitialAutoRepeatingDelay() const; - /** - * @brief Sets the next autorepeating delay. - * - * By default this value is set to 0.05 seconds. - * - * @pre nextAutoRepeatingDelay must be greater than zero. - * @param[in] nextAutoRepeatingDelay in seconds. - */ - void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ); + // Deprecated API - /** - * @return the next autorepeating delay in seconds. - */ - float GetNextAutoRepeatingDelay() const; + using Button::SetButtonImage; /** - * @brief Sets the \e toggled property. + * @DEPRECATED_1_0.50. Instead, use Button::SetUnselectedImage. * - * If the \e toggled property is set to \e true, then the \e autorepeating property is set to false. + * @brief Sets the unselected image with an Actor. * - * @param[in] toggle property. + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ - void SetToggleButton( bool toggle ); + void SetButtonImage( Actor image ); - /** - * @return \e true if the \e toggled property is set. - */ - bool IsToggleButton() const; + using Button::SetBackgroundImage; /** - * @brief Sets the button as toggled or not toggled. + * @DEPRECATED_1_0.50. Instead, use Button::SetBackgroundImage. * - * \e toggled property must be set to \e true. + * @brief Sets the background image with an Actor. * - * Emits a Button::StateChangedSignal() signal. - * - * @param[in] toggle state. - */ - void SetToggled( bool toggle ); - - /** - * @return \e true if the \e toggled property is set and the button is toggled. + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ - bool IsToggled() const; - - /** - * @brief Sets the button image. - * - * @param[in] image The button image. - */ - void SetButtonImage( Image image ); + void SetBackgroundImage( Actor image ); - /** - * @copydoc SetButtonImage( Image image ) - */ - void SetButtonImage( Actor image ); + using Button::SetSelectedImage; /** - * @brief Gets the button image. + * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedImage( const std::string& filename ). * - * @return An actor with the button image. - */ - Actor GetButtonImage() const; - - /** - * @brief Sets the background image. + * @brief Sets the selected image with an Actor. * - * @param[in] image The background image. + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ - void SetBackgroundImage( Image image ); + void SetSelectedImage( Actor image ); - /** - * @copydoc SetBackgroundImage( Image image ) - */ - void SetBackgroundImage( Actor image ); + using Button::SetSelectedBackgroundImage; /** - * @brief Gets the background image. + * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedBackgroundImage. * - * @return An actor with the background image. - */ - Actor GetBackgroundImage() const; - - /** - * @brief Sets the selected image. + * @brief Sets the selected background image with an Actor. * - * @param[in] image The selected image. + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ - void SetSelectedImage( Image image ); + void SetSelectedBackgroundImage( Actor image ); - /** - * @copydoc SetSelectedImage( Image image ) - */ - void SetSelectedImage( Actor image ); + using Button::SetDisabledBackgroundImage; /** - * @brief Gets the selected image. + * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledBackgroundImage. * - * @return An actor with the selected image. - */ - Actor GetSelectedImage() const; - - /** - * @brief Sets the disabled background image. + * @brief Sets the disabled background image with an Actor. * - * @param[in] image The disabled background image. - */ - void SetDisabledBackgroundImage( Image image ); - - /** - * @copydoc SetDisabledBackgroundImage( Image image ) + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ void SetDisabledBackgroundImage( Actor image ); - /** - * @brief Gets the disabled background image. - * - * @return An actor with the disabled background image. - */ - Actor GetDisabledBackgroundImage() const; + using Button::SetDisabledImage; /** - * @brief Sets the disabled button image. + * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledImage. * - * @param[in] image The disabled button image. - */ - void SetDisabledImage( Image image ); - - /** - * @copydoc SetDisabledImage( Image image ) + * @brief Sets the disabled image with an Actor. + * + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ void SetDisabledImage( Actor image ); - /** - * @brief Gets the disabled image. - * - * @return An actor with the disabled image. - */ - Actor GetDisabledImage() const; + using Button::SetDisabledSelectedImage; /** - * @brief Sets the button label. + * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledSelectedImage. * - * @param[in] label The button label. - */ - void SetLabel( const std::string& label ); - - /** - * @copydoc SetLabel( const std::string& label ) - */ - void SetLabel( Actor label ); - - /** - * @brief Gets the label. + * @brief Sets the disabled selected image with an Actor. * - * @return An actor with the label. + * @SINCE_1_0.0 + * @param[in] image The Actor to use. */ - Actor GetLabel() const; - -public: //Signals - - /// @brief PushButton Pressed signal type. - typedef Signal< bool ( Button ) > PressedSignalType; + void SetDisabledSelectedImage( Actor image ); - /// @brief PushButton Released signal type. - typedef Signal< bool ( Button ) > ReleasedSignalType; - - /** - * @brief Signal emitted when the button is touched. - */ - PressedSignalType& PressedSignal(); - - /** - * @brief Signal emitted when the button is touched and the touch point leaves the boundary of the button. - */ - ReleasedSignalType& ReleasedSignal(); public: // Not intended for application developers + /// @cond internal /** * @brief Creates a handle using the Toolkit::Internal implementation. * + * @SINCE_1_0.0 * @param[in] implementation The Control implementation. */ DALI_INTERNAL PushButton( Internal::PushButton& implementation ); @@ -349,11 +267,16 @@ public: // Not intended for application developers /** * @brief Allows the creation of this Control from an Internal::CustomActor pointer. * + * @SINCE_1_0.0 * @param[in] internal A pointer to the internal CustomActor. */ DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal ); + /// @endcond }; +/** + * @} + */ } // namespace Toolkit } // namespace Dali