1 #ifndef DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H
5 * Copyright (c) 2021 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/adaptor-framework/timer.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/public-api/object/weak-handle.h>
28 #include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
29 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h>
30 #include <dali-toolkit/public-api/controls/control-impl.h>
31 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
32 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
33 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl-constraints.h>
42 typedef IntrusivePtr<ScrollView> ScrollViewPtr;
44 class ScrollInternalConstraints;
45 typedef IntrusivePtr<ScrollInternalConstraints> ScrollInternalConstraintsPtr;
47 class ScrollOvershootIndicator;
48 typedef IntrusivePtr<ScrollOvershootIndicator> ScrollOvershootIndicatorPtr;
51 * @copydoc Toolkit::ScrollView
53 class ScrollView : public ScrollBase
57 * FindDirection specifies how searching is conducted within the Find... routines.
61 None = -3, ///< Includes none within the search query.
62 All = -2, ///< Includes all within the search query.
63 Left = -1, ///< Includes only those not right !(>)
64 Right = 1, ///< Includes only those right (>)
65 Up = -1, ///< Includes only those not below !(>)
66 Down = 1, ///< Includes only those below (>)
67 Out = -1, ///< Includes only those not infront !(>)
68 In = 1 ///< Includes only those infront (>)
73 LockPossible = 0, ///< Locking is possible, but not set in stone yet.
74 LockHorizontal, ///< Locking is set to horizontal. (can pan vertically)
75 LockVertical, ///< Locking is set to vertical. (can pan horizontally)
76 LockNone ///< Locking is set to none (free panning).
81 AnimatingInternalX = 0x01, ///< animating mPropertyX due to externally requested ScrollTo or internal snapping operation
82 AnimatingInternalY = 0x02, ///< animating mPropertyY due to externally requested ScrollTo or internal snapping operation
83 SnappingInternalX = 0x04, ///< snapping mPropertyX back to mPropertyPreScroll x value to remove x overshoot over time
84 SnappingInternalY = 0x08, ///< snapping mPropertyY back to mPropertyPreScroll y value to remove y overshoot over time
87 static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX;
88 static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY;
89 static const unsigned int SCROLL_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY;
90 static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY;
93 typedef std::vector<Dali::Toolkit::ScrollViewEffect> ScrollViewEffectContainer; ///< Container of Dali::Toolkit::ScrollViewEffect
94 typedef ScrollViewEffectContainer::iterator ScrollViewEffectIter; ///< Iterator for Dali::Toolkit::ScrollViewEffectContainer
98 * Create a new ScrollView.
99 * @return A public handle to the newly allocated ScrollView.
101 static Dali::Toolkit::ScrollView New();
105 * @copydoc Toolkit::ScrollView::GetScrollSnapAlphaFunction
107 AlphaFunction GetScrollSnapAlphaFunction() const
109 return mSnapAlphaFunction;
113 * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction
115 void SetScrollSnapAlphaFunction(AlphaFunction alpha)
117 mSnapAlphaFunction = alpha;
121 * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction
123 AlphaFunction GetScrollFlickAlphaFunction() const
125 return mFlickAlphaFunction;
129 * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction
131 void SetScrollFlickAlphaFunction(AlphaFunction alpha)
133 mFlickAlphaFunction = alpha;
137 * @copydoc Toolkit::ScrollView::GetScrollSnapDuration
139 float GetScrollSnapDuration() const
141 return mSnapDuration;
145 * @copydoc Toolkit::ScrollView::SetScrollSnapDuration
147 void SetScrollSnapDuration(float time)
149 mSnapDuration = time;
153 * @copydoc Toolkit::ScrollView::GetScrollFlickDuration
155 float GetScrollFlickDuration() const
157 return mFlickDuration;
161 * @copydoc Toolkit::ScrollView::SetScrollFlickDuration
163 void SetScrollFlickDuration(float time)
165 mFlickDuration = time;
169 * @copydoc Toolkit::ScrollView::ApplyEffect
171 void ApplyEffect(Toolkit::ScrollViewEffect effect);
174 * @copydoc Toolkit::ScrollView::RemoveEffect
176 void RemoveEffect(Toolkit::ScrollViewEffect effect);
179 * @copydoc Toolkit::ScrollView::RemoveAllEffects
181 void RemoveAllEffects();
184 * @copydoc Toolkit::ScrollView::ApplyConstraintToChildren
186 void ApplyConstraintToChildren(Constraint constraint);
189 * @copydoc Toolkit::ScrollView::RemoveConstraintsFromChildren
191 void RemoveConstraintsFromChildren();
194 * @copydoc Toolkit::ScrollView::GetRulerX
196 const RulerPtr GetRulerX() const
202 * @copydoc Toolkit::ScrollView::GetRulerY
204 const RulerPtr GetRulerY() const
210 * @copydoc Toolkit::ScrollView::SetRulerX
212 void SetRulerX(RulerPtr ruler);
215 * @copydoc Toolkit::ScrollView::SetRulerY
217 void SetRulerY(RulerPtr ruler);
220 * Retrieve the touch sensitivity.
222 * @return whether the touch sensitivity is true or false.
224 bool GetScrollSensitive()
230 * @copydoc Toolkit::ScrollView::SetScrollSensitive
232 void SetScrollSensitive(bool sensitive);
235 * @copydoc Toolkit::ScrollView::SetMaxOvershoot
237 void SetMaxOvershoot(float overshootX, float overshootY);
240 * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
242 void SetSnapOvershootAlphaFunction(AlphaFunction alpha)
244 mSnapOvershootAlphaFunction = alpha;
248 * Retrieve the duartion of Snap Overshoot animation
250 * @return the duration.
252 float GetSnapOvershootDuration()
254 return mSnapOvershootDuration;
258 * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
260 void SetSnapOvershootDuration(float duration)
262 mSnapOvershootDuration = duration;
266 * Retrieve whether Actor Auto-Snap mode is enabled or not.
268 * @return Actor Auto-Snap mode Enabled flag.
270 bool GetActorAutoSnap();
273 * @copydoc Toolkit::ScrollView::SetActorAutoSnap
275 void SetActorAutoSnap(bool enable)
277 mActorAutoSnapEnabled = enable;
281 * Enables or Disables Auto Resizing mode for ScrollView contents.
283 * When enabled, the ScrollView's X/Y Domains are restricted to the
284 * dimensions of the content's bounds, which may change as Actors are
285 * Added/Removed, and repositioned.
287 * @note This has been disabled for now, as this requires some fundamental
288 * changes to the way Actors positions and bounds are retrieved.
289 * (currently only constraints have these initial state knowledge)
291 * @param[in] enable Enables (true), or disables (false) Auto Resize.
293 void SetAutoResize(bool enable);
296 * Returns whether the wrap mode has been enabled (true) or not (false).
298 * @return Wrap Mode Enabled flag.
300 bool GetWrapMode() const
306 * @copydoc Toolkit::ScrollView::SetWrapMode
308 void SetWrapMode(bool enable);
311 * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
313 int GetScrollUpdateDistance() const
315 return mScrollUpdateDistance;
319 * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
321 void SetScrollUpdateDistance(int distance)
323 mScrollUpdateDistance = distance;
327 * @copydoc Toolkit::ScrollView::GetAxisAutoLock
329 bool GetAxisAutoLock() const
331 return mAxisAutoLock;
335 * @copydoc Toolkit::ScrollView::SetAxisAutoLock
337 void SetAxisAutoLock(bool enable);
340 * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
342 float GetAxisAutoLockGradient() const
344 return mAxisAutoLockGradient;
348 * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
350 void SetAxisAutoLockGradient(float gradient);
353 * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
355 float GetFrictionCoefficient() const
357 return mFrictionCoefficient;
361 * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
363 void SetFrictionCoefficient(float friction);
366 * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
368 float GetFlickSpeedCoefficient() const
370 return mFlickSpeedCoefficient;
374 * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
376 void SetFlickSpeedCoefficient(float speed)
378 mFlickSpeedCoefficient = speed;
382 * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick
384 Vector2 GetMinimumDistanceForFlick() const
386 return mMinFlickDistance;
390 * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick
392 void SetMinimumDistanceForFlick(const Vector2& distance)
394 mMinFlickDistance = distance;
398 * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick
400 float GetMinimumSpeedForFlick() const
402 return mFlickSpeedThreshold;
406 * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick
408 void SetMinimumSpeedForFlick(float speed)
410 mFlickSpeedThreshold = speed;
414 * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
416 float GetMaxFlickSpeed() const
418 return mMaxFlickSpeed;
422 * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
424 void SetMaxFlickSpeed(float speed)
426 mMaxFlickSpeed = speed;
430 * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep
432 Vector2 GetWheelScrollDistanceStep() const
434 return mWheelScrollDistanceStep;
438 * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep
440 void SetWheelScrollDistanceStep(Vector2 step)
442 mWheelScrollDistanceStep = step;
446 * @copydoc Toolkit::ScrollView::GetCurrentPage
448 unsigned int GetCurrentPage() const;
451 * @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
453 Vector2 GetCurrentScrollPosition() const;
456 * @copydoc ScrollTo(const Vector2&)
458 void TransformTo(const Vector2& position,
459 DirectionBias horizontalBias = DIRECTION_BIAS_NONE,
460 DirectionBias verticalBias = DIRECTION_BIAS_NONE);
463 * @copydoc ScrollTo(const Vector2&, float, AlhpaFunction, DirectionBias, DirectionBias)
465 void TransformTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias = DIRECTION_BIAS_NONE, DirectionBias verticalBias = DIRECTION_BIAS_NONE);
468 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position)
470 void ScrollTo(const Vector2& position);
473 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration)
475 void ScrollTo(const Vector2& position, float duration);
478 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
480 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
483 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
485 void ScrollTo(const Vector2& position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias);
488 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
490 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias);
493 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page)
495 void ScrollTo(unsigned int page);
498 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
500 void ScrollTo(unsigned int page, float duration, DirectionBias bias = DIRECTION_BIAS_NONE);
503 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor)
505 void ScrollTo(Actor& actor);
508 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration)
510 void ScrollTo(Actor& actor, float duration);
513 * @copydoc Toolkit::ScrollView::SetScrollingDirection()
515 void SetScrollingDirection(Radian direction, Radian threshold);
518 * @copydoc Toolkit::ScrollView::RemoveScrollingDirection()
520 void RemoveScrollingDirection(Radian angle);
523 * Finds the closest Actor to the current center of the ScrollView.
525 * @return A handle to the actor if found, or an empty handle if not.
527 Actor FindClosestActor();
530 * Finds the closest Actor to position in ScrollView
532 * @param[in] position position within ScrollView.
533 * @param[in] dirX Whether to search only those elements that are Left,Right, or All
534 * @param[in] dirY Whether to search only those elements that are Up,Down, or All
535 * @param[in] dirZ Whether to search only those elements that are Out,In, or All
536 * @return A handle to the actor if found, or an empty handle if not.
538 Actor FindClosestActorToPosition(const Vector3& position, FindDirection dirX = All, FindDirection dirY = All, FindDirection dirZ = All);
541 * @copydoc Toolkit::ScrollView::ScrollToSnapPoint
543 bool ScrollToSnapPoint();
548 void StopAnimation(void);
551 * Stops the input animation
553 * @param[in] the animation to stop
555 void StopAnimation(Animation& animation);
558 * Animates to position transform.
560 * @param[in] position The position to animate to
561 * @param[in] positionDuration The number of seconds this animation should run for in each axis.
562 * @param[in] alpha The easing alpha function to use.
563 * @param[in] findShortcuts (optional) Whether to find the shortest route (in Wrap mode)
564 * @param[in] horizontalBias (optional) Whether to bias animation to left or right (or no biasing)
565 * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
566 * @return True if animation necessary and taking place to reach desired transform.
568 bool AnimateTo(const Vector2& position, const Vector2& positionDuration, AlphaFunction alpha, bool findShortcuts = true, DirectionBias horizontalBias = DIRECTION_BIAS_NONE, DirectionBias verticalBias = DIRECTION_BIAS_NONE, SnapType snapType = SNAP);
571 * @copydoc Toolkit::Scrollable::AddOverlay()
573 void AddOverlay(Actor actor);
576 * @copydoc Toolkit::Scrollable::RemoveOverlay()
578 void RemoveOverlay(Actor actor);
581 * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize
583 void SetOvershootSize(const Vector2& size);
586 * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
588 void SetOvershootEffectColor(const Vector4& color);
593 * Called when a property of an object of this type is set.
594 * @param[in] object The object whose property is set.
595 * @param[in] index The property index.
596 * @param[in] value The new property value.
598 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
601 * Called to retrieve a property of an object of this type.
602 * @param[in] object The object whose property is to be retrieved.
603 * @param[in] index The property index.
604 * @return The current value of the property.
606 static Property::Value GetProperty(BaseObject* object, Property::Index index);
610 * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal()
612 Toolkit::ScrollView::SnapStartedSignalType& SnapStartedSignal();
615 * Connects a callback function with the object's signals.
616 * @param[in] object The object providing the signal.
617 * @param[in] tracker Used to disconnect the signal.
618 * @param[in] signalName The signal to connect to.
619 * @param[in] functor A newly allocated FunctorDelegate.
620 * @return True if the signal was connected.
621 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
623 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
625 private: // private overridden functions from CustomActorImpl and Controls
627 * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
629 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
632 * @copydoc CustomActorImpl::OnSizeSet(const Vector3&)
634 void OnSizeSet(const Vector3& size) override;
637 * From CustomActorImpl; called after a child has been added to the owning actor.
638 * @param[in] child The child which has been added.
640 void OnChildAdd(Actor& child) override;
643 * From CustomActorImpl; called shortly before a child is removed from the owning actor.
644 * @param[in] child The child being removed.
646 void OnChildRemove(Actor& child) override;
649 * Called after a wheelEvent is received by the owning actor.
650 * @param[in] actor Actor associated with the event.
651 * @param[in] event The wheel event.
652 * @return True if the event should be consumed.
654 bool OnWheelEvent(Actor actor, const WheelEvent& event);
657 * @copydoc Toolkit::Control::OnInitialize()
659 void OnInitialize() override;
662 * @copydoc CustomActorImpl::OnSceneConnection()
664 void OnSceneConnection(int depth) override;
667 * @copydoc CustomActorImpl::OnSceneDisconnection()
669 void OnSceneDisconnection() override;
672 * @copydoc Toolkit::Control::OnAccessibilityPan()
674 bool OnAccessibilityPan(PanGesture gesture) override;
677 * @copydoc Toolkit::Scrollable::EnableScrollOvershoot()
679 void EnableScrollOvershoot(bool enable) override;
683 * Called after a touchSignal is received by the owning actor.
685 * We don't consume these events as content within the container may consume events.
687 * @param[in] actor The touched actor.
688 * @param[in] touch The touch information.
689 * @return True if the event should be consumed.
691 bool OnTouch(Actor actor, const TouchEvent& touch);
694 * Start a timer which calls OnTouchDownTimeout()
696 void StartTouchDownTimer();
699 * Stop a timer which calls OnTouchDownTimeout()
701 void StopTouchDownTimer();
704 * Helper to detect when touch-point has been down (outside of pan gesture)
706 bool OnTouchDownTimeout();
709 * Called whenever a snap animation has completed
710 * @param[in] source the Animation instance that has completed.
711 * Resets all scrolling animations and states, leaving current scroll position at SCROLL_POSITION
713 void ResetScrolling();
716 * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
718 void UpdateLocalScrollProperties();
721 * Makes sure scroll values are ready for animated scrolling
723 void PreAnimatedScrollSetup();
726 * Finish an animated scroll, ensuring all scroll properties are updated
729 void FinaliseAnimatedScroll();
732 * Animates the internal x property to the given value
734 * @param[in] position The X position to animate to
735 * @param[in] duration The time in seconds for animation
736 * @param[in] alpha The alpha function to use for animating
738 void AnimateInternalXTo(float position, float duration, AlphaFunction alpha);
741 * Animates the internal y property to the given value
743 * @param[in] position The Y position to animate to
744 * @param[in] duration The time in seconds for animation
745 * @param[in] alpha The alpha function to use for animating
747 void AnimateInternalYTo(float position, float duration, AlphaFunction alpha);
750 * Called whenever a snap animation on the x-axis has completed
751 * @param[in] source the Animation instance that has completed.
753 void OnScrollAnimationFinished(Animation& source);
756 * Called when either the X or Y internal scroll positions have finished snapping back to SCROLL_PRE_POSITION
758 * @param[in] source the Animation instance that has completed.
760 void OnSnapInternalPositionFinished(Animation& source);
763 * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
764 * position to our clamped position
765 * @param[in] position The x position to snap pre scroll property to
767 void SnapInternalXTo(float position);
770 * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
771 * position to our clamped position
772 * @param[in] position The y position to snap pre scroll property to
774 void SnapInternalYTo(float position);
777 * This is called internally whenever the Scroll Rulers are
778 * modified. This will update the properties: 'scrollPositionMin'
779 * and 'scrollPositionMax' to reflect the changes.
781 void UpdatePropertyDomain();
784 * Called when the gesture starts.
786 void GestureStarted();
789 * Amalgamated Gesture Continuing event
791 * @param[in] panDelta average panning delta from base position (0)
793 void GestureContinuing(const Vector2& panDelta);
796 * Called upon pan gesture event.
798 * @param[in] gesture The gesture event.
800 void OnPan(const PanGesture& pan);
803 * Extension of the above gestures.
805 * @param[in] gesture The gesture event.
807 void OnGestureEx(GestureState state);
810 * Performs snapping while taking into account Velocity of gesture
811 * (velocity in pixels/sec)
813 * @param[in] velocity velocity in pixels/sec
815 bool SnapWithVelocity(Vector2 velocity);
818 * Finishes Container Transform
819 * (occurs upon finishing gesture i.e. releasing)
821 void FinishTransform();
824 * Returns overshoot vector based on current position
826 * Overshoot vector is defined as how far outside of bounds
827 * the viewport is trying to view (prior to being clamped).
829 * an overshoot of (100,50), means user is in bottom right corner,
830 * trying to pan +100 to the right, and +50 below. This can be used
831 * to determine an effect, such as stretching.
833 * @param[in] position The position for which you wish to obtain overshoot vector
835 Vector2 GetOvershoot(Vector2& position) const;
838 * Clamps position within the domain set up by X/Y Rulers
840 * @param[in,out] position The position you wish to clamp
842 void ClampPosition(Vector2& position) const;
845 * Clamps position within the domain set up by X/Y Rulers
847 * @param[in,out] position The position you wish to clamp
848 * @param[out] clamped The results of the clamping.
850 void ClampPosition(Vector2& position, ClampState2D& clamped) const;
853 * Wraps position within the domain set up by X/Y Rulers
855 * @note Only wraps if mWrapMode is enabled, and respective domains
858 * @param[in,out] position The position you wish to wrap
860 void WrapPosition(Vector2& position) const;
863 struct AccessibleImpl : public Scrollable::AccessibleImpl
865 using Scrollable::AccessibleImpl::AccessibleImpl;
867 bool ScrollToChild(Actor child) override;
871 * Construct a new ScrollView.
876 * A reference counted object may only be deleted by calling Unreference()
878 virtual ~ScrollView();
882 * Searches this ScrollView, and attempts to Unbind
883 * systematically this Actor from the ScrollView attached.
885 * @param[in] child The actor to be unbound.
887 void FindAndUnbindActor(Actor child) override;
890 * Gets position property.
892 * @return The current position
894 Vector2 GetPropertyPrePosition() const;
897 * Gets position property.
899 * @return The current position
901 Vector2 GetPropertyPosition() const;
904 * Handles a Stopped animation. Its position properties need to be saved, and the animation flag
907 void HandleStoppedAnimation();
910 * Handles a Stopped animation (whether the animation completed, or was
911 * manually stopped). Its position properties need to be saved, and the
912 * animation flag switched off.
914 void HandleSnapAnimationFinished();
917 * Checks if the property notifications are active and adds them if not
919 void SetScrollUpdateNotification(bool enabled);
922 * Refresh the ScrollView (used when animating to update application developer of changes)
923 * @return True if the refresh timer should be kept running.
925 void OnScrollUpdateNotification(Dali::PropertyNotification& source);
928 * Set up default rulers using a property map
929 * @param[in] scrollModeMap A map defining the characteristics of X and Y scrolling
930 * using either FixedRuler or DefaultRuler.
932 void SetScrollMode(const Property::Map& scrollModeMap);
936 ScrollView(const ScrollView&);
939 ScrollView& operator=(const ScrollView& rhs);
942 ScrollViewConstraints mConstraints;
944 unsigned long mTouchDownTime; ///< The touch down time
946 int mGestureStackDepth; ///< How many gestures are currently occuring.
947 Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured
948 Vector2 mPanDelta; ///< Amount currently panned.
950 unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling
951 // Scroll delegate pre and post position properties...
952 Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
953 Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
954 Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll
955 Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
957 // Rulers for each axes...
961 // Last property values set to ScrollView
965 Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position
966 Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position
968 Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
971 Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior.
973 float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications
974 Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
975 Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification
977 Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
979 ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects.
981 Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
982 Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator
983 float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO
984 AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot.
986 float mSnapDuration; ///< Time for the snap animation to take (in seconds).
987 AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation.
989 Vector2 mMinFlickDistance; ///< Minimum pan distance required for a flick
990 float mFlickSpeedThreshold; ///< Minimum pan speed required for a flick in pixels/ms
991 float mFlickDuration; ///< Time for the flick animation to take (in seconds).
992 AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation.
994 float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
995 float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
996 float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
997 float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
999 Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received.
1001 ScrollOvershootIndicatorPtr mOvershootIndicator;
1002 WeakHandle<Toolkit::ScrollBar> mScrollBar;
1004 Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal;
1006 bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions
1007 bool mScrolling : 1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
1008 bool mScrollInterrupted : 1; ///< Flag set for when a down event interrupts a scroll
1009 bool mPanning : 1; ///< Whether scroll view is currently panning or not
1010 bool mSensitive : 1; ///< Scroll Sensitivity Flag.
1011 bool mTouchDownTimeoutReached : 1; ///< Indicates when down event timeout occured without corresponding up event (touch still down)
1012 bool mActorAutoSnapEnabled : 1; ///< Whether to automatically snap to closest actor.
1013 bool mAutoResizeContainerEnabled : 1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
1014 bool mWrapMode : 1; ///< Whether to wrap contents based on container size.
1015 bool mAxisAutoLock : 1; ///< Whether to automatically lock axis when panning.
1016 bool mAlterChild : 1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
1017 bool mDefaultMaxOvershoot : 1; ///< Whether to use default max overshoot or application defined one
1018 bool mCanScrollHorizontal : 1; ///< Local value of our property to check against
1019 bool mCanScrollVertical : 1; ///< Local value of our property to check against
1020 bool mTransientScrollBar : 1; ///< True if scroll-bar should be automatically show/hidden during/after panning
1022 friend ScrollViewConstraints;
1026 * Returns whether to lock scrolling to a particular axis
1028 * @param[in] panDelta Distance panned since gesture started
1029 * @param[in] currentLockAxis The current lock axis value
1030 * @param[in] lockGradient How quickly to lock to a particular axis
1032 * @return The new axis lock state
1034 ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis currentLockAxis, float lockGradient);
1036 } // namespace Internal
1038 // Helpers for public-api forwarding methods
1040 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
1042 DALI_ASSERT_ALWAYS(scrollView);
1044 Dali::RefObject& handle = scrollView.GetImplementation();
1046 return static_cast<Toolkit::Internal::ScrollView&>(handle);
1049 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
1051 DALI_ASSERT_ALWAYS(scrollView);
1053 const Dali::RefObject& handle = scrollView.GetImplementation();
1055 return static_cast<const Toolkit::Internal::ScrollView&>(handle);
1058 } // namespace Toolkit
1062 #endif // DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H