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