Formatting API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / slider / slider.h
1 #ifndef DALI_TOOLKIT_SLIDER_H
2 #define DALI_TOOLKIT_SLIDER_H
3
4 /*
5  * Copyright (c) 2020 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 namespace Toolkit
27 {
28 namespace Internal DALI_INTERNAL
29 {
30 class Slider;
31 }
32 /**
33  * @addtogroup dali_toolkit_controls_slider
34  * @{
35  */
36
37 /**
38  * @brief Slider is a control to enable sliding an indicator between two values.
39  *
40  * Signals
41  * | %Signal Name      | Method                        |
42  * |-------------------|-------------------------------|
43  * | valueChanged      | @ref ValueChangedSignal()     |
44  * | markReached       | @ref MarkReachedSignal()      |
45  * | slidingFinished   | @ref SlidingFinishedSignal()  |
46  * @SINCE_1_1.39
47  */
48 class DALI_TOOLKIT_API Slider : public Control
49 {
50 public:
51   // Properties
52
53   /**
54    * @brief Enumeration for the start and end property ranges for this control.
55    * @SINCE_1_1.39
56    */
57   enum PropertyRange
58   {
59     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_1.39
60     PROPERTY_END_INDEX   = PROPERTY_START_INDEX + 1000              ///< Reserve property indices @SINCE_1_1.39
61   };
62
63   /**
64    * @brief Enumeration for the instance of properties belonging to the Slider class.
65    * @SINCE_1_1.39
66    */
67   struct Property
68   {
69     /**
70      * @brief Enumeration for the instance of properties belonging to the Slider class.
71      * @SINCE_1_1.39
72      */
73     enum
74     {
75
76       /**
77        * @brief name "lowerBound", type float.
78        * @SINCE_1_1.39
79        */
80       LOWER_BOUND = PROPERTY_START_INDEX,
81
82       /**
83        * @brief name "upperBound", type float.
84        * @SINCE_1_1.39
85        */
86       UPPER_BOUND,
87
88       /**
89        * @brief name "value", type float.
90        * @SINCE_1_1.39
91        */
92       VALUE,
93
94       /**
95        * @brief name "trackVisual", type string if it is a url, map otherwise.
96        * @SINCE_1_1.39
97        */
98       TRACK_VISUAL,
99
100       /**
101        * @brief name "handleVisual", type string if it is a url, map otherwise.
102        * @SINCE_1_1.39
103        */
104       HANDLE_VISUAL,
105
106       /**
107        * @brief name "progressVisual", type string if it is a url, map otherwise.
108        * @SINCE_1_1.39
109        */
110       PROGRESS_VISUAL,
111
112       /**
113        * @brief name "popupVisual", type string if it is a url, map otherwise.
114        * @SINCE_1_1.39
115        */
116       POPUP_VISUAL,
117
118       /**
119        * @brief name "popupArrowVisual", type string if it is a url, map otherwise.
120        * @SINCE_1_1.39
121        */
122       POPUP_ARROW_VISUAL,
123
124       /**
125        * @brief name "disabledColor", type Vector4.
126        * @SINCE_1_1.39
127        */
128       DISABLED_COLOR,
129
130       /**
131        * @brief name "valuePrecision", type int.
132        * @SINCE_1_1.39
133        */
134       VALUE_PRECISION,
135
136       /**
137        * @brief name "showPopup", type bool.
138        * @SINCE_1_1.39
139        */
140       SHOW_POPUP,
141
142       /**
143        * @brief name "showValue", type bool.
144        * @SINCE_1_1.39
145        */
146       SHOW_VALUE,
147
148       /**
149        * @brief name "marks", type Property::Array<float>.
150        * @SINCE_1_1.39
151        */
152       MARKS,
153
154       /**
155        * @brief name "snapToMarks", type bool.
156        * @SINCE_1_1.39
157        */
158       SNAP_TO_MARKS,
159
160       /**
161        * @brief name "markTolerance", type float.
162        * @SINCE_1_1.39
163        */
164       MARK_TOLERANCE,
165     };
166   };
167
168 public:
169   /**
170    * @brief Creates the Slider control.
171    * @SINCE_1_1.39
172    * @return A handle to the Slider control
173    */
174   static Slider New();
175
176   /**
177    * @brief Creates an empty Slider handle.
178    * @SINCE_1_1.39
179    */
180   Slider();
181
182   /**
183    * @brief Copy constructor.
184    *
185    * Creates another handle that points to the same real object.
186    * @SINCE_1_1.39
187    * @param[in] handle Handle to an object
188    */
189   Slider(const Slider& handle);
190
191   /**
192    * @brief Move constructor
193    * @SINCE_1_9.23
194    *
195    * @param[in] rhs A reference to the moved handle
196    */
197   Slider(Slider&& rhs);
198
199   /**
200    * @brief Assignment operator.
201    *
202    * Changes this handle to point to another real object.
203    * @SINCE_1_1.39
204    * @param[in] handle Handle to an object
205    * @return A reference to this
206    */
207   Slider& operator=(const Slider& handle);
208
209   /**
210    * @brief Move assignment
211    * @SINCE_1_9.23
212    *
213    * @param[in] rhs A reference to the moved handle
214    * @return A reference to this
215    */
216   Slider& operator=(Slider&& rhs);
217
218   /**
219    * @brief Destructor.
220    *
221    * This is non-virtual since derived Handle types must not contain data or virtual methods.
222    * @SINCE_1_1.39
223    */
224   ~Slider();
225
226   /**
227    * @brief Downcasts an Object handle to Slider.
228    *
229    * If handle points to a Slider, the downcast produces valid handle.
230    * If not, the returned handle is left uninitialized.
231    * @SINCE_1_1.39
232    * @param[in] handle Handle to an object
233    * @return handle to a Slider or an uninitialized handle
234    */
235   static Slider DownCast(BaseHandle handle);
236
237 public: // Signals
238   /**
239    * @brief Value changed signal type.
240    * @SINCE_1_1.39
241    */
242   typedef Signal<bool(Slider, float)> ValueChangedSignalType;
243
244   /**
245    * @brief Mark reached signal type.
246    * @SINCE_1_1.39
247    */
248   typedef Signal<bool(Slider, int)> MarkReachedSignalType;
249
250   /**
251    * @brief Signal emitted when the slider value changes.
252    *
253    * A callback of the following type may be connected:
254    * @code
255    *   bool YourCallbackName( Slider slider, float value );
256    * @endcode
257    * @SINCE_1_1.39
258    * @return The signal to connect to
259    */
260   ValueChangedSignalType& ValueChangedSignal();
261
262   /**
263    * @brief Signal emitted when the sliding is finished.
264    *
265    * A callback of the following type may be connected:
266    * @code
267    *   bool YourCallbackName( Slider slider, float value );
268    * @endcode
269    * @SINCE_1_1.39
270    * @return The signal to connect to
271    */
272   ValueChangedSignalType& SlidingFinishedSignal();
273
274   /**
275    * @brief Signal emitted when the slider handle reaches a mark.
276    *
277    * A callback of the following type may be connected:
278    * @code
279    *   bool YourCallbackName( Slider slider, int value );
280    * @endcode
281    * @SINCE_1_1.39
282    * @return The signal to connect to
283    */
284   MarkReachedSignalType& MarkReachedSignal();
285
286 public: // Not intended for application developers
287   /// @cond internal
288   /**
289    * @brief Creates a handle using the Toolkit::Internal implementation.
290    *
291    * @SINCE_1_1.39
292    * @param[in] implementation The Control implementation
293    */
294   DALI_INTERNAL Slider(Internal::Slider& implementation);
295
296   /**
297    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
298    *
299    * @SINCE_1_1.39
300    * @param[in] internal A pointer to the internal CustomActor
301    */
302   explicit DALI_INTERNAL Slider(Dali::Internal::CustomActor* internal);
303   /// @endcond
304 };
305
306 /**
307  * @}
308  */
309 } // namespace Toolkit
310
311 } // namespace Dali
312
313 #endif // DALI_TOOLKIT_SLIDER_H