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=34ea28f743d8b465463af57e1468c18f628e1544;hp=e693a1142ae8367b100ac5ce394ee30528261e66;hb=f54caf0701f2812a55aa573530f2861ea057e8d6;hpb=57869973578f6a0b0f836d396c7232ddb8302c6b diff --git a/dali-toolkit/public-api/controls/buttons/button.h b/dali-toolkit/public-api/controls/buttons/button.h index e693a11..34ea28f 100644 --- a/dali-toolkit/public-api/controls/buttons/button.h +++ b/dali-toolkit/public-api/controls/buttons/button.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_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. @@ -31,36 +31,93 @@ namespace Internal DALI_INTERNAL { class Button; } +/** + * @addtogroup dali-toolkit-controls-buttons + * @{ + */ /** * @brief Button is a base class for different kind of buttons. * * This class provides the disabled property and the clicked signal. * - * A ClickedSignal() is emitted when the button is touched and the touch - * point doesn't leave the boundary of the button. + * A ClickedSignal() is emitted when the button is touched and the touch point doesn't leave the boundary of the button. * * When the \e disabled property is set to \e true, no signal is emitted. + * + * Button provides the following properties which modify the signals emitted: + * + * + * The button's appearance can be modified by setting properties for the various image filenames. + * + * 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. + * + * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images. + * + * 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() | + * + * Actions + * | %Action Name | %Button method called | + * |-------------------|-----------------------------| + * | button-click | %DoClickAction() | */ class DALI_IMPORT_API Button : public Control { public: - // Signal Names - static const char* const SIGNAL_CLICKED; ///< name "clicked" - static const char* const SIGNAL_STATE_CHANGED; ///< name "state-changed" - - // Properties - static const Property::Index PROPERTY_DISABLED; ///< name "disabled", @see SetDisabled(), type BOOLEAN - static const Property::Index PROPERTY_AUTO_REPEATING; ///< name "auto-repeating", @see SetAutoRepeating(), type BOOLEAN - static const Property::Index PROPERTY_INITIAL_AUTO_REPEATING_DELAY; ///< name "initial-auto-repeating-delay", @see SetInitialAutoRepeatingDelay(), type FLOAT - static const Property::Index PROPERTY_NEXT_AUTO_REPEATING_DELAY; ///< name "next-auto-repeating-delay", @see SetNextAutoRepeatingDelay(), type FLOAT - static const Property::Index PROPERTY_TOGGLABLE; ///< name "togglable", @see SetToggleButton(), type BOOLEAN - static const Property::Index PROPERTY_TOGGLED; ///< name "toggled", @see SetToggled(), type BOOLEAN - static const Property::Index PROPERTY_NORMAL_STATE_ACTOR; ///< name "button-state-actor", @see SetButtonImage(), type MAP - static const Property::Index PROPERTY_SELECTED_STATE_ACTOR; ///< name "selected-state-actor", @see SetSelectedImage(), type MAP - static const Property::Index PROPERTY_DISABLED_STATE_ACTOR; ///< name "disabled-state-actor", @see SetDisabledImage(), type MAP - static const Property::Index PROPERTY_LABEL_ACTOR; ///< name "label-actor", @see SetLabel(), type MAP + /** + * @brief The start and end property ranges for this control. + */ + enum PropertyRange + { + PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices + }; + + /** + * @brief An enumeration of properties belonging to the Button class. + */ + struct Property + { + 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 + }; + }; public: @@ -115,9 +172,84 @@ public: bool IsDisabled() const; /** + * @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. + */ + 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 ); + + /** + * @return the next autorepeating delay in seconds. + */ + float GetNextAutoRepeatingDelay() const; + + /** + * @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. + */ + void SetTogglableButton( bool togglable ); + + /** + * @return \e true if the \e togglable property is set. + */ + bool IsTogglableButton() const; + + /** + * 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. + */ + void SetSelected( bool selected ); + + /** + * @return \e true if the \e selected property is set and the button is togglable. + */ + bool IsSelected() const; + + /** * @brief Sets the animation time. * - * @param [in] animationTime The animation time in seconds. + * @param[in] animationTime The animation time in seconds. */ void SetAnimationTime( float animationTime ); @@ -128,27 +260,167 @@ public: */ float GetAnimationTime() const; + /** + * @brief Sets the button's label. + * + * @param[in] label The label text. + */ + void SetLabelText( const std::string& label ); + + /** + * @brief Gets the label. + * + * @return The label text. + */ + std::string GetLabelText() const; + + /** + * @brief Sets the unselected button image. + * + * @param[in] filename The button image. + */ + void SetUnselectedImage( const std::string& filename ); + + /** + * @brief Sets the background image. + * + * @param[in] filename The background image. + */ + void SetBackgroundImage( const std::string& filename ); + + /** + * @brief Sets the selected image. + * + * @param[in] filename The selected image. + */ + void SetSelectedImage( const std::string& filename ); + + /** + * @brief Sets the selected background image. + * + * @param[in] filename The selected background image. + */ + void SetSelectedBackgroundImage( const std::string& filename ); + + /** + * @brief Sets the disabled background image. + * + * @param[in] filename The disabled background image. + */ + void SetDisabledBackgroundImage( const std::string& filename ); + + /** + * @brief Sets the disabled button image. + * + * @param[in] filename The disabled button image. + */ + void SetDisabledImage( const std::string& filename ); + + /** + * @brief Sets the disabled selected button image. + * + * @param[in] filename The disabled selected button image. + */ + void SetDisabledSelectedImage( const std::string& filename ); + + // Deprecated API + + /** + * @brief Sets the label with an actor. + * + * @deprecated DALi 1.0.50 + * + * @param[in] label The actor to use as a label + */ + void SetLabel( Actor label ); + + /** + * @brief Sets the button image. + * + * @deprecated DALi 1.0.50 + * + * @param[in] image The button image. + */ + void SetButtonImage( Image image ); + + /** + * @brief Sets the selected image. + * + * @deprecated DALi 1.0.50 + * + * @param[in] image The selected image. + */ + void SetSelectedImage( Image image ); + + /** + * @brief Gets the button image. + * + * @deprecated DALi 1.0.50 + * + * @return An actor with the button image. + */ + Actor GetButtonImage() const; + + /** + * @brief Gets the selected image. + * + * @deprecated DALi 1.0.50 + * + * @return An actor with the selected image. + */ + Actor GetSelectedImage() const; + public: //Signals /** - * @brief Button Clicked signal type + * @brief Button signal type + */ + typedef Signal< bool ( Button ) > ButtonSignalType; + + /** + * @brief This signal is emitted when the button is touched. + * + * A callback of the following type may be connected: + * @code + * bool YourCallbackName( Button button ); + * @endcode + * @return The signal to connect to. */ - typedef Signal< bool ( Button ) > ClickedSignalType; + ButtonSignalType& PressedSignal(); /** - * @brief Button state changed signal type + * @brief This signal is emitted when the button is touched and the touch point leaves the boundary of the button. + * + * A callback of the following type may be connected: + * @code + * bool YourCallbackName( Button button ); + * @endcode + * @return The signal to connect to. */ - typedef Signal< bool ( Button, bool ) > StateChangedSignalType; + ButtonSignalType& ReleasedSignal(); /** - * @brief Signal emitted when the button is touched and the touch point doesn't leave the boundary of the button. + * @brief This signal is emitted when the button is touched and the touch point doesn't leave the boundary of the button. + * + * A callback of the following type may be connected: + * @code + * bool YourCallbackName( Button button ); + * @endcode + * @return The signal to connect to. */ - ClickedSignalType& ClickedSignal(); + ButtonSignalType& ClickedSignal(); /** - * @brief Signal emitted when the button's state is changed. + * @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. */ - StateChangedSignalType& StateChangedSignal(); + ButtonSignalType& StateChangedSignal(); public: // Not intended for application developers @@ -167,6 +439,9 @@ public: // Not intended for application developers DALI_INTERNAL Button( Dali::Internal::CustomActor* internal ); }; +/** + * @} + */ } // namespace Toolkit } // namespace Dali