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 ControlImpl
45 static const std::string SCROLLABLE_CAN_SCROLL_VERTICAL;
46 static const std::string SCROLLABLE_CAN_SCROLL_HORIZONTAL;
49 * Create a new Scrollable.
50 * @return A public handle to the newly allocated Scrollable.
52 // static Dali::Toolkit::Scrollable New();
57 * @copydoc Dali::Toolkit::Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType type)
59 bool IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const;
62 * @copydoc Dali::Toolkit::Scrollable::EnableScrollComponent(Scrollable::ScrollComponentType type)
64 void EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
67 * @copydoc Dali::Toolkit::Scrollable::DisableScrollComponent(Scrollable::ScrollComponentType type)
69 void DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
72 * Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
73 * @return the domain size
75 virtual Vector3 GetDomainSize() const = 0;
78 * Adds actor as an Overlay to Scrollable
79 * This method is called by Add-on UI components
80 * such as scroll bars, page indicators.
81 * @param[in] actor Actor to add as an overlay.
83 virtual void AddOverlay(Actor actor) = 0;
86 * Removes overlay actor from Scrollable
87 * This method is called by Add-on UI components
88 * such as scroll bars, page indicators.
89 * @param[in] actor Actor overlay to remove.
91 virtual void RemoveOverlay(Actor actor) = 0;
94 * Retrieves current scroll position.
95 * @returns The current scroll position.
97 virtual Vector3 GetCurrentScrollPosition() const = 0;
100 * Scrolls Scrollable to position specified (contents will scroll to this position)
101 * Position 0,0 is the origin. Increasing X scrolls contents left, while
102 * increasing Y scrolls contents up.
103 * @param[in] position The position to scroll to.
104 * @param[in] duration The duration of the animation in seconds
106 virtual void ScrollTo(const Vector3 &position, float duration) = 0;
111 * Temporary function to override EnableScrollComponent functionality for overshoot
112 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
113 * @param[in] enable true to enable, false to disable overshoot indicator
115 virtual void SetOvershootEnabled(bool enable) {}
120 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
122 Toolkit::Scrollable::ScrollStartedSignalV2& ScrollStartedSignal();
125 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
127 Toolkit::Scrollable::ScrollUpdatedSignalV2& ScrollUpdatedSignal();
130 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
132 Toolkit::Scrollable::ScrollCompletedSignalV2& ScrollCompletedSignal();
135 * @copydoc Dali::Toolkit::Scrollable::ScrollClampedSignal()
137 Toolkit::Scrollable::ScrollClampedSignalV2& ScrollClampedSignal();
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 * Construct a new Scrollable.
158 * A reference counted object may only be deleted by calling Unreference()
160 virtual ~Scrollable();
163 * Register common properties
165 void RegisterCommonProperties();
170 * Gets position property.
172 * @return The current position
174 Vector3 GetPropertyPosition() const;
179 Scrollable(const Scrollable&);
182 Scrollable& operator=(const Scrollable& rhs);
185 * Helper to create an initialized ScrollComponent
186 * @param[in] scrollable reference to ScrollView implementation
187 * @param[in] type the type of scroll component to create.
188 * @return A pointer to the created ScrollComponent.
190 Toolkit::ScrollComponent NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type);
194 Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes]
195 Property::Index mPropertyPositionMin; ///< Scroll Domain Minimum ("position-min")
196 Property::Index mPropertyPositionMax; ///< Scroll Domain Maximum ("position-max")
197 Property::Index mPropertyScrollDirection; ///< Scroll direction ("scroll-direction")
198 Property::Index mPropertyCanScrollVertical; ///< Whether the current scroll domain is large enough to scroll vertically
199 Property::Index mPropertyCanScrollHorizontal; ///< Whether the current scroll domain is large enough to scroll horizontally
201 std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> mComponent; ///< ScrollComponent (such as a scrollbar/page indicator/status)
203 Toolkit::Scrollable::ScrollStartedSignalV2 mScrollStartedSignalV2;
204 Toolkit::Scrollable::ScrollUpdatedSignalV2 mScrollUpdatedSignalV2;
205 Toolkit::Scrollable::ScrollCompletedSignalV2 mScrollCompletedSignalV2;
206 Toolkit::Scrollable::ScrollClampedSignalV2 mScrollClampedSignalV2;
210 typedef std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> ComponentContainer;
211 typedef ComponentContainer::iterator ComponentIter;
213 ComponentContainer mComponents; ///< ScrollComponent (such as a scrollbar/page indicator/status)
214 bool mOvershootEnabled;
217 } // namespace Internal
219 // Helpers for public-api forwarding methods
221 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
223 DALI_ASSERT_ALWAYS(scrollable);
225 Dali::RefObject& handle = scrollable.GetImplementation();
227 return static_cast<Toolkit::Internal::Scrollable&>(handle);
230 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
232 DALI_ASSERT_ALWAYS(scrollable);
234 const Dali::RefObject& handle = scrollable.GetImplementation();
236 return static_cast<const Toolkit::Internal::Scrollable&>(handle);
239 } // namespace Toolkit
243 #endif // __DALI_TOOLKIT_INTERNAL_SCROLLABLE_H__