Revert to tizen branch.
[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) 2014 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 /**
36  * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
37  * (via touch) or automatically.
38  *
39  * Scrollables such as ScrollView and ItemView can be derived from this class.
40  *
41  * Signals
42  * | %Signal Name      | Method                       |
43  * |-------------------|------------------------------|
44  * | scroll-started    | @ref ScrollStartedSignal()   |
45  * | scroll-completed  | @ref ScrollUpdatedSignal()   |
46  * | scroll-updated    | @ref ScrollCompletedSignal() |
47  */
48 class DALI_IMPORT_API Scrollable : public Control
49 {
50 public:
51
52   /**
53    * @brief Scroll component types
54    */
55   enum ScrollComponentType
56   {
57     HorizontalScrollBar,
58     VerticalScrollBar,
59     OvershootIndicator,
60   };
61
62   /**
63    * @brief The start and end property ranges for this control.
64    */
65   enum PropertyRange
66   {
67     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
68     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,             ///< Reserve property indices
69
70     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
71     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000              ///< Reserve animatable property indices
72   };
73
74   /**
75    * @brief An enumeration of properties belonging to the Scrollable class.
76    */
77   struct Property
78   {
79     enum
80     {
81       // Event side properties
82       OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshoot-effect-color",    @see SetOvershootEffectColor(),    type Vector4
83       OVERSHOOT_ANIMATION_SPEED,                     ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type float
84
85       // Animatable properties
86       SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector3
87       SCROLL_POSITION_MIN,                                        ///< Property, name "scroll-position-min",      type Vector3
88       SCROLL_POSITION_MAX,                                        ///< Property, name "scroll-position-max",      type Vector3
89       SCROLL_DIRECTION,                                           ///< Property, name "scroll-direction",         type Vector2
90       CAN_SCROLL_VERTICAL,                                        ///< Property, name "can-scroll-vertical",      type bool
91       CAN_SCROLL_HORIZONTAL                                       ///< Property, name "can-scroll-horizontal",    type bool
92     };
93   };
94
95 public:
96
97   typedef Signal< void ( const Vector3& ) > ScrollStartedSignalType;   ///< ScrollStarted signal type
98   typedef Signal< void ( const Vector3& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
99   typedef Signal< void ( const Vector3& ) > ScrollUpdatedSignalType;   ///< Scroll updated signal type
100
101   /**
102    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
103    */
104   ScrollStartedSignalType& ScrollStartedSignal();
105
106   /**
107    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
108    */
109   ScrollUpdatedSignalType& ScrollUpdatedSignal();
110
111   /**
112    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
113    */
114   ScrollCompletedSignalType& ScrollCompletedSignal();
115
116 public:
117
118   /**
119    * @brief Creates an uninitialized Scrollable handle.
120    */
121   Scrollable();
122
123   /**
124    * @brief Copy constructor.
125    *
126    * Creates another handle that points to the same real object
127    *
128    * @param handle to copy from
129    */
130   Scrollable( const Scrollable& handle );
131
132   /**
133    * @brief Assignment operator.
134    *
135    * Changes this handle to point to another real object
136    * @param[in] handle to copy from
137    * @return A reference to this
138    */
139   Scrollable& operator=( const Scrollable& handle );
140
141   /**
142    * @brief Destructor
143    *
144    * This is non-virtual since derived Handle types must not contain data or virtual methods.
145    */
146   ~Scrollable();
147
148   /**
149    * @brief Downcast an Object handle to Scrollable.
150    *
151    * If handle points to a Scrollable the downcast produces valid
152    * handle. If not the returned handle is left uninitialized.
153    *
154    * @param[in] handle Handle to an object
155    * @return handle to a Scrollable or an uninitialized handle
156    */
157   static Scrollable DownCast( BaseHandle handle );
158
159   /**
160    * @brief Checks if a ScrollComponent has been enabled or not.
161    *
162    * @param[in] type The Scroll Component Type to check
163    * @return True (if Enabled)
164    */
165   bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
166
167   /**
168    * @brief Enables a ScrollComponent.
169    *
170    * @param[in] type The Scroll Component Type to enable
171    */
172   void EnableScrollComponent(Scrollable::ScrollComponentType type);
173
174   /**
175    * @brief Disables a ScrollComponent.
176    *
177    * @param[in] type The Scroll Component Type to disable
178    */
179   void DisableScrollComponent(Scrollable::ScrollComponentType type);
180
181   /**
182    * @brief Set the color of the overshoot effect.
183    *
184    * @param[in] color The color of the overshoot effect.
185    */
186   void SetOvershootEffectColor( const Vector4& color );
187
188   /**
189    * @brief Get the color of the overshoot effect.
190    * @return The color of the overshoot effect.
191    */
192   Vector4 GetOvershootEffectColor() const;
193
194   /**
195    * @brief Set the speed of overshoot animation in pixels per second.
196    * When the speed is not greater than 0, the overshoot is set instantly with no animation.
197    * @param[in] pixelsPerSecond The speed of the overshoot animation.
198    */
199   void SetOvershootAnimationSpeed( float pixelsPerSecond );
200
201   /**
202    * @brief Get the speed of overshoot animation in pixels per second.
203    * @return The speed of the overshoot animation.
204    */
205   float GetOvershootAnimationSpeed() const;
206
207 public: // Not intended for application developers
208
209   /**
210    * @brief Creates a handle using the Toolkit::Internal implementation.
211    *
212    * @param[in]  implementation  The Control implementation.
213    */
214   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
215
216   /**
217    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
218    *
219    * @param[in]  internal  A pointer to the internal CustomActor.
220    */
221   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
222 };
223
224 } // namespace Toolkit
225
226 } // namespace Dali
227
228 #endif // __DALI_TOOLKIT_SCROLLABLE_H__