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-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
35 typedef IntrusivePtr<Scrollable> ScrollablePtr;
38 * @copydoc Toolkit::Scrollable
40 class Scrollable : public Control
45 * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
47 bool IsOvershootEnabled() const;
50 * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
52 void SetOvershootEnabled(bool enable);
55 * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
56 * @return the domain size
58 virtual Vector2 GetDomainSize() const = 0;
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.
66 virtual void AddOverlay(Actor actor) = 0;
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.
74 virtual void RemoveOverlay(Actor actor) = 0;
77 * Retrieves current scroll position.
78 * @returns The current scroll position.
80 virtual Vector2 GetCurrentScrollPosition() const = 0;
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
89 virtual void ScrollTo(const Vector2 &position, float duration) = 0;
92 * Set the color of the overshoot effect.
93 * @parm[in] color The color of the overshoot effect
95 virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
98 * Retrieve the color of the overshoot effect.
99 * @return The color of the overshoot effect.
101 Vector4 GetOvershootEffectColor() const;
104 * @copydoc Dali::Toolkit::Scrollable::SetOvershootAnimationSpeed(float pixelsPerSecond)
106 void SetOvershootAnimationSpeed( float pixelsPerSecond );
109 * @copydoc Dali::Toolkit::Scrollable::GetOvershootAnimationSpeed()
111 float GetOvershootAnimationSpeed() const;
116 * Temporary function to override EnableScrollOvershoot functionality for overshoot
117 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
118 * @param[in] enable true to enable, false to disable overshoot indicator
120 virtual void EnableScrollOvershoot(bool enable) {}
125 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
127 Toolkit::Scrollable::ScrollStartedSignalType& ScrollStartedSignal();
130 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
132 Toolkit::Scrollable::ScrollUpdatedSignalType& ScrollUpdatedSignal();
135 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
137 Toolkit::Scrollable::ScrollCompletedSignalType& ScrollCompletedSignal();
140 * Connects a callback function with the object's signals.
141 * @param[in] object The object providing the signal.
142 * @param[in] tracker Used to disconnect the signal.
143 * @param[in] signalName The signal to connect to.
144 * @param[in] functor A newly allocated FunctorDelegate.
145 * @return True if the signal was connected.
146 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
148 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
153 * Called when a property of an object of this type is set.
154 * @param[in] object The object whose property is set.
155 * @param[in] index The property index.
156 * @param[in] value The new property value.
158 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
161 * Called to retrieve a property of an object of this type.
162 * @param[in] object The object whose property is to be retrieved.
163 * @param[in] index The property index.
164 * @return The current value of the property.
166 static Property::Value GetProperty( BaseObject* object, Property::Index index );
171 * Construct a new Scrollable.
176 * @brief Construct a new Scrollable.
178 * @param[in] behaviourFlags Flags to enable
180 Scrollable( ControlBehaviour behaviourFlags );
183 * A reference counted object may only be deleted by calling Unreference()
185 virtual ~Scrollable();
190 * Gets position property.
192 * @return The current position
194 Vector2 GetPropertyPosition() const;
199 Scrollable(const Scrollable&);
202 Scrollable& operator=(const Scrollable& rhs);
206 Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
207 float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
209 Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
210 Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
211 Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
215 bool mOvershootEnabled:1;
218 } // namespace Internal
220 // Helpers for public-api forwarding methods
222 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
224 DALI_ASSERT_ALWAYS(scrollable);
226 Dali::RefObject& handle = scrollable.GetImplementation();
228 return static_cast<Toolkit::Internal::Scrollable&>(handle);
231 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
233 DALI_ASSERT_ALWAYS(scrollable);
235 const Dali::RefObject& handle = scrollable.GetImplementation();
237 return static_cast<const Toolkit::Internal::Scrollable&>(handle);
240 } // namespace Toolkit
244 #endif // __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__