1 #ifndef DALI_TOOLKIT_INTERNAL_SCROLLABLE_H
2 #define DALI_TOOLKIT_INTERNAL_SCROLLABLE_H
5 * Copyright (c) 2019 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>
27 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
39 typedef IntrusivePtr<Scrollable> ScrollablePtr;
42 * @copydoc Toolkit::Scrollable
44 class Scrollable : public Control
49 * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
51 bool IsOvershootEnabled() const;
54 * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
56 void SetOvershootEnabled(bool enable);
59 * Adds actor as an Overlay to Scrollable
60 * This method is called by Add-on UI components
61 * such as scroll bars, page indicators.
62 * @param[in] actor Actor to add as an overlay.
64 virtual void AddOverlay(Actor actor) = 0;
67 * Removes overlay actor from Scrollable
68 * This method is called by Add-on UI components
69 * such as scroll bars, page indicators.
70 * @param[in] actor Actor overlay to remove.
72 virtual void RemoveOverlay(Actor actor) = 0;
75 * Retrieves current scroll position.
76 * @returns The current scroll position.
78 virtual Vector2 GetCurrentScrollPosition() const = 0;
81 * Scrolls Scrollable to position specified (contents will scroll to this position)
82 * Position 0,0 is the origin. Increasing X scrolls contents left, while
83 * increasing Y scrolls contents up.
84 * @param[in] position The position to scroll to.
85 * @param[in] duration The duration of the animation in seconds
87 virtual void ScrollTo(const Vector2 &position, float duration) = 0;
90 * Set the color of the overshoot effect.
91 * @parm[in] color The color of the overshoot effect
93 virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
96 * Retrieve the color of the overshoot effect.
97 * @return The color of the overshoot effect.
99 Vector4 GetOvershootEffectColor() const;
102 * @copydoc Dali::Toolkit::Scrollable::SetOvershootAnimationSpeed(float pixelsPerSecond)
104 void SetOvershootAnimationSpeed( float pixelsPerSecond );
107 * @copydoc Dali::Toolkit::Scrollable::GetOvershootAnimationSpeed()
109 float GetOvershootAnimationSpeed() const;
112 * @copydoc Dali::Toolkit::Scrollable::GetOvershootSize()
114 const Vector2& GetOvershootSize() const;
117 * Set the size of the overshoot effect.
118 * @parm[in] size The size of the overshoot effect
120 virtual void SetOvershootSize( const Vector2& size ) = 0;
122 protected: // From Control
123 struct AccessibleImpl : public Control::Impl::AccessibleImpl
125 using Control::Impl::AccessibleImpl::AccessibleImpl;
127 bool IsScrollable() override;
131 * @copydoc Control::OnInitialize
133 virtual void OnInitialize() override;
138 * Temporary function to override EnableScrollOvershoot functionality for overshoot
139 * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
140 * @param[in] enable true to enable, false to disable overshoot indicator
142 virtual void EnableScrollOvershoot(bool enable) {}
147 * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
149 Toolkit::Scrollable::ScrollStartedSignalType& ScrollStartedSignal();
152 * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
154 Toolkit::Scrollable::ScrollUpdatedSignalType& ScrollUpdatedSignal();
157 * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
159 Toolkit::Scrollable::ScrollCompletedSignalType& ScrollCompletedSignal();
162 * Connects a callback function with the object's signals.
163 * @param[in] object The object providing the signal.
164 * @param[in] tracker Used to disconnect the signal.
165 * @param[in] signalName The signal to connect to.
166 * @param[in] functor A newly allocated FunctorDelegate.
167 * @return True if the signal was connected.
168 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
170 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
175 * Called when a property of an object of this type is set.
176 * @param[in] object The object whose property is set.
177 * @param[in] index The property index.
178 * @param[in] value The new property value.
180 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
183 * Called to retrieve a property of an object of this type.
184 * @param[in] object The object whose property is to be retrieved.
185 * @param[in] index The property index.
186 * @return The current value of the property.
188 static Property::Value GetProperty( BaseObject* object, Property::Index index );
193 * Removed default constructor.
195 Scrollable() = delete;
198 * @brief Construct a new Scrollable.
200 * @param[in] behaviourFlags Flags to enable
202 Scrollable( ControlBehaviour behaviourFlags );
205 * A reference counted object may only be deleted by calling Unreference()
207 virtual ~Scrollable();
212 * Gets position property.
214 * @return The current position
216 Vector2 GetPropertyPosition() const;
221 Scrollable(const Scrollable&);
224 Scrollable& operator=(const Scrollable& rhs);
228 Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
229 float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
230 Vector2 mOvershootSize; ///<The size of the overshoot effect
232 Dali::AlphaFunction::BuiltinFunction mScrollToAlphaFunction; ///< The ScrollTo() animations use this
234 Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
235 Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
236 Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
240 bool mOvershootEnabled:1;
243 } // namespace Internal
245 // Helpers for public-api forwarding methods
247 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
249 DALI_ASSERT_ALWAYS(scrollable);
251 Dali::RefObject& handle = scrollable.GetImplementation();
253 return static_cast<Toolkit::Internal::Scrollable&>(handle);
256 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
258 DALI_ASSERT_ALWAYS(scrollable);
260 const Dali::RefObject& handle = scrollable.GetImplementation();
262 return static_cast<const Toolkit::Internal::Scrollable&>(handle);
265 } // namespace Toolkit
269 #endif // DALI_TOOLKIT_INTERNAL_SCROLLABLE_H