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/common/map-wrapper.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
39 typedef IntrusivePtr<Scrollable> ScrollablePtr;
42 * @copydoc Toolkit::Scrollable
44 class Scrollable : public Control
47 static const std::string SCROLLABLE_CAN_SCROLL_VERTICAL;
48 static const std::string SCROLLABLE_CAN_SCROLL_HORIZONTAL;
51 * Create a new Scrollable.
52 * @return A public handle to the newly allocated Scrollable.
54 // static Dali::Toolkit::Scrollable New();
59 * @copydoc Dali::Toolkit::Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType type)
61 bool IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const;
64 * @copydoc Dali::Toolkit::Scrollable::EnableScrollComponent(Scrollable::ScrollComponentType type)
66 void EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
69 * @copydoc Dali::Toolkit::Scrollable::DisableScrollComponent(Scrollable::ScrollComponentType type)
71 void DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
74 * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
75 * @return the domain size
77 virtual Vector3 GetDomainSize() const = 0;
80 * Adds actor as an Overlay to Scrollable
81 * This method is called by Add-on UI components
82 * such as scroll bars, page indicators.
83 * @param[in] actor Actor to add as an overlay.
85 virtual void AddOverlay(Actor actor) = 0;
88 * Removes overlay actor from Scrollable
89 * This method is called by Add-on UI components
90 * such as scroll bars, page indicators.
91 * @param[in] actor Actor overlay to remove.
93 virtual void RemoveOverlay(Actor actor) = 0;
96 * Retrieves current scroll position.
97 * @returns The current scroll position.
99 virtual Vector3 GetCurrentScrollPosition() const = 0;
102 * Scrolls Scrollable to position specified (contents will scroll to this position)
103 * Position 0,0 is the origin. Increasing X scrolls contents left, while
104 * increasing Y scrolls contents up.
105 * @param[in] position The position to scroll to.
106 * @param[in] duration The duration of the animation in seconds
108 virtual void ScrollTo(const Vector3 &position, float duration) = 0;
111 * Set the color of the overshoot effect.
112 * @parm[in] color The color of the overshoot effect
114 virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
117 * Retrieve the color of the overshoot effect.
118 * @return The color of the overshoot effect.
120 Vector4 GetOvershootEffectColor() const;
125 * Temporary function to override EnableScrollComponent functionality for overshoot
126 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
127 * @param[in] enable true to enable, false to disable overshoot indicator
129 virtual void SetOvershootEnabled(bool enable) {}
134 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
136 Toolkit::Scrollable::ScrollStartedSignalV2& ScrollStartedSignal();
139 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
141 Toolkit::Scrollable::ScrollUpdatedSignalV2& ScrollUpdatedSignal();
144 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
146 Toolkit::Scrollable::ScrollCompletedSignalV2& ScrollCompletedSignal();
149 * @copydoc Dali::Toolkit::Scrollable::ScrollClampedSignal()
151 Toolkit::Scrollable::ScrollClampedSignalV2& ScrollClampedSignal();
154 * Connects a callback function with the object's signals.
155 * @param[in] object The object providing the signal.
156 * @param[in] tracker Used to disconnect the signal.
157 * @param[in] signalName The signal to connect to.
158 * @param[in] functor A newly allocated FunctorDelegate.
159 * @return True if the signal was connected.
160 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
162 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
167 * Called when a property of an object of this type is set.
168 * @param[in] object The object whose property is set.
169 * @param[in] index The property index.
170 * @param[in] value The new property value.
172 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
175 * Called to retrieve a property of an object of this type.
176 * @param[in] object The object whose property is to be retrieved.
177 * @param[in] index The property index.
178 * @return The current value of the property.
180 static Property::Value GetProperty( BaseObject* object, Property::Index index );
185 * Construct a new Scrollable.
190 * A reference counted object may only be deleted by calling Unreference()
192 virtual ~Scrollable();
195 * Register common properties
197 void RegisterCommonProperties();
202 * Gets position property.
204 * @return The current position
206 Vector3 GetPropertyPosition() const;
211 Scrollable(const Scrollable&);
214 Scrollable& operator=(const Scrollable& rhs);
217 * Helper to create an initialized ScrollComponent
218 * @param[in] scrollable reference to ScrollView implementation
219 * @param[in] type the type of scroll component to create.
220 * @return A pointer to the created ScrollComponent.
222 Toolkit::ScrollComponent NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type);
226 Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
228 Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes]
229 Property::Index mPropertyPositionMin; ///< Scroll Domain Minimum ("position-min")
230 Property::Index mPropertyPositionMax; ///< Scroll Domain Maximum ("position-max")
231 Property::Index mPropertyScrollDirection; ///< Scroll direction ("scroll-direction")
232 Property::Index mPropertyCanScrollVertical; ///< Whether the current scroll domain is large enough to scroll vertically
233 Property::Index mPropertyCanScrollHorizontal; ///< Whether the current scroll domain is large enough to scroll horizontally
235 std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> mComponent; ///< ScrollComponent (such as a scrollbar/page indicator/status)
237 Toolkit::Scrollable::ScrollStartedSignalV2 mScrollStartedSignalV2;
238 Toolkit::Scrollable::ScrollUpdatedSignalV2 mScrollUpdatedSignalV2;
239 Toolkit::Scrollable::ScrollCompletedSignalV2 mScrollCompletedSignalV2;
240 Toolkit::Scrollable::ScrollClampedSignalV2 mScrollClampedSignalV2;
244 typedef std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> ComponentContainer;
245 typedef ComponentContainer::iterator ComponentIter;
247 ComponentContainer mComponents; ///< ScrollComponent (such as a scrollbar/page indicator/status)
248 bool mOvershootEnabled:1;
251 } // namespace Internal
253 // Helpers for public-api forwarding methods
255 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
257 DALI_ASSERT_ALWAYS(scrollable);
259 Dali::RefObject& handle = scrollable.GetImplementation();
261 return static_cast<Toolkit::Internal::Scrollable&>(handle);
264 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
266 DALI_ASSERT_ALWAYS(scrollable);
268 const Dali::RefObject& handle = scrollable.GetImplementation();
270 return static_cast<const Toolkit::Internal::Scrollable&>(handle);
273 } // namespace Toolkit
277 #endif // __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__