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