remove (dead) ImageView UI control
[platform/core/uifw/dali-toolkit.git] / base / 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) 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 "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 PushButton::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
43  * and a PushButton::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 PushButton::PressedSignal(), PushButton::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 toggle button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e toggled property is set to
55  *       false but no signal is emitted.
56  *
57  *   <li>\e toggle
58  *
59  *       When \e toggle is set to \e true, a Button::StateChangedSignal() signal is emitted, with the toggle state, every time the button is touched instead
60  *       of emit PushButton::PressedSignal(), Button::ClickedSignal() and PushButton::ReleasedSignal() signals.
61  *
62  *       An \e autorepeating button can't be \e toggle. If the \e toggled 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   //Signal Names
83   static const char* const SIGNAL_PRESSED; ///< name "pressed"
84   static const char* const SIGNAL_RELEASED; ///< name "released"
85
86   //Action Names
87   static const char* const ACTION_PUSH_BUTTON_CLICK; ///< name "push-button-click"
88
89 public:
90
91   /**
92    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
93    *
94    * Calling member functions with an uninitialized Dali::Object is not allowed.
95    */
96   PushButton();
97
98   /**
99    * @brief Copy constructor.
100    */
101   PushButton( const PushButton& pushButton );
102
103   /**
104    * @brief Assignment operator.
105    */
106   PushButton& operator=( const PushButton& pushButton );
107
108   /**
109    * @brief Destructor
110    *
111    * This is non-virtual since derived Handle types must not contain data or virtual methods.
112    */
113   ~PushButton();
114
115   /**
116    * @brief Create an initialized PushButton.
117    *
118    * @return A handle to a newly allocated Dali resource.
119    */
120   static PushButton New();
121
122   /**
123    * @brief Downcast an Object handle to PushButton.
124    *
125    * If handle points to a PushButton the downcast produces valid
126    * handle. If not the returned handle is left uninitialized.
127    *
128    * @param[in] handle Handle to an object
129    * @return handle to a PushButton or an uninitialized handle
130    */
131   static PushButton DownCast( BaseHandle handle );
132
133   /**
134    * @brief Sets the \e autorepeating property.
135    *
136    * If the \e autorepeating property is set to \e true, then the \e toggled property is set to false
137    * but no signal is emitted.
138    *
139    * @param[in] autoRepeating \e autorepeating property.
140    */
141   void SetAutoRepeating( bool autoRepeating );
142
143   /**
144    * @return \e true if the \e autorepeating property is set.
145    */
146   bool IsAutoRepeating() const;
147
148   /**
149    * @brief Sets the initial autorepeating delay.
150    *
151    * By default this value is set to 0.15 seconds.
152    *
153    * @pre initialAutoRepeatingDelay must be greater than zero.
154    * @param[in] initialAutoRepeatingDelay in seconds.
155    */
156   void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
157
158   /**
159    * @return the initial autorepeating delay in seconds.
160    */
161   float GetInitialAutoRepeatingDelay() const;
162
163   /**
164    * @brief Sets the next autorepeating delay.
165    *
166    * By default this value is set to 0.05 seconds.
167    *
168    * @pre nextAutoRepeatingDelay must be greater than zero.
169    * @param[in] nextAutoRepeatingDelay in seconds.
170    */
171   void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
172
173   /**
174    * @return the next autorepeating delay in seconds.
175    */
176   float GetNextAutoRepeatingDelay() const;
177
178   /**
179    * @brief Sets the \e toggled property.
180    *
181    * If the \e toggled property is set to \e true, then the \e autorepeating property is set to false.
182    *
183    * @param[in] toggle property.
184    */
185   void SetToggleButton( bool toggle );
186
187   /**
188    * @return \e true if the \e toggled property is set.
189    */
190   bool IsToggleButton() const;
191
192   /**
193    * @brief Sets the button as toggled or not toggled.
194    *
195    * \e toggled property must be set to \e true.
196    *
197    * Emits a Button::StateChangedSignal() signal.
198    *
199    * @param[in] toggle state.
200    */
201   void SetToggled( bool toggle );
202
203   /**
204    * @return \e true if the \e toggled property is set and the button is toggled.
205    */
206   bool IsToggled() const;
207
208   /**
209    * @brief Sets the button image.
210    *
211    * @param[in] image The button image.
212    */
213   void SetButtonImage( Image image );
214
215   /**
216    * @copydoc SetButtonImage( Image image )
217    */
218   void SetButtonImage( Actor image );
219
220   /**
221    * @brief Gets the button image.
222    *
223    * @return An actor with the button image.
224    */
225   Actor GetButtonImage() const;
226
227   /**
228    * @brief Sets the background image.
229    *
230    * @param[in] image The background image.
231    */
232   void SetBackgroundImage( Image image );
233
234   /**
235    * @copydoc SetBackgroundImage( Image image )
236    */
237   void SetBackgroundImage( Actor image );
238
239   /**
240    * @brief Gets the background image.
241    *
242    * @return An actor with the background image.
243    */
244   Actor GetBackgroundImage() const;
245
246   /**
247    * @brief Sets the selected image.
248    *
249    * @param[in] image The selected image.
250    */
251   void SetSelectedImage( Image image );
252
253   /**
254    * @copydoc SetSelectedImage( Image image )
255    */
256   void SetSelectedImage( Actor image );
257
258   /**
259    * @brief Gets the selected image.
260    *
261    * @return An actor with the selected image.
262    */
263   Actor GetSelectedImage() const;
264
265   /**
266    * @brief Sets the disabled background image.
267    *
268    * @param[in] image The disabled background image.
269    */
270   void SetDisabledBackgroundImage( Image image );
271
272   /**
273    * @copydoc SetDisabledBackgroundImage( Image image )
274    */
275   void SetDisabledBackgroundImage( Actor image );
276
277   /**
278    * @brief Gets the disabled background image.
279    *
280    * @return An actor with the disabled background image.
281    */
282   Actor GetDisabledBackgroundImage() const;
283
284   /**
285    * @brief Sets the disabled button image.
286    *
287    * @param[in] image The disabled button image.
288    */
289   void SetDisabledImage( Image image );
290
291   /**
292    * @copydoc SetDisabledImage( Image image )
293    */
294   void SetDisabledImage( Actor image );
295
296   /**
297    * @brief Gets the disabled image.
298    *
299    * @return An actor with the disabled image.
300    */
301   Actor GetDisabledImage() const;
302
303   /**
304    * @brief Sets the button label.
305    *
306    * @param[in] label The button label.
307    */
308   void SetLabel( const std::string& label );
309
310   /**
311    * @copydoc SetLabel( const std::string& label )
312    */
313   void SetLabel( Actor label );
314
315   /**
316    * @brief Gets the label.
317    *
318    * @return An actor with the label.
319    */
320   Actor GetLabel() const;
321
322 public: //Signals
323
324   /// @brief PushButton Pressed signal type.
325   typedef Signal< bool ( Button ) > PressedSignalType;
326
327   /// @brief PushButton Released signal type.
328   typedef Signal< bool ( Button ) > ReleasedSignalType;
329
330   /**
331    * @brief Signal emitted when the button is touched.
332    */
333   PressedSignalType& PressedSignal();
334
335   /**
336    * @brief Signal emitted when the button is touched and the touch point leaves the boundary of the button.
337    */
338   ReleasedSignalType& ReleasedSignal();
339
340 public: // Not intended for application developers
341
342   /**
343    * @brief Creates a handle using the Toolkit::Internal implementation.
344    *
345    * @param[in]  implementation  The Control implementation.
346    */
347   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
348
349   /**
350    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
351    *
352    * @param[in]  internal  A pointer to the internal CustomActor.
353    */
354   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
355 };
356
357 } // namespace Toolkit
358
359 } // namespace Dali
360
361 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__