3065a2ca593e09601eee75f30e299a3d77c8b573
[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   // Custom properties
63
64   static const std::string SCROLL_RELATIVE_POSITION_PROPERTY_NAME;      ///< Property, name "scroll-relative-position", type VECTOR3
65   static const std::string SCROLL_POSITION_MIN_PROPERTY_NAME;           ///< Property, name "scroll-position-min",      type VECTOR3
66   static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME;           ///< Property, name "scroll-position-max",      type VECTOR3
67   static const std::string SCROLL_DIRECTION_PROPERTY_NAME;              ///< Property, name "scroll-direction",         type VECTOR2
68
69   /// @name Properties
70   /** @{ */
71   static const Dali::Property::Index PROPERTY_OVERSHOOT_EFFECT_COLOR;         ///< Property, name "overshoot-effect-color",  @see SetOvershootEffectColor(),  type VECTOR4
72   static const Dali::Property::Index PROPERTY_OVERSHOOT_ANIMATION_SPEED;      ///< Property, name "overshoot-animation-speed",  @see SetOvershootAnimationSpeed(),  type FLOAT
73   /** @} */
74
75 public:
76
77   typedef Signal< void ( const Vector3& ) > ScrollStartedSignalType;   ///< ScrollStarted signal type
78   typedef Signal< void ( const Vector3& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
79   typedef Signal< void ( const Vector3& ) > ScrollUpdatedSignalType;   ///< Scroll updated signal type
80
81   /**
82    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
83    */
84   ScrollStartedSignalType& ScrollStartedSignal();
85
86   /**
87    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
88    */
89   ScrollUpdatedSignalType& ScrollUpdatedSignal();
90
91   /**
92    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
93    */
94   ScrollCompletedSignalType& ScrollCompletedSignal();
95
96 public:
97
98   /**
99    * @brief Creates an uninitialized Scrollable handle.
100    */
101   Scrollable();
102
103   /**
104    * @brief Copy constructor.
105    *
106    * Creates another handle that points to the same real object
107    *
108    * @param handle to copy from
109    */
110   Scrollable( const Scrollable& handle );
111
112   /**
113    * @brief Assignment operator.
114    *
115    * Changes this handle to point to another real object
116    * @param[in] handle to copy from
117    * @return A reference to this
118    */
119   Scrollable& operator=( const Scrollable& handle );
120
121   /**
122    * @brief Destructor
123    *
124    * This is non-virtual since derived Handle types must not contain data or virtual methods.
125    */
126   ~Scrollable();
127
128   /**
129    * @brief Downcast an Object handle to Scrollable.
130    *
131    * If handle points to a Scrollable the downcast produces valid
132    * handle. If not the returned handle is left uninitialized.
133    *
134    * @param[in] handle Handle to an object
135    * @return handle to a Scrollable or an uninitialized handle
136    */
137   static Scrollable DownCast( BaseHandle handle );
138
139   /**
140    * @brief Checks if a ScrollComponent has been enabled or not.
141    *
142    * @param[in] type The Scroll Component Type to check
143    * @return True (if Enabled)
144    */
145   bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
146
147   /**
148    * @brief Enables a ScrollComponent.
149    *
150    * @param[in] type The Scroll Component Type to enable
151    */
152   void EnableScrollComponent(Scrollable::ScrollComponentType type);
153
154   /**
155    * @brief Disables a ScrollComponent.
156    *
157    * @param[in] type The Scroll Component Type to disable
158    */
159   void DisableScrollComponent(Scrollable::ScrollComponentType type);
160
161   /**
162    * @brief Set the color of the overshoot effect.
163    *
164    * @param[in] color The color of the overshoot effect.
165    */
166   void SetOvershootEffectColor( const Vector4& color );
167
168   /**
169    * @brief Get the color of the overshoot effect.
170    * @return The color of the overshoot effect.
171    */
172   Vector4 GetOvershootEffectColor() const;
173
174   /**
175    * @brief Set the speed of overshoot animation in pixels per second.
176    * When the speed is not greater than 0, the overshoot is set instantly with no animation.
177    * @param[in] pixelsPerSecond The speed of the overshoot animation.
178    */
179   void SetOvershootAnimationSpeed( float pixelsPerSecond );
180
181   /**
182    * @brief Get the speed of overshoot animation in pixels per second.
183    * @return The speed of the overshoot animation.
184    */
185   float GetOvershootAnimationSpeed() const;
186
187 public: // Not intended for application developers
188
189   /**
190    * @brief Creates a handle using the Toolkit::Internal implementation.
191    *
192    * @param[in]  implementation  The Control implementation.
193    */
194   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
195
196   /**
197    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
198    *
199    * @param[in]  internal  A pointer to the internal CustomActor.
200    */
201   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
202 };
203
204 } // namespace Toolkit
205
206 } // namespace Dali
207
208 #endif // __DALI_TOOLKIT_SCROLLABLE_H__