Merge "Fix for cursor. Avoid the jump of the grab handle when there is a mix of...
[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) 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 <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 /**
36  * @brief Slider is a control to enable sliding an indicator between two values
37  *
38  * Signals
39  * | %Signal Name      | Method                      |
40  * |-------------------|-----------------------------|
41  * | value-changed     | @ref ValueChangedSignal()   |
42  * | mark              | @ref MarkSignal()           |
43  */
44 class DALI_IMPORT_API Slider : public Control
45 {
46 public:
47
48   /**
49    * @brief The start and end property ranges for this control.
50    */
51   enum PropertyRange
52   {
53     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
54     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserving 1000 property indices
55   };
56
57   /**
58    * @brief An enumeration of properties belonging to the Slider class.
59    */
60   struct Property
61   {
62     enum
63     {
64       LOWER_BOUND = PROPERTY_START_INDEX, ///< Property, name "lower-bound",            type float
65       UPPER_BOUND,                        ///< Property, name "upper-bound",            type float
66       VALUE,                              ///< Property, name "value",                  type float
67       HIT_REGION,                         ///< Property, name "hit-region",             type Vector2
68       BACKING_REGION,                     ///< Property, name "backing-region",         type Vector2
69       HANDLE_REGION,                      ///< Property, name "handle-region",          type Vector2
70       BACKING_IMAGE_NAME,                 ///< Property, name "backing-image-name",     type std::string
71       HANDLE_IMAGE_NAME,                  ///< Property, name "handle-image-name",      type std::string
72       PROGRESS_IMAGE_NAME,                ///< Property, name "progress-image-name",    type std::string
73       POPUP_IMAGE_NAME,                   ///< Property, name "popup-image-name",       type std::string
74       POPUP_ARROW_IMAGE_NAME,             ///< Property, name "popup-arrow-image-name", type std::string
75       DISABLE_COLOR,                      ///< Property, name "disable-color",          type Vector4
76       POPUP_TEXT_COLOR,                   ///< Property, name "popup-text-color",       type Vector4
77       VALUE_PRECISION,                    ///< Property, name "value-precision",        type int
78       SHOW_POPUP,                         ///< Property, name "show-popup",             type bool
79       SHOW_VALUE,                         ///< Property, name "show-value",             type bool
80       ENABLED,                            ///< Property, name "enabled",                type bool
81       MARKS,                              ///< Property, name "marks",                  type Property::Array<float>
82       SNAP_TO_MARKS,                      ///< Property, name "snap-to-marks",          type bool
83       MARK_TOLERANCE,                     ///< Property, name "mark-tolerance",         type float
84     };
85   };
86
87 public:
88
89   /**
90    * Create the Slider control
91    * @return A handle to the Slider control.
92    */
93   static Slider New();
94
95   /**
96    * Creates an empty Slider handle
97    */
98   Slider();
99
100   /**
101    * Copy constructor. Creates another handle that points to the same real object
102    */
103   Slider( const Slider& handle );
104
105   /**
106    * Assignment operator. Changes this handle to point to another real object
107    */
108   Slider& operator=( const Slider& handle );
109
110   /**
111    * @brief Destructor
112    *
113    * This is non-virtual since derived Handle types must not contain data or virtual methods.
114    */
115   ~Slider();
116
117   /**
118    * Downcast an Object handle to Slider. If handle points to a Slider the
119    * downcast produces valid handle. If not the returned handle is left uninitialized.
120    * @param[in] handle Handle to an object
121    * @return handle to a Slider or an uninitialized handle
122    */
123   static Slider DownCast( BaseHandle handle );
124
125 public:
126
127   // Signals
128
129   // Value changed
130   typedef Signal< bool ( Slider, float ) > ValueChangedSignalType;
131   typedef Signal< bool ( Slider, int ) > MarkSignalType;
132
133   /**
134    * Signal emitted when the slider value changes
135    */
136   ValueChangedSignalType& ValueChangedSignal();
137
138   /**
139    * Signal emitted when the sliding is finished
140    */
141   ValueChangedSignalType& SlidingFinishedSignal();
142
143   /**
144    * Signal emitted when the slider handle reaches a mark
145    */
146   MarkSignalType& MarkSignal();
147
148 public: // Not intended for application developers
149
150   /**
151    * Creates a handle using the Toolkit::Internal implementation.
152    * @param[in]  implementation  The Control implementation.
153    */
154   DALI_INTERNAL Slider(Internal::Slider& implementation);
155
156   /**
157    * Allows the creation of this Control from an Internal::CustomActor pointer.
158    * @param[in]  internal  A pointer to the internal CustomActor.
159    */
160   explicit DALI_INTERNAL Slider( Dali::Internal::CustomActor* internal );
161 };
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif // __DALI_TOOLKIT_SLIDER_H__