a74610abad2f014c91d7b067a661f9d40b348557
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / push-button.h
1 #ifndef __DALI_TOOLKIT_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_PUSH_BUTTON_H__
3
4 /*
5  * Copyright (c) 2015 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 "button.h"
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 // Forward declarations
31
32 namespace Internal DALI_INTERNAL
33 {
34 // Forward declarations
35
36 class PushButton;
37 }
38
39 /**
40  * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
41  *
42  * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
43  * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
44  *
45  * PushButton provides the following properties which modify signals emitted:
46  * <ul>
47  *   <li>\e autorepeating
48  *
49  *       When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
50  *       intervals while the button is touched.
51  *
52  *       The intervals could be modified with the PushButton::SetInitialAutoRepeatingDelay and PushButton::SetNextAutoRepeatingDelay methods.
53  *
54  *       A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
55  *       false but no signal is emitted.
56  *
57  *   <li>\e togglable
58  *
59  *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state, every time the button is touched instead
60  *       of emit Button::PressedSignal(), Button::ClickedSignal() and Button::ReleasedSignal() signals.
61  *
62  *       An \e autorepeating button can't be \e togglable. If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
63  * </ul>
64  *
65  * The button's appearance could be modified by setting images or actors with PushButton::SetButtonImage, PushButton::SetBackgroundImage,
66  * PushButton::SetSelectedImage, PushButton::SetDisabledBackgroundImage and  PushButton::SetDisabledImage or setting a text with
67  * PushButton::SetLabel.
68  *
69  * 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
70  * 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.
71  *
72  * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
73  *
74  * The methods used to modify the button's appearance could receive Dali::Actor objects as a parameter, so more complex images could be defined.
75  *
76  * 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.
77  */
78 class DALI_IMPORT_API PushButton : public Button
79 {
80 public:
81
82   /**
83    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
84    *
85    * Calling member functions with an uninitialized Dali::Object is not allowed.
86    */
87   PushButton();
88
89   /**
90    * @brief Copy constructor.
91    */
92   PushButton( const PushButton& pushButton );
93
94   /**
95    * @brief Assignment operator.
96    */
97   PushButton& operator=( const PushButton& pushButton );
98
99   /**
100    * @brief Destructor
101    *
102    * This is non-virtual since derived Handle types must not contain data or virtual methods.
103    */
104   ~PushButton();
105
106   /**
107    * @brief Create an initialized PushButton.
108    *
109    * @return A handle to a newly allocated Dali resource.
110    */
111   static PushButton New();
112
113   /**
114    * @brief Downcast an Object handle to PushButton.
115    *
116    * If handle points to a PushButton the downcast produces valid
117    * handle. If not the returned handle is left uninitialized.
118    *
119    * @param[in] handle Handle to an object
120    * @return handle to a PushButton or an uninitialized handle
121    */
122   static PushButton DownCast( BaseHandle handle );
123
124   using Button::SetButtonImage;
125
126   /**
127    * @brief SetButtonImage
128    *
129    * @param[in] image The Actor to be used as the button image.
130    *
131    * The natural size of the button would be the size of this Actor
132    * if it's larger than the background and label
133    */
134   void SetButtonImage( Actor image );
135
136   /**
137    * @brief Gets the button image.
138    *
139    * @return An actor with the button image.
140    */
141   Actor GetButtonImage() const;
142
143   using Button::SetBackgroundImage;
144
145   /**
146    * @brief SetBackgroundImage
147    *
148    * @param[in] image The Actor to be used as the background image.
149    *
150    * The natural size of the button would be the size of this Actor
151    * if it's larger than the button and label
152    */
153   void SetBackgroundImage( Actor image );
154
155   /**
156    * @brief Gets the background image.
157    *
158    * @return An actor with the background image.
159    */
160   Actor GetBackgroundImage() const;
161
162   using Button::SetSelectedImage;
163
164   /**
165    * @copydoc SetSelectedImage( Image image )
166    */
167   void SetSelectedImage( Actor image );
168
169   /**
170    * @brief Gets the selected image.
171    *
172    * @return An actor with the selected image.
173    */
174   Actor GetSelectedImage() const;
175
176   using Button::SetSelectedBackgroundImage;
177
178   /**
179    * @copydoc SetSelectedBackgroundImage( Image image )
180    */
181   void SetSelectedBackgroundImage( Actor image );
182
183   /**
184    * @brief Gets the selected background image.
185    *
186    * @return An actor with the selected background image.
187    */
188   Actor GetSelectedBackgroundImage() const;
189
190   using Button::SetDisabledBackgroundImage;
191
192   /**
193    * @copydoc SetDisabledBackgroundImage( Image image )
194    */
195   void SetDisabledBackgroundImage( Actor image );
196
197   /**
198    * @brief Gets the disabled background image.
199    *
200    * @return An actor with the disabled background image.
201    */
202   Actor GetDisabledBackgroundImage() const;
203
204   using Button::SetDisabledImage;
205
206   /**
207    * @copydoc SetDisabledImage( Image image )
208    */
209   void SetDisabledImage( Actor image );
210
211   /**
212    * @brief Gets the disabled image.
213    *
214    * @return An actor with the disabled image.
215    */
216   Actor GetDisabledImage() const;
217
218 public: // Not intended for application developers
219
220   /**
221    * @brief Creates a handle using the Toolkit::Internal implementation.
222    *
223    * @param[in]  implementation  The Control implementation.
224    */
225   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
226
227   /**
228    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
229    *
230    * @param[in]  internal  A pointer to the internal CustomActor.
231    */
232   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
233 };
234
235 } // namespace Toolkit
236
237 } // namespace Dali
238
239 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__