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