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;
110 * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction
112 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
115 * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction
117 AlphaFunction GetScrollFlickAlphaFunction() const;
120 * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction
122 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
125 * @copydoc Toolkit::ScrollView::GetScrollSnapDuration
127 float GetScrollSnapDuration() const;
130 * @copydoc Toolkit::ScrollView::SetScrollSnapDuration
132 void SetScrollSnapDuration(float time);
135 * @copydoc Toolkit::ScrollView::GetScrollFlickDuration
137 float GetScrollFlickDuration() const;
140 * @copydoc Toolkit::ScrollView::SetScrollFlickDuration
142 void SetScrollFlickDuration(float time);
145 * @copydoc Toolkit::ScrollView::ApplyEffect
147 void ApplyEffect(Toolkit::ScrollViewEffect effect);
150 * @copydoc Toolkit::ScrollView::RemoveEffect
152 void RemoveEffect(Toolkit::ScrollViewEffect effect);
155 * @copydoc Toolkit::ScrollView::RemoveAllEffects
157 void RemoveAllEffects();
160 * @copydoc Toolkit::ScrollView::ApplyConstraintToChildren
162 void ApplyConstraintToChildren(Constraint constraint);
165 * @copydoc Toolkit::ScrollView::RemoveConstraintsFromChildren
167 void RemoveConstraintsFromChildren();
170 * @copydoc Toolkit::ScrollView::GetRulerX
172 const RulerPtr GetRulerX() const;
175 * @copydoc Toolkit::ScrollView::GetRulerY
177 const RulerPtr GetRulerY() const;
180 * @copydoc Toolkit::ScrollView::SetRulerX
182 void SetRulerX(RulerPtr ruler);
185 * @copydoc Toolkit::ScrollView::SetRulerY
187 void SetRulerY(RulerPtr ruler);
190 * Retrieve the touch sensitivity.
192 * @return whether the touch sensitivity is true or false.
194 bool GetScrollSensitive();
197 * @copydoc Toolkit::ScrollView::SetScrollSensitive
199 void SetScrollSensitive(bool sensitive);
202 * @copydoc Toolkit::ScrollView::SetMaxOvershoot
204 void SetMaxOvershoot(float overshootX, float overshootY);
207 * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
209 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
212 * Retrieve the duartion of Snap Overshoot animation
214 * @return the duration.
216 float GetSnapOvershootDuration();
219 * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
221 void SetSnapOvershootDuration(float duration);
224 * Retrieve whether Actor Auto-Snap mode is enabled or not.
226 * @return Actor Auto-Snap mode Enabled flag.
228 bool GetActorAutoSnap();
231 * @copydoc Toolkit::ScrollView::SetActorAutoSnap
233 void SetActorAutoSnap(bool enable);
236 * Enables or Disables Auto Resizing mode for ScrollView contents.
238 * When enabled, the ScrollView's X/Y Domains are restricted to the
239 * dimensions of the content's bounds, which may change as Actors are
240 * Added/Removed, and repositioned.
242 * @note This has been disabled for now, as this requires some fundamental
243 * changes to the way Actors positions and bounds are retrieved.
244 * (currently only constraints have these initial state knowledge)
246 * @param[in] enable Enables (true), or disables (false) Auto Resize.
248 void SetAutoResize(bool enable);
251 * Returns whether the wrap mode has been enabled (true) or not (false).
253 * @return Wrap Mode Enabled flag.
255 bool GetWrapMode() const;
258 * @copydoc Toolkit::ScrollView::SetWrapMode
260 void SetWrapMode(bool enable);
263 * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
265 int GetScrollUpdateDistance() const;
268 * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
270 void SetScrollUpdateDistance(int distance);
273 * @copydoc Toolkit::ScrollView::GetAxisAutoLock
275 bool GetAxisAutoLock() const;
278 * @copydoc Toolkit::ScrollView::SetAxisAutoLock
280 void SetAxisAutoLock(bool enable);
283 * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
285 float GetAxisAutoLockGradient() const;
288 * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
290 void SetAxisAutoLockGradient(float gradient);
293 * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
295 float GetFrictionCoefficient() const;
298 * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
300 void SetFrictionCoefficient(float friction);
303 * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
305 float GetFlickSpeedCoefficient() const;
308 * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
310 void SetFlickSpeedCoefficient(float speed);
313 * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick
315 Vector2 GetMinimumDistanceForFlick() const;
318 * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick
320 void SetMinimumDistanceForFlick(const Vector2& distance);
323 * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick
325 float GetMinimumSpeedForFlick() const;
328 * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick
330 void SetMinimumSpeedForFlick(float speed);
333 * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
335 float GetMaxFlickSpeed() const;
338 * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
340 void SetMaxFlickSpeed(float speed);
343 * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep
345 Vector2 GetWheelScrollDistanceStep() const;
348 * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep
350 void SetWheelScrollDistanceStep(Vector2 step);
353 * @copydoc Toolkit::ScrollView::GetCurrentPage
355 unsigned int GetCurrentPage() const;
358 * @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
360 Vector2 GetCurrentScrollPosition() const;
363 * @copydoc ScrollTo(const Vector2&)
365 void TransformTo(const Vector2& position,
366 DirectionBias horizontalBias = DIRECTION_BIAS_NONE,
367 DirectionBias verticalBias = DIRECTION_BIAS_NONE);
370 * @copydoc ScrollTo(const Vector2&, float, AlhpaFunction, DirectionBias, DirectionBias)
372 void TransformTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias = DIRECTION_BIAS_NONE, DirectionBias verticalBias = DIRECTION_BIAS_NONE);
375 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position)
377 void ScrollTo(const Vector2& position);
380 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration)
382 void ScrollTo(const Vector2& position, float duration);
385 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
387 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
390 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
392 void ScrollTo(const Vector2& position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias);
395 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
397 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias);
400 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page)
402 void ScrollTo(unsigned int page);
405 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
407 void ScrollTo(unsigned int page, float duration, DirectionBias bias = DIRECTION_BIAS_NONE);
410 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor)
412 void ScrollTo(Actor& actor);
415 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration)
417 void ScrollTo(Actor& actor, float duration);
420 * @copydoc Toolkit::ScrollView::SetScrollingDirection()
422 void SetScrollingDirection(Radian direction, Radian threshold);
425 * @copydoc Toolkit::ScrollView::RemoveScrollingDirection()
427 void RemoveScrollingDirection(Radian angle);
430 * Finds the closest Actor to the current center of the ScrollView.
432 * @return A handle to the actor if found, or an empty handle if not.
434 Actor FindClosestActor();
437 * Finds the closest Actor to position in ScrollView
439 * @param[in] position position within ScrollView.
440 * @param[in] dirX Whether to search only those elements that are Left,Right, or All
441 * @param[in] dirY Whether to search only those elements that are Up,Down, or All
442 * @param[in] dirZ Whether to search only those elements that are Out,In, or All
443 * @return A handle to the actor if found, or an empty handle if not.
445 Actor FindClosestActorToPosition(const Vector3& position, FindDirection dirX = All, FindDirection dirY = All, FindDirection dirZ = All);
448 * @copydoc Toolkit::ScrollView::ScrollToSnapPoint
450 bool ScrollToSnapPoint();
455 void StopAnimation(void);
458 * Stops the input animation
460 * @param[in] the animation to stop
462 void StopAnimation(Animation& animation);
465 * Animates to position transform.
467 * @param[in] position The position to animate to
468 * @param[in] positionDuration The number of seconds this animation should run for in each axis.
469 * @param[in] alpha The easing alpha function to use.
470 * @param[in] findShortcuts (optional) Whether to find the shortest route (in Wrap mode)
471 * @param[in] horizontalBias (optional) Whether to bias animation to left or right (or no biasing)
472 * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
473 * @return True if animation necessary and taking place to reach desired transform.
475 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);
478 * @copydoc Toolkit::Scrollable::AddOverlay()
480 void AddOverlay(Actor actor);
483 * @copydoc Toolkit::Scrollable::RemoveOverlay()
485 void RemoveOverlay(Actor actor);
488 * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize
490 void SetOvershootSize(const Vector2& size);
493 * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
495 void SetOvershootEffectColor(const Vector4& color);
500 * Called when a property of an object of this type is set.
501 * @param[in] object The object whose property is set.
502 * @param[in] index The property index.
503 * @param[in] value The new property value.
505 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
508 * Called to retrieve a property of an object of this type.
509 * @param[in] object The object whose property is to be retrieved.
510 * @param[in] index The property index.
511 * @return The current value of the property.
513 static Property::Value GetProperty(BaseObject* object, Property::Index index);
517 * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal()
519 Toolkit::ScrollView::SnapStartedSignalType& SnapStartedSignal();
522 * Connects a callback function with the object's signals.
523 * @param[in] object The object providing the signal.
524 * @param[in] tracker Used to disconnect the signal.
525 * @param[in] signalName The signal to connect to.
526 * @param[in] functor A newly allocated FunctorDelegate.
527 * @return True if the signal was connected.
528 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
530 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
532 private: // private overridden functions from CustomActorImpl and Controls
534 * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
536 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
539 * @copydoc CustomActorImpl::OnSizeSet(const Vector3&)
541 void OnSizeSet(const Vector3& size) override;
544 * From CustomActorImpl; called after a child has been added to the owning actor.
545 * @param[in] child The child which has been added.
547 void OnChildAdd(Actor& child) override;
550 * From CustomActorImpl; called shortly before a child is removed from the owning actor.
551 * @param[in] child The child being removed.
553 void OnChildRemove(Actor& child) override;
556 * Called after a wheelEvent is received by the owning actor.
557 * @param[in] actor Actor associated with the event.
558 * @param[in] event The wheel event.
559 * @return True if the event should be consumed.
561 bool OnWheelEvent(Actor actor, const WheelEvent& event);
564 * @copydoc Toolkit::Control::OnInitialize()
566 void OnInitialize() override;
569 * @copydoc CustomActorImpl::OnSceneConnection()
571 void OnSceneConnection(int depth) override;
574 * @copydoc CustomActorImpl::OnSceneDisconnection()
576 void OnSceneDisconnection() override;
579 * @copydoc Toolkit::Control::OnAccessibilityPan()
581 bool OnAccessibilityPan(PanGesture gesture) override;
584 * @copydoc Toolkit::Scrollable::EnableScrollOvershoot()
586 void EnableScrollOvershoot(bool enable) override;
590 * Called after a touchSignal is received by the owning actor.
592 * We don't consume these events as content within the container may consume events.
594 * @param[in] actor The touched actor.
595 * @param[in] touch The touch information.
596 * @return True if the event should be consumed.
598 bool OnTouch(Actor actor, const TouchEvent& touch);
601 * Start a timer which calls OnTouchDownTimeout()
603 void StartTouchDownTimer();
606 * Stop a timer which calls OnTouchDownTimeout()
608 void StopTouchDownTimer();
611 * Helper to detect when touch-point has been down (outside of pan gesture)
613 bool OnTouchDownTimeout();
616 * Called whenever a snap animation has completed
617 * @param[in] source the Animation instance that has completed.
618 * Resets all scrolling animations and states, leaving current scroll position at SCROLL_POSITION
620 void ResetScrolling();
623 * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
625 void UpdateLocalScrollProperties();
628 * Makes sure scroll values are ready for animated scrolling
630 void PreAnimatedScrollSetup();
633 * Finish an animated scroll, ensuring all scroll properties are updated
636 void FinaliseAnimatedScroll();
639 * Animates the internal x property to the given value
641 * @param[in] position The X position to animate to
642 * @param[in] duration The time in seconds for animation
643 * @param[in] alpha The alpha function to use for animating
645 void AnimateInternalXTo(float position, float duration, AlphaFunction alpha);
648 * Animates the internal y property to the given value
650 * @param[in] position The Y position to animate to
651 * @param[in] duration The time in seconds for animation
652 * @param[in] alpha The alpha function to use for animating
654 void AnimateInternalYTo(float position, float duration, AlphaFunction alpha);
657 * Called whenever a snap animation on the x-axis has completed
658 * @param[in] source the Animation instance that has completed.
660 void OnScrollAnimationFinished(Animation& source);
663 * Called when either the X or Y internal scroll positions have finished snapping back to SCROLL_PRE_POSITION
665 * @param[in] source the Animation instance that has completed.
667 void OnSnapInternalPositionFinished(Animation& source);
670 * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
671 * position to our clamped position
672 * @param[in] position The x position to snap pre scroll property to
674 void SnapInternalXTo(float position);
677 * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
678 * position to our clamped position
679 * @param[in] position The y position to snap pre scroll property to
681 void SnapInternalYTo(float position);
684 * This is called internally whenever the Scroll Rulers are
685 * modified. This will update the properties: 'scrollPositionMin'
686 * and 'scrollPositionMax' to reflect the changes.
688 void UpdatePropertyDomain();
691 * Called when the gesture starts.
693 void GestureStarted();
696 * Amalgamated Gesture Continuing event
698 * @param[in] panDelta average panning delta from base position (0)
700 void GestureContinuing(const Vector2& panDelta);
703 * Called upon pan gesture event.
705 * @param[in] gesture The gesture event.
707 void OnPan(const PanGesture& pan);
710 * Extension of the above gestures.
712 * @param[in] gesture The gesture event.
714 void OnGestureEx(GestureState state);
717 * Performs snapping while taking into account Velocity of gesture
718 * (velocity in pixels/sec)
720 * @param[in] velocity velocity in pixels/sec
722 bool SnapWithVelocity(Vector2 velocity);
725 * Finishes Container Transform
726 * (occurs upon finishing gesture i.e. releasing)
728 void FinishTransform();
731 * Returns overshoot vector based on current position
733 * Overshoot vector is defined as how far outside of bounds
734 * the viewport is trying to view (prior to being clamped).
736 * an overshoot of (100,50), means user is in bottom right corner,
737 * trying to pan +100 to the right, and +50 below. This can be used
738 * to determine an effect, such as stretching.
740 * @param[in] position The position for which you wish to obtain overshoot vector
742 Vector2 GetOvershoot(Vector2& position) const;
745 * Clamps position within the domain set up by X/Y Rulers
747 * @param[in,out] position The position you wish to clamp
749 void ClampPosition(Vector2& position) const;
752 * Clamps position within the domain set up by X/Y Rulers
754 * @param[in,out] position The position you wish to clamp
755 * @param[out] clamped The results of the clamping.
757 void ClampPosition(Vector2& position, ClampState2D& clamped) const;
760 * Wraps position within the domain set up by X/Y Rulers
762 * @note Only wraps if mWrapMode is enabled, and respective domains
765 * @param[in,out] position The position you wish to wrap
767 void WrapPosition(Vector2& position) const;
770 struct AccessibleImpl : public Scrollable::AccessibleImpl
772 using Scrollable::AccessibleImpl::AccessibleImpl;
774 bool ScrollToChild(Actor child) override;
778 * Construct a new ScrollView.
783 * A reference counted object may only be deleted by calling Unreference()
785 virtual ~ScrollView();
789 * Searches this ScrollView, and attempts to Unbind
790 * systematically this Actor from the ScrollView attached.
792 * @param[in] child The actor to be unbound.
794 void FindAndUnbindActor(Actor child) override;
797 * Gets position property.
799 * @return The current position
801 Vector2 GetPropertyPrePosition() const;
804 * Gets position property.
806 * @return The current position
808 Vector2 GetPropertyPosition() const;
811 * Handles a Stopped animation. Its position properties need to be saved, and the animation flag
814 void HandleStoppedAnimation();
817 * Handles a Stopped animation (whether the animation completed, or was
818 * manually stopped). Its position properties need to be saved, and the
819 * animation flag switched off.
821 void HandleSnapAnimationFinished();
824 * Checks if the property notifications are active and adds them if not
826 void SetScrollUpdateNotification(bool enabled);
829 * Refresh the ScrollView (used when animating to update application developer of changes)
830 * @return True if the refresh timer should be kept running.
832 void OnScrollUpdateNotification(Dali::PropertyNotification& source);
835 * Set up default rulers using a property map
836 * @param[in] scrollModeMap A map defining the characteristics of X and Y scrolling
837 * using either FixedRuler or DefaultRuler.
839 void SetScrollMode(const Property::Map& scrollModeMap);
843 ScrollView(const ScrollView&);
846 ScrollView& operator=(const ScrollView& rhs);
849 ScrollViewConstraints mConstraints;
851 unsigned long mTouchDownTime; ///< The touch down time
853 int mGestureStackDepth; ///< How many gestures are currently occuring.
854 Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured
855 Vector2 mPanDelta; ///< Amount currently panned.
857 unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling
858 // Scroll delegate pre and post position properties...
859 Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
860 Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
861 Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll
862 Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
864 // Rulers for each axes...
868 // Last property values set to ScrollView
872 Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position
873 Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position
875 Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
878 Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior.
880 float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications
881 Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
882 Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification
884 Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
886 ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects.
888 Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
889 Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator
890 float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO
891 AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot.
893 float mSnapDuration; ///< Time for the snap animation to take (in seconds).
894 AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation.
896 Vector2 mMinFlickDistance; ///< Minimum pan distance required for a flick
897 float mFlickSpeedThreshold; ///< Minimum pan speed required for a flick in pixels/ms
898 float mFlickDuration; ///< Time for the flick animation to take (in seconds).
899 AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation.
901 float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
902 float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
903 float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
904 float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
906 Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received.
908 ScrollOvershootIndicatorPtr mOvershootIndicator;
909 WeakHandle<Toolkit::ScrollBar> mScrollBar;
911 Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal;
913 bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions
914 bool mScrolling : 1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
915 bool mScrollInterrupted : 1; ///< Flag set for when a down event interrupts a scroll
916 bool mPanning : 1; ///< Whether scroll view is currently panning or not
917 bool mSensitive : 1; ///< Scroll Sensitivity Flag.
918 bool mTouchDownTimeoutReached : 1; ///< Indicates when down event timeout occured without corresponding up event (touch still down)
919 bool mActorAutoSnapEnabled : 1; ///< Whether to automatically snap to closest actor.
920 bool mAutoResizeContainerEnabled : 1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
921 bool mWrapMode : 1; ///< Whether to wrap contents based on container size.
922 bool mAxisAutoLock : 1; ///< Whether to automatically lock axis when panning.
923 bool mAlterChild : 1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
924 bool mDefaultMaxOvershoot : 1; ///< Whether to use default max overshoot or application defined one
925 bool mCanScrollHorizontal : 1; ///< Local value of our property to check against
926 bool mCanScrollVertical : 1; ///< Local value of our property to check against
927 bool mTransientScrollBar : 1; ///< True if scroll-bar should be automatically show/hidden during/after panning
929 friend ScrollViewConstraints;
933 * Returns whether to lock scrolling to a particular axis
935 * @param[in] panDelta Distance panned since gesture started
936 * @param[in] currentLockAxis The current lock axis value
937 * @param[in] lockGradient How quickly to lock to a particular axis
939 * @return The new axis lock state
941 ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis currentLockAxis, float lockGradient);
943 } // namespace Internal
945 // Helpers for public-api forwarding methods
947 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
949 DALI_ASSERT_ALWAYS(scrollView);
951 Dali::RefObject& handle = scrollView.GetImplementation();
953 return static_cast<Toolkit::Internal::ScrollView&>(handle);
956 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
958 DALI_ASSERT_ALWAYS(scrollView);
960 const Dali::RefObject& handle = scrollView.GetImplementation();
962 return static_cast<const Toolkit::Internal::ScrollView&>(handle);
965 } // namespace Toolkit
969 #endif // DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H