1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/animation/alpha-function.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
38 typedef IntrusivePtr<Scrollable> ScrollablePtr;
41 * @copydoc Toolkit::Scrollable
43 class Scrollable : public Control
48 * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
50 bool IsOvershootEnabled() const;
53 * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
55 void SetOvershootEnabled(bool enable);
58 * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
59 * @return the domain size
61 virtual Vector2 GetDomainSize() const = 0;
64 * Adds actor as an Overlay to Scrollable
65 * This method is called by Add-on UI components
66 * such as scroll bars, page indicators.
67 * @param[in] actor Actor to add as an overlay.
69 virtual void AddOverlay(Actor actor) = 0;
72 * Removes overlay actor from Scrollable
73 * This method is called by Add-on UI components
74 * such as scroll bars, page indicators.
75 * @param[in] actor Actor overlay to remove.
77 virtual void RemoveOverlay(Actor actor) = 0;
80 * Retrieves current scroll position.
81 * @returns The current scroll position.
83 virtual Vector2 GetCurrentScrollPosition() const = 0;
86 * Scrolls Scrollable to position specified (contents will scroll to this position)
87 * Position 0,0 is the origin. Increasing X scrolls contents left, while
88 * increasing Y scrolls contents up.
89 * @param[in] position The position to scroll to.
90 * @param[in] duration The duration of the animation in seconds
92 virtual void ScrollTo(const Vector2 &position, float duration) = 0;
95 * Set the color of the overshoot effect.
96 * @parm[in] color The color of the overshoot effect
98 virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
101 * Retrieve the color of the overshoot effect.
102 * @return The color of the overshoot effect.
104 Vector4 GetOvershootEffectColor() const;
107 * @copydoc Dali::Toolkit::Scrollable::SetOvershootAnimationSpeed(float pixelsPerSecond)
109 void SetOvershootAnimationSpeed( float pixelsPerSecond );
112 * @copydoc Dali::Toolkit::Scrollable::GetOvershootAnimationSpeed()
114 float GetOvershootAnimationSpeed() const;
117 * @copydoc Dali::Toolkit::Scrollable::GetOvershootSize()
119 const Vector2& GetOvershootSize() const;
124 * Temporary function to override EnableScrollOvershoot functionality for overshoot
125 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
126 * @param[in] enable true to enable, false to disable overshoot indicator
128 virtual void EnableScrollOvershoot(bool enable) {}
133 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
135 Toolkit::Scrollable::ScrollStartedSignalType& ScrollStartedSignal();
138 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
140 Toolkit::Scrollable::ScrollUpdatedSignalType& ScrollUpdatedSignal();
143 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
145 Toolkit::Scrollable::ScrollCompletedSignalType& ScrollCompletedSignal();
148 * Connects a callback function with the object's signals.
149 * @param[in] object The object providing the signal.
150 * @param[in] tracker Used to disconnect the signal.
151 * @param[in] signalName The signal to connect to.
152 * @param[in] functor A newly allocated FunctorDelegate.
153 * @return True if the signal was connected.
154 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
156 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
161 * Called when a property of an object of this type is set.
162 * @param[in] object The object whose property is set.
163 * @param[in] index The property index.
164 * @param[in] value The new property value.
166 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
169 * Called to retrieve a property of an object of this type.
170 * @param[in] object The object whose property is to be retrieved.
171 * @param[in] index The property index.
172 * @return The current value of the property.
174 static Property::Value GetProperty( BaseObject* object, Property::Index index );
179 * Construct a new Scrollable.
184 * @brief Construct a new Scrollable.
186 * @param[in] behaviourFlags Flags to enable
188 Scrollable( ControlBehaviour behaviourFlags );
191 * A reference counted object may only be deleted by calling Unreference()
193 virtual ~Scrollable();
198 * Gets position property.
200 * @return The current position
202 Vector2 GetPropertyPosition() const;
207 Scrollable(const Scrollable&);
210 Scrollable& operator=(const Scrollable& rhs);
214 Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
215 float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
216 Vector2 mOvershootSize; ///<The size of the overshoot effect
218 Dali::AlphaFunction::BuiltinFunction mScrollToAlphaFunction; ///< The ScrollTo() animations use this
220 Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
221 Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
222 Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
226 bool mOvershootEnabled:1;
229 } // namespace Internal
231 // Helpers for public-api forwarding methods
233 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
235 DALI_ASSERT_ALWAYS(scrollable);
237 Dali::RefObject& handle = scrollable.GetImplementation();
239 return static_cast<Toolkit::Internal::Scrollable&>(handle);
242 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
244 DALI_ASSERT_ALWAYS(scrollable);
246 const Dali::RefObject& handle = scrollable.GetImplementation();
248 return static_cast<const Toolkit::Internal::Scrollable&>(handle);
251 } // namespace Toolkit
255 #endif // __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__