Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / button.h
1 #ifndef __DALI_TOOLKIT_BUTTON_H__
2 #define __DALI_TOOLKIT_BUTTON_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class Button;
33 }
34
35 /**
36  * @brief Button is a base class for different kind of buttons.
37  *
38  * This class provides the disabled property and the clicked signal.
39  *
40  * A ClickedSignal() is emitted when the button is touched and the touch
41  * point doesn't leave the boundary of the button.
42  *
43  * When the \e disabled property is set to \e true, no signal is emitted.
44  */
45 class DALI_IMPORT_API Button : public Control
46 {
47 public:
48
49   // Signal Names
50   static const char* const SIGNAL_CLICKED;       ///< name "clicked"
51   static const char* const SIGNAL_STATE_CHANGED; ///< name "state-changed"
52
53   // Properties
54   static const Property::Index PROPERTY_DISABLED;                     ///< name "disabled",                     @see SetDisabled(),                  type BOOLEAN
55   static const Property::Index PROPERTY_AUTO_REPEATING;               ///< name "auto-repeating",               @see SetAutoRepeating(),             type BOOLEAN
56   static const Property::Index PROPERTY_INITIAL_AUTO_REPEATING_DELAY; ///< name "initial-auto-repeating-delay", @see SetInitialAutoRepeatingDelay(), type FLOAT
57   static const Property::Index PROPERTY_NEXT_AUTO_REPEATING_DELAY;    ///< name "next-auto-repeating-delay",    @see SetNextAutoRepeatingDelay(),    type FLOAT
58   static const Property::Index PROPERTY_TOGGLABLE;                    ///< name "togglable",                    @see SetToggleButton(),              type BOOLEAN
59   static const Property::Index PROPERTY_TOGGLED;                      ///< name "toggled",                      @see SetToggled(),                   type BOOLEAN
60   static const Property::Index PROPERTY_NORMAL_STATE_ACTOR;           ///< name "button-state-actor",           @see SetButtonImage(),               type MAP
61   static const Property::Index PROPERTY_SELECTED_STATE_ACTOR;         ///< name "selected-state-actor",         @see SetSelectedImage(),             type MAP
62   static const Property::Index PROPERTY_DISABLED_STATE_ACTOR;         ///< name "disabled-state-actor",         @see SetDisabledImage(),             type MAP
63   static const Property::Index PROPERTY_LABEL_ACTOR;                  ///< name "label-actor",                  @see SetLabel(),                     type MAP
64
65 public:
66
67   /**
68    * @brief Create an uninitialized Button.
69    *
70    * Only derived versions can be instantiated.  Calling member
71    * functions with an uninitialized Dali::Object is not allowed.
72    */
73   Button();
74
75   /**
76    * @brief Copy constructor.
77    */
78   Button( const Button& button );
79
80   /**
81    * @brief Assignment operator.
82    */
83   Button& operator=( const Button& button );
84
85   /**
86    * @brief Downcast an Object handle to Button.
87    *
88    * If handle points to a Button the downcast produces valid
89    * handle. If not the returned handle is left uninitialized.
90    *
91    * @param[in] handle Handle to an object
92    * @return handle to a Button or an uninitialized handle
93    */
94   static Button DownCast( BaseHandle handle );
95
96   /**
97    * @brief Destructor
98    *
99    * This is non-virtual since derived Handle types must not contain data or virtual methods.
100    */
101   ~Button();
102
103   /**
104    * @brief Sets the button as \e disabled.
105    *
106    * No signals are emitted when the \e disabled property is set.
107    *
108    * @param[in] disabled property.
109    */
110   void SetDisabled( bool disabled );
111
112   /**
113    * @return \e true if the button is \e disabled.
114    */
115   bool IsDisabled() const;
116
117   /**
118    * @brief Sets the animation time.
119    *
120    * @param [in] animationTime The animation time in seconds.
121    */
122   void SetAnimationTime( float animationTime );
123
124   /**
125    * @brief Retrieves button's animation time.
126    *
127    * @return The animation time in seconds.
128    */
129   float GetAnimationTime() const;
130
131 public: //Signals
132
133   /**
134    * @brief Button Clicked signal type
135    */
136   typedef Signal< bool ( Button ) > ClickedSignalType;
137
138   /**
139    * @brief Button state changed signal type
140    */
141   typedef Signal< bool ( Button, bool ) > StateChangedSignalType;
142
143   /**
144    * @brief Signal emitted when the button is touched and the touch point doesn't leave the boundary of the button.
145    */
146   ClickedSignalType& ClickedSignal();
147
148   /**
149    * @brief Signal emitted when the button's state is changed.
150    */
151   StateChangedSignalType& StateChangedSignal();
152
153 public: // Not intended for application developers
154
155   /**
156    * @brief Creates a handle using the Toolkit::Internal implementation.
157    *
158    * @param[in]  implementation  The Control implementation.
159    */
160   DALI_INTERNAL Button( Internal::Button& implementation );
161
162   /**
163    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
164    *
165    * @param[in]  internal  A pointer to the internal CustomActor.
166    */
167   DALI_INTERNAL Button( Dali::Internal::CustomActor* internal );
168 };
169
170 } // namespace Toolkit
171
172 } // namespace Dali
173
174 #endif // __DALI_TOOLKIT_BUTTON_H__