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