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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
37 typedef IntrusivePtr<Scrollable> ScrollablePtr;
40 * @copydoc Toolkit::Scrollable
42 class Scrollable : public Control
45 static const std::string SCROLLABLE_CAN_SCROLL_VERTICAL;
46 static const std::string SCROLLABLE_CAN_SCROLL_HORIZONTAL;
47 static const Vector4 DEFAULT_OVERSHOOT_COLOUR;
50 * Create a new Scrollable.
51 * @return A public handle to the newly allocated Scrollable.
53 // static Dali::Toolkit::Scrollable New();
58 * @copydoc Dali::Toolkit::Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType type)
60 bool IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const;
63 * @copydoc Dali::Toolkit::Scrollable::EnableScrollComponent(Scrollable::ScrollComponentType type)
65 void EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
68 * @copydoc Dali::Toolkit::Scrollable::DisableScrollComponent(Scrollable::ScrollComponentType type)
70 void DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
73 * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
74 * @return the domain size
76 virtual Vector3 GetDomainSize() const = 0;
79 * Adds actor as an Overlay to Scrollable
80 * This method is called by Add-on UI components
81 * such as scroll bars, page indicators.
82 * @param[in] actor Actor to add as an overlay.
84 virtual void AddOverlay(Actor actor) = 0;
87 * Removes overlay actor from Scrollable
88 * This method is called by Add-on UI components
89 * such as scroll bars, page indicators.
90 * @param[in] actor Actor overlay to remove.
92 virtual void RemoveOverlay(Actor actor) = 0;
95 * Retrieves current scroll position.
96 * @returns The current scroll position.
98 virtual Vector3 GetCurrentScrollPosition() const = 0;
101 * Scrolls Scrollable to position specified (contents will scroll to this position)
102 * Position 0,0 is the origin. Increasing X scrolls contents left, while
103 * increasing Y scrolls contents up.
104 * @param[in] position The position to scroll to.
105 * @param[in] duration The duration of the animation in seconds
107 virtual void ScrollTo(const Vector3 &position, float duration) = 0;
112 * Temporary function to override EnableScrollComponent functionality for overshoot
113 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
114 * @param[in] enable true to enable, false to disable overshoot indicator
116 virtual void SetOvershootEnabled(bool enable) {}
121 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
123 Toolkit::Scrollable::ScrollStartedSignalV2& ScrollStartedSignal();
126 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
128 Toolkit::Scrollable::ScrollUpdatedSignalV2& ScrollUpdatedSignal();
131 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
133 Toolkit::Scrollable::ScrollCompletedSignalV2& ScrollCompletedSignal();
136 * @copydoc Dali::Toolkit::Scrollable::ScrollClampedSignal()
138 Toolkit::Scrollable::ScrollClampedSignalV2& ScrollClampedSignal();
141 * Connects a callback function with the object's signals.
142 * @param[in] object The object providing the signal.
143 * @param[in] tracker Used to disconnect the signal.
144 * @param[in] signalName The signal to connect to.
145 * @param[in] functor A newly allocated FunctorDelegate.
146 * @return True if the signal was connected.
147 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
149 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
154 * Construct a new Scrollable.
159 * A reference counted object may only be deleted by calling Unreference()
161 virtual ~Scrollable();
164 * Register common properties
166 void RegisterCommonProperties();
171 * Gets position property.
173 * @return The current position
175 Vector3 GetPropertyPosition() const;
180 Scrollable(const Scrollable&);
183 Scrollable& operator=(const Scrollable& rhs);
186 * Helper to create an initialized ScrollComponent
187 * @param[in] scrollable reference to ScrollView implementation
188 * @param[in] type the type of scroll component to create.
189 * @return A pointer to the created ScrollComponent.
191 Toolkit::ScrollComponent NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type);
195 Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes]
196 Property::Index mPropertyPositionMin; ///< Scroll Domain Minimum ("position-min")
197 Property::Index mPropertyPositionMax; ///< Scroll Domain Maximum ("position-max")
198 Property::Index mPropertyScrollDirection; ///< Scroll direction ("scroll-direction")
199 Property::Index mPropertyCanScrollVertical; ///< Whether the current scroll domain is large enough to scroll vertically
200 Property::Index mPropertyCanScrollHorizontal; ///< Whether the current scroll domain is large enough to scroll horizontally
202 std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> mComponent; ///< ScrollComponent (such as a scrollbar/page indicator/status)
204 Toolkit::Scrollable::ScrollStartedSignalV2 mScrollStartedSignalV2;
205 Toolkit::Scrollable::ScrollUpdatedSignalV2 mScrollUpdatedSignalV2;
206 Toolkit::Scrollable::ScrollCompletedSignalV2 mScrollCompletedSignalV2;
207 Toolkit::Scrollable::ScrollClampedSignalV2 mScrollClampedSignalV2;
211 typedef std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> ComponentContainer;
212 typedef ComponentContainer::iterator ComponentIter;
214 ComponentContainer mComponents; ///< ScrollComponent (such as a scrollbar/page indicator/status)
215 bool mOvershootEnabled;
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__