Merge "Remove dead constraint function from GaussianBlurView" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scrollable-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_INTERNAL_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-impl.h>
23 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 class Scrollable;
35 typedef IntrusivePtr<Scrollable> ScrollablePtr;
36
37 /**
38  * @copydoc Toolkit::Scrollable
39  */
40 class Scrollable : public Control
41 {
42 public:
43
44   /**
45    * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
46    */
47   bool IsOvershootEnabled() const;
48
49   /**
50    * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
51    */
52   void SetOvershootEnabled(bool enable);
53
54   /**
55    * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
56    * @return the domain size
57    */
58   virtual Vector2 GetDomainSize() const = 0;
59
60   /**
61    * Adds actor as an Overlay to Scrollable
62    * This method is called by Add-on UI components
63    * such as scroll bars, page indicators.
64    * @param[in] actor Actor to add as an overlay.
65    */
66   virtual void AddOverlay(Actor actor) = 0;
67
68   /**
69    * Removes overlay actor from Scrollable
70    * This method is called by Add-on UI components
71    * such as scroll bars, page indicators.
72    * @param[in] actor Actor overlay to remove.
73    */
74   virtual void RemoveOverlay(Actor actor) = 0;
75
76   /**
77    * Retrieves current scroll position.
78    * @returns The current scroll position.
79    */
80   virtual Vector2 GetCurrentScrollPosition() const = 0;
81
82   /**
83    * Scrolls Scrollable to position specified (contents will scroll to this position)
84    * Position 0,0 is the origin. Increasing X scrolls contents left, while
85    * increasing Y scrolls contents up.
86    * @param[in] position The position to scroll to.
87    * @param[in] duration The duration of the animation in seconds
88    */
89   virtual void ScrollTo(const Vector2 &position, float duration) = 0;
90
91   /**
92    * Set the color of the overshoot effect.
93    * @parm[in] color The color of the overshoot effect
94    */
95   virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
96
97   /**
98    * Retrieve the color of the overshoot effect.
99    * @return The color of the overshoot effect.
100    */
101   Vector4 GetOvershootEffectColor() const;
102
103   /**
104    * @copydoc Dali::Toolkit::Scrollable::SetOvershootAnimationSpeed(float pixelsPerSecond)
105    */
106   void SetOvershootAnimationSpeed( float pixelsPerSecond );
107
108   /**
109    * @copydoc Dali::Toolkit::Scrollable::GetOvershootAnimationSpeed()
110    */
111   float GetOvershootAnimationSpeed() const;
112
113   /**
114    * @copydoc Dali::Toolkit::Scrollable::GetOvershootSize()
115    */
116   const Vector2& GetOvershootSize() const;
117
118 private:
119
120   /**
121    * Temporary function to override EnableScrollOvershoot functionality for overshoot
122    * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
123    * @param[in] enable true to enable, false to disable overshoot indicator
124    */
125   virtual void EnableScrollOvershoot(bool enable) {}
126
127 public: //Signals
128
129   /**
130    * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
131    */
132   Toolkit::Scrollable::ScrollStartedSignalType& ScrollStartedSignal();
133
134   /**
135    * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
136    */
137   Toolkit::Scrollable::ScrollUpdatedSignalType& ScrollUpdatedSignal();
138
139   /**
140    * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
141    */
142   Toolkit::Scrollable::ScrollCompletedSignalType& ScrollCompletedSignal();
143
144   /**
145    * Connects a callback function with the object's signals.
146    * @param[in] object The object providing the signal.
147    * @param[in] tracker Used to disconnect the signal.
148    * @param[in] signalName The signal to connect to.
149    * @param[in] functor A newly allocated FunctorDelegate.
150    * @return True if the signal was connected.
151    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
152    */
153   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
154
155   //properties
156
157   /**
158    * Called when a property of an object of this type is set.
159    * @param[in] object The object whose property is set.
160    * @param[in] index The property index.
161    * @param[in] value The new property value.
162    */
163   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
164
165   /**
166    * Called to retrieve a property of an object of this type.
167    * @param[in] object The object whose property is to be retrieved.
168    * @param[in] index The property index.
169    * @return The current value of the property.
170    */
171   static Property::Value GetProperty( BaseObject* object, Property::Index index );
172
173 protected:
174
175   /**
176    * Construct a new Scrollable.
177    */
178   Scrollable();
179
180   /**
181    * @brief Construct a new Scrollable.
182    *
183    * @param[in] behaviourFlags Flags to enable
184    */
185   Scrollable( ControlBehaviour behaviourFlags );
186
187   /**
188    * A reference counted object may only be deleted by calling Unreference()
189    */
190   virtual ~Scrollable();
191
192 private:
193
194   /**
195    * Gets position property.
196    *
197    * @return The current position
198    */
199   Vector2 GetPropertyPosition() const;
200
201 private:
202
203   // Undefined
204   Scrollable(const Scrollable&);
205
206   // Undefined
207   Scrollable& operator=(const Scrollable& rhs);
208
209 protected:
210
211   Vector4         mOvershootEffectColor;    ///<The color of the overshoot bouncing effect
212   float           mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
213   Vector2         mOvershootSize;           ///<The size of the overshoot effect
214
215   Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
216   Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
217   Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
218
219 private:
220
221   bool mOvershootEnabled:1;
222 };
223
224 } // namespace Internal
225
226 // Helpers for public-api forwarding methods
227
228 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
229 {
230   DALI_ASSERT_ALWAYS(scrollable);
231
232   Dali::RefObject& handle = scrollable.GetImplementation();
233
234   return static_cast<Toolkit::Internal::Scrollable&>(handle);
235 }
236
237 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
238 {
239   DALI_ASSERT_ALWAYS(scrollable);
240
241   const Dali::RefObject& handle = scrollable.GetImplementation();
242
243   return static_cast<const Toolkit::Internal::Scrollable&>(handle);
244 }
245
246 } // namespace Toolkit
247
248 } // namespace Dali
249
250 #endif // __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__