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