Update doxygen comments
[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 ScrollCompletedSignal() |
50  * | scrollUpdated    | @ref ScrollUpdatedSignal()   |
51  * @SINCE_1_0.0
52  */
53 class DALI_IMPORT_API Scrollable : public Control
54 {
55 public:
56
57   /**
58    * @brief Enumeration for 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 Enumeration for the instance of properties belonging to the Scrollable class.
72    * @SINCE_1_0.0
73    */
74   struct Property
75   {
76     /**
77      * @brief Enumeration for the instance of properties belonging to the Scrollable class.
78      * @SINCE_1_0.0
79      */
80     enum
81     {
82       // Event side properties
83       OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshootEffectColor",      @see SetOvershootEffectColor(),    type Vector4 @SINCE_1_0.0
84       OVERSHOOT_ANIMATION_SPEED,                     ///< Property, name "overshootAnimationSpeed",   @see SetOvershootAnimationSpeed(), type float @SINCE_1_0.0
85       OVERSHOOT_ENABLED,                             ///< Property, name "overshootEnabled",          @see SetOvershootEnabled(),        type bool,    @SINCE_1_1.18
86       OVERSHOOT_SIZE,                                ///< Property, name "overshootSize",                                                type Vector2, @SINCE_1_1.31
87       SCROLL_TO_ALPHA_FUNCTION,                      ///< Property, name "scrollToAlphaFunction",                                        type int,     @SINCE_1_1.33
88
89       // Animatable properties
90       SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition",   type Vector2 @SINCE_1_0.0
91       SCROLL_POSITION_MIN,                                        ///< Property, name "scrollPositionMin",        type Vector2 @SINCE_1_0.0
92       SCROLL_POSITION_MIN_X,                                      ///< Property, name "scrollPositionMinX",       type float @SINCE_1_0.0
93       SCROLL_POSITION_MIN_Y,                                      ///< Property, name "scrollPositionMinY",       type float @SINCE_1_0.0
94       SCROLL_POSITION_MAX,                                        ///< Property, name "scrollPositionMax",        type Vector2 @SINCE_1_0.0
95       SCROLL_POSITION_MAX_X,                                      ///< Property, name "scrollPositionMaxX",       type float @SINCE_1_0.0
96       SCROLL_POSITION_MAX_Y,                                      ///< Property, name "scrollPositionMaxY",       type float @SINCE_1_0.0
97       CAN_SCROLL_VERTICAL,                                        ///< Property, name "canScrollVertical",        type bool @SINCE_1_0.0
98       CAN_SCROLL_HORIZONTAL                                       ///< Property, name "canScrollHorizontal",      type bool @SINCE_1_0.0
99     };
100   };
101
102   // Typedefs
103
104   typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType;   ///< ScrollStarted signal type @SINCE_1_0.0
105   typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type @SINCE_1_0.0
106   typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType;   ///< Scroll updated signal type @SINCE_1_0.0
107
108 public:
109
110   /**
111    * @brief Creates an uninitialized Scrollable handle.
112    * @SINCE_1_0.0
113    */
114   Scrollable();
115
116   /**
117    * @brief Copy constructor.
118    *
119    * Creates another handle that points to the same real object.
120    *
121    * @SINCE_1_0.0
122    * @param handle to copy from
123    */
124   Scrollable( const Scrollable& handle );
125
126   /**
127    * @brief Assignment operator.
128    *
129    * Changes this handle to point to another real object.
130    * @SINCE_1_0.0
131    * @param[in] handle Handle to copy from
132    * @return A reference to this
133    */
134   Scrollable& operator=( const Scrollable& handle );
135
136   /**
137    * @brief Destructor.
138    *
139    * This is non-virtual since derived Handle types must not contain data or virtual methods.
140    * @SINCE_1_0.0
141    */
142   ~Scrollable();
143
144   /**
145    * @brief Downcasts a handle to Scrollable handle.
146    *
147    * If handle points to a Scrollable, the downcast produces valid handle.
148    * If not, the returned handle is left uninitialized.
149    *
150    * @SINCE_1_0.0
151    * @param[in] handle Handle to an object
152    * @return A handle to a Scrollable or an uninitialized handle
153    */
154   static Scrollable DownCast( BaseHandle handle );
155
156   /**
157    * @brief Checks if scroll overshoot has been enabled or not.
158    *
159    * @SINCE_1_0.0
160    * @return Whether the scroll overshoot is enabled
161    */
162   bool IsOvershootEnabled() const;
163
164   /**
165    * @brief Sets whether to enables or disable scroll overshoot.
166    *
167    * @SINCE_1_0.0
168    * @param[in] enable Whether to enable the scroll overshoot or not
169    */
170   void SetOvershootEnabled(bool enable);
171
172   /**
173    * @brief Sets the color of the overshoot effect.
174    *
175    * @SINCE_1_0.0
176    * @param[in] color The color of the overshoot effect
177    */
178   void SetOvershootEffectColor( const Vector4& color );
179
180   /**
181    * @brief Gets the color of the overshoot effect.
182    * @SINCE_1_0.0
183    * @return The color of the overshoot effect
184    */
185   Vector4 GetOvershootEffectColor() const;
186
187   /**
188    * @brief Sets the speed of overshoot animation in pixels per second.
189    *
190    * When the speed is not greater than 0, the overshoot is set instantly with no animation.
191    * @SINCE_1_0.0
192    * @param[in] pixelsPerSecond The speed of the overshoot animation
193    */
194   void SetOvershootAnimationSpeed( float pixelsPerSecond );
195
196   /**
197    * @brief Gets the speed of overshoot animation in pixels per second.
198    * @SINCE_1_0.0
199    * @return The speed of the overshoot animation
200    */
201   float GetOvershootAnimationSpeed() const;
202
203 public: // Signals
204
205   /**
206    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
207    *
208    * A callback of the following type may be connected:
209    * @code
210    *   void YourCallbackName(const Vector2& currentScrollPosition);
211    * @endcode
212    * @SINCE_1_0.0
213    * @return The signal to connect to
214    * @pre The Object has been initialized.
215    */
216   ScrollStartedSignalType& ScrollStartedSignal();
217
218   /**
219    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
220    *
221    * A callback of the following type may be connected:
222    * @code
223    *   void YourCallbackName(const Vector2& currentScrollPosition);
224    * @endcode
225    * @SINCE_1_0.0
226    * @return The signal to connect to
227    * @pre The Object has been initialized.
228    */
229   ScrollUpdatedSignalType& ScrollUpdatedSignal();
230
231   /**
232    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
233    *
234    * A callback of the following type may be connected:
235    * @code
236    *   void YourCallbackName(const Vector2& currentScrollPosition);
237    * @endcode
238    * @SINCE_1_0.0
239    * @return The signal to connect to
240    * @pre The Object has been initialized.
241    */
242   ScrollCompletedSignalType& ScrollCompletedSignal();
243
244 public: // Not intended for application developers
245
246   /// @cond internal
247   /**
248    * @brief Creates a handle using the Toolkit::Internal implementation.
249    *
250    * @SINCE_1_0.0
251    * @param[in] implementation The Control implementation
252    */
253   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
254
255   /**
256    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
257    *
258    * @SINCE_1_0.0
259    * @param[in] internal A pointer to the internal CustomActor
260    */
261   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
262   /// @endcond
263 };
264
265 /**
266  * @}
267  */
268 } // namespace Toolkit
269
270 } // namespace Dali
271
272 #endif // __DALI_TOOLKIT_SCROLLABLE_H__