Merge "Fix for font validation." into devel/master
[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 a handle to Scrollable handle.
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 A 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 overshoot 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 overshoot 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    *
184    * When the speed is not greater than 0, the overshoot is set instantly with no animation.
185    * @SINCE_1_0.0
186    * @param[in] pixelsPerSecond The speed of the overshoot animation.
187    */
188   void SetOvershootAnimationSpeed( float pixelsPerSecond );
189
190   /**
191    * @brief Get the speed of overshoot animation in pixels per second.
192    * @SINCE_1_0.0
193    * @return The speed of the overshoot animation.
194    */
195   float GetOvershootAnimationSpeed() const;
196
197 public: // Signals
198
199   /**
200    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
201    *
202    * A callback of the following type may be connected:
203    * @code
204    *   void YourCallbackName(const Vector2& currentScrollPosition);
205    * @endcode
206    * @SINCE_1_0.0
207    * @return The signal to connect to.
208    * @pre The Object has been initialized.
209    */
210   ScrollStartedSignalType& ScrollStartedSignal();
211
212   /**
213    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
214    *
215    * A callback of the following type may be connected:
216    * @code
217    *   void YourCallbackName(const Vector2& currentScrollPosition);
218    * @endcode
219    * @SINCE_1_0.0
220    * @return The signal to connect to.
221    * @pre The Object has been initialized.
222    */
223   ScrollUpdatedSignalType& ScrollUpdatedSignal();
224
225   /**
226    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
227    *
228    * A callback of the following type may be connected:
229    * @code
230    *   void YourCallbackName(const Vector2& currentScrollPosition);
231    * @endcode
232    * @SINCE_1_0.0
233    * @return The signal to connect to.
234    * @pre The Object has been initialized.
235    */
236   ScrollCompletedSignalType& ScrollCompletedSignal();
237
238 public: // Not intended for application developers
239
240   /**
241    * @brief Creates a handle using the Toolkit::Internal implementation.
242    *
243    * @SINCE_1_0.0
244    * @param[in]  implementation  The Control implementation.
245    */
246   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
247
248   /**
249    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
250    *
251    * @SINCE_1_0.0
252    * @param[in]  internal  A pointer to the internal CustomActor.
253    */
254   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
255 };
256
257 /**
258  * @}
259  */
260 } // namespace Toolkit
261
262 } // namespace Dali
263
264 #endif // __DALI_TOOLKIT_SCROLLABLE_H__