Apply the new doxygen tagging rule for @SINCE
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scrollable.h
1 #ifndef __DALI_TOOLKIT_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_SCROLLABLE_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 Scrollable;
33 }
34 /**
35  * @addtogroup dali_toolkit_controls_scrollable
36  * @{
37  */
38
39 /**
40  * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
41  * (via touch) or automatically.
42  *
43  * Scrollables such as ScrollView and ItemView can be derived from this class.
44  *
45  * Signals
46  * | %Signal Name     | Method                       |
47  * |------------------|------------------------------|
48  * | scrollStarted    | @ref ScrollStartedSignal()   |
49  * | scrollCompleted  | @ref ScrollUpdatedSignal()   |
50  * | scrollUpdated    | @ref ScrollCompletedSignal() |
51  * @SINCE_1_0.0
52  */
53 class DALI_IMPORT_API Scrollable : public Control
54 {
55 public:
56
57   /**
58    * @brief The start and end property ranges for this control.
59    * @SINCE_1_0.0
60    */
61   enum PropertyRange
62   {
63     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
64     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,             ///< Reserve property indices @SINCE_1_0.0
65
66     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
67     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000              ///< Reserve animatable property indices @SINCE_1_0.0
68   };
69
70   /**
71    * @brief An enumeration of properties belonging to the Scrollable class.
72    * @SINCE_1_0.0
73    */
74   struct Property
75   {
76     enum
77     {
78       // Event side properties
79       OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshootEffectColor",      @see SetOvershootEffectColor(),    type Vector4 @SINCE_1_0.0
80       OVERSHOOT_ANIMATION_SPEED,                     ///< Property, name "overshootAnimationSpeed",   @see SetOvershootAnimationSpeed(), type float @SINCE_1_0.0
81       OVERSHOOT_ENABLED,                             ///< Property, name "overshootEnabled",          @see SetOvershootEnabled(),        type bool,    @SINCE_1_1.18
82
83       // Animatable properties
84       SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition",   type Vector2 @SINCE_1_0.0
85       SCROLL_POSITION_MIN,                                        ///< Property, name "scrollPositionMin",        type Vector2 @SINCE_1_0.0
86       SCROLL_POSITION_MIN_X,                                      ///< Property, name "scrollPositionMinX",       type float @SINCE_1_0.0
87       SCROLL_POSITION_MIN_Y,                                      ///< Property, name "scrollPositionMinY",       type float @SINCE_1_0.0
88       SCROLL_POSITION_MAX,                                        ///< Property, name "scrollPositionMax",        type Vector2 @SINCE_1_0.0
89       SCROLL_POSITION_MAX_X,                                      ///< Property, name "scrollPositionMaxX",       type float @SINCE_1_0.0
90       SCROLL_POSITION_MAX_Y,                                      ///< Property, name "scrollPositionMaxY",       type float @SINCE_1_0.0
91       CAN_SCROLL_VERTICAL,                                        ///< Property, name "canScrollVertical",        type bool @SINCE_1_0.0
92       CAN_SCROLL_HORIZONTAL                                       ///< Property, name "canScrollHorizontal",      type bool @SINCE_1_0.0
93     };
94   };
95
96   // Typedefs
97
98   typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType;   ///< ScrollStarted signal type @SINCE_1_0.0
99   typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type @SINCE_1_0.0
100   typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType;   ///< Scroll updated signal type @SINCE_1_0.0
101
102 public:
103
104   /**
105    * @brief Creates an uninitialized Scrollable handle.
106    * @SINCE_1_0.0
107    */
108   Scrollable();
109
110   /**
111    * @brief Copy constructor.
112    *
113    * Creates another handle that points to the same real object
114    *
115    * @SINCE_1_0.0
116    * @param handle to copy from
117    */
118   Scrollable( const Scrollable& handle );
119
120   /**
121    * @brief Assignment operator.
122    *
123    * Changes this handle to point to another real object
124    * @SINCE_1_0.0
125    * @param[in] handle to copy from
126    * @return A reference to this
127    */
128   Scrollable& operator=( const Scrollable& handle );
129
130   /**
131    * @brief Destructor
132    *
133    * This is non-virtual since derived Handle types must not contain data or virtual methods.
134    * @SINCE_1_0.0
135    */
136   ~Scrollable();
137
138   /**
139    * @brief Downcast an Object handle to Scrollable.
140    *
141    * If handle points to a Scrollable the downcast produces valid
142    * handle. If not the returned handle is left uninitialized.
143    *
144    * @SINCE_1_0.0
145    * @param[in] handle Handle to an object
146    * @return handle to a Scrollable or an uninitialized handle
147    */
148   static Scrollable DownCast( BaseHandle handle );
149
150   /**
151    * @brief Checks if scroll overshoot has been enabled or not.
152    *
153    * @SINCE_1_0.0
154    * @return Whether the scroll obvershoot is enabled
155    */
156   bool IsOvershootEnabled() const;
157
158   /**
159    * @brief Sets whether to enables or disable scroll overshoot.
160    *
161    * @SINCE_1_0.0
162    * @param[in] enable Whether to enable the scroll obvershoot or not
163    */
164   void SetOvershootEnabled(bool enable);
165
166   /**
167    * @brief Set the color of the overshoot effect.
168    *
169    * @SINCE_1_0.0
170    * @param[in] color The color of the overshoot effect.
171    */
172   void SetOvershootEffectColor( const Vector4& color );
173
174   /**
175    * @brief Get the color of the overshoot effect.
176    * @SINCE_1_0.0
177    * @return The color of the overshoot effect.
178    */
179   Vector4 GetOvershootEffectColor() const;
180
181   /**
182    * @brief Set the speed of overshoot animation in pixels per second.
183    * When the speed is not greater than 0, the overshoot is set instantly with no animation.
184    * @SINCE_1_0.0
185    * @param[in] pixelsPerSecond The speed of the overshoot animation.
186    */
187   void SetOvershootAnimationSpeed( float pixelsPerSecond );
188
189   /**
190    * @brief Get the speed of overshoot animation in pixels per second.
191    * @SINCE_1_0.0
192    * @return The speed of the overshoot animation.
193    */
194   float GetOvershootAnimationSpeed() const;
195
196 public: // Signals
197
198   /**
199    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
200    *
201    * A callback of the following type may be connected:
202    * @code
203    *   void YourCallbackName(const Vector2& currentScrollPosition);
204    * @endcode
205    * @SINCE_1_0.0
206    * @return The signal to connect to.
207    * @pre The Object has been initialized.
208    */
209   ScrollStartedSignalType& ScrollStartedSignal();
210
211   /**
212    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
213    *
214    * A callback of the following type may be connected:
215    * @code
216    *   void YourCallbackName(const Vector2& currentScrollPosition);
217    * @endcode
218    * @SINCE_1_0.0
219    * @return The signal to connect to.
220    * @pre The Object has been initialized.
221    */
222   ScrollUpdatedSignalType& ScrollUpdatedSignal();
223
224   /**
225    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
226    *
227    * A callback of the following type may be connected:
228    * @code
229    *   void YourCallbackName(const Vector2& currentScrollPosition);
230    * @endcode
231    * @SINCE_1_0.0
232    * @return The signal to connect to.
233    * @pre The Object has been initialized.
234    */
235   ScrollCompletedSignalType& ScrollCompletedSignal();
236
237 public: // Not intended for application developers
238
239   /**
240    * @brief Creates a handle using the Toolkit::Internal implementation.
241    *
242    * @SINCE_1_0.0
243    * @param[in]  implementation  The Control implementation.
244    */
245   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
246
247   /**
248    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
249    *
250    * @SINCE_1_0.0
251    * @param[in]  internal  A pointer to the internal CustomActor.
252    */
253   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
254 };
255
256 /**
257  * @}
258  */
259 } // namespace Toolkit
260
261 } // namespace Dali
262
263 #endif // __DALI_TOOLKIT_SCROLLABLE_H__