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>
41 typedef IntrusivePtr<ScrollView> ScrollViewPtr;
43 class ScrollInternalConstraints;
44 typedef IntrusivePtr<ScrollInternalConstraints> ScrollInternalConstraintsPtr;
46 class ScrollOvershootIndicator;
47 typedef IntrusivePtr<ScrollOvershootIndicator> ScrollOvershootIndicatorPtr;
50 * @copydoc Toolkit::ScrollView
52 class ScrollView : public ScrollBase
56 * FindDirection specifies how searching is conducted within the Find... routines.
60 None = -3, ///< Includes none within the search query.
61 All = -2, ///< Includes all within the search query.
62 Left = -1, ///< Includes only those not right !(>)
63 Right = 1, ///< Includes only those right (>)
64 Up = -1, ///< Includes only those not below !(>)
65 Down = 1, ///< Includes only those below (>)
66 Out = -1, ///< Includes only those not infront !(>)
67 In = 1 ///< Includes only those infront (>)
72 LockPossible = 0, ///< Locking is possible, but not set in stone yet.
73 LockHorizontal, ///< Locking is set to horizontal. (can pan vertically)
74 LockVertical, ///< Locking is set to vertical. (can pan horizontally)
75 LockNone ///< Locking is set to none (free panning).
80 AnimatingInternalX = 0x01, ///< animating mPropertyX due to externally requested ScrollTo or internal snapping operation
81 AnimatingInternalY = 0x02, ///< animating mPropertyY due to externally requested ScrollTo or internal snapping operation
82 SnappingInternalX = 0x04, ///< snapping mPropertyX back to mPropertyPreScroll x value to remove x overshoot over time
83 SnappingInternalY = 0x08, ///< snapping mPropertyY back to mPropertyPreScroll y value to remove y overshoot over time
86 static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX;
87 static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY;
88 static const unsigned int SCROLL_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY;
89 static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY;
92 typedef std::vector<Dali::Toolkit::ScrollViewEffect> ScrollViewEffectContainer; ///< Container of Dali::Toolkit::ScrollViewEffect
93 typedef ScrollViewEffectContainer::iterator ScrollViewEffectIter; ///< Iterator for Dali::Toolkit::ScrollViewEffectContainer
97 * Create a new ScrollView.
98 * @return A public handle to the newly allocated ScrollView.
100 static Dali::Toolkit::ScrollView New();
104 * @copydoc Toolkit::ScrollView::GetScrollSnapAlphaFunction
106 AlphaFunction GetScrollSnapAlphaFunction() const;
109 * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction
111 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
114 * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction
116 AlphaFunction GetScrollFlickAlphaFunction() const;
119 * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction
121 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
124 * @copydoc Toolkit::ScrollView::GetScrollSnapDuration
126 float GetScrollSnapDuration() const;
129 * @copydoc Toolkit::ScrollView::SetScrollSnapDuration
131 void SetScrollSnapDuration(float time);
134 * @copydoc Toolkit::ScrollView::GetScrollFlickDuration
136 float GetScrollFlickDuration() const;
139 * @copydoc Toolkit::ScrollView::SetScrollFlickDuration
141 void SetScrollFlickDuration(float time);
144 * @copydoc Toolkit::ScrollView::ApplyEffect
146 void ApplyEffect(Toolkit::ScrollViewEffect effect);
149 * @copydoc Toolkit::ScrollView::RemoveEffect
151 void RemoveEffect(Toolkit::ScrollViewEffect effect);
154 * @copydoc Toolkit::ScrollView::RemoveAllEffects
156 void RemoveAllEffects();
159 * @copydoc Toolkit::ScrollView::ApplyConstraintToChildren
161 void ApplyConstraintToChildren(Constraint constraint);
164 * @copydoc Toolkit::ScrollView::RemoveConstraintsFromChildren
166 void RemoveConstraintsFromChildren();
169 * @copydoc Toolkit::ScrollView::GetRulerX
171 const RulerPtr GetRulerX() const;
174 * @copydoc Toolkit::ScrollView::GetRulerY
176 const RulerPtr GetRulerY() const;
179 * @copydoc Toolkit::ScrollView::SetRulerX
181 void SetRulerX(RulerPtr ruler);
184 * @copydoc Toolkit::ScrollView::SetRulerY
186 void SetRulerY(RulerPtr ruler);
189 * Retrieve the touch sensitivity.
191 * @return whether the touch sensitivity is true or false.
193 bool GetScrollSensitive();
196 * @copydoc Toolkit::ScrollView::SetScrollSensitive
198 void SetScrollSensitive(bool sensitive);
201 * @copydoc Toolkit::ScrollView::SetMaxOvershoot
203 void SetMaxOvershoot(float overshootX, float overshootY);
206 * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
208 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
211 * Retrieve the duartion of Snap Overshoot animation
213 * @return the duration.
215 float GetSnapOvershootDuration();
218 * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
220 void SetSnapOvershootDuration(float duration);
223 * Retrieve whether Actor Auto-Snap mode is enabled or not.
225 * @return Actor Auto-Snap mode Enabled flag.
227 bool GetActorAutoSnap();
230 * @copydoc Toolkit::ScrollView::SetActorAutoSnap
232 void SetActorAutoSnap(bool enable);
235 * Enables or Disables Auto Resizing mode for ScrollView contents.
237 * When enabled, the ScrollView's X/Y Domains are restricted to the
238 * dimensions of the content's bounds, which may change as Actors are
239 * Added/Removed, and repositioned.
241 * @note This has been disabled for now, as this requires some fundamental
242 * changes to the way Actors positions and bounds are retrieved.
243 * (currently only constraints have these initial state knowledge)
245 * @param[in] enable Enables (true), or disables (false) Auto Resize.
247 void SetAutoResize(bool enable);
250 * Returns whether the wrap mode has been enabled (true) or not (false).
252 * @return Wrap Mode Enabled flag.
254 bool GetWrapMode() const;
257 * @copydoc Toolkit::ScrollView::SetWrapMode
259 void SetWrapMode(bool enable);
262 * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
264 int GetScrollUpdateDistance() const;
267 * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
269 void SetScrollUpdateDistance(int distance);
272 * @copydoc Toolkit::ScrollView::GetAxisAutoLock
274 bool GetAxisAutoLock() const;
277 * @copydoc Toolkit::ScrollView::SetAxisAutoLock
279 void SetAxisAutoLock(bool enable);
282 * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
284 float GetAxisAutoLockGradient() const;
287 * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
289 void SetAxisAutoLockGradient(float gradient);
292 * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
294 float GetFrictionCoefficient() const;
297 * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
299 void SetFrictionCoefficient(float friction);
302 * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
304 float GetFlickSpeedCoefficient() const;
307 * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
309 void SetFlickSpeedCoefficient(float speed);
312 * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick
314 Vector2 GetMinimumDistanceForFlick() const;
317 * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick
319 void SetMinimumDistanceForFlick(const Vector2& distance);
322 * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick
324 float GetMinimumSpeedForFlick() const;
327 * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick
329 void SetMinimumSpeedForFlick(float speed);
332 * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
334 float GetMaxFlickSpeed() const;
337 * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
339 void SetMaxFlickSpeed(float speed);
342 * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep
344 Vector2 GetWheelScrollDistanceStep() const;
347 * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep
349 void SetWheelScrollDistanceStep(Vector2 step);
352 * @copydoc Toolkit::ScrollView::GetCurrentPage
354 unsigned int GetCurrentPage() const;
357 * @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
359 Vector2 GetCurrentScrollPosition() const;
362 * @copydoc ScrollTo(const Vector2&)
364 void TransformTo(const Vector2& position,
365 DirectionBias horizontalBias = DIRECTION_BIAS_NONE,
366 DirectionBias verticalBias = DIRECTION_BIAS_NONE);
369 * @copydoc ScrollTo(const Vector2&, float, AlhpaFunction, DirectionBias, DirectionBias)
371 void TransformTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias = DIRECTION_BIAS_NONE, DirectionBias verticalBias = DIRECTION_BIAS_NONE);
374 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position)
376 void ScrollTo(const Vector2& position);
379 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration)
381 void ScrollTo(const Vector2& position, float duration);
384 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
386 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
389 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
391 void ScrollTo(const Vector2& position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias);
394 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
396 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias);
399 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page)
401 void ScrollTo(unsigned int page);
404 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
406 void ScrollTo(unsigned int page, float duration, DirectionBias bias = DIRECTION_BIAS_NONE);
409 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor)
411 void ScrollTo(Actor& actor);
414 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration)
416 void ScrollTo(Actor& actor, float duration);
419 * @copydoc Toolkit::ScrollView::SetScrollingDirection()
421 void SetScrollingDirection(Radian direction, Radian threshold);
424 * @copydoc Toolkit::ScrollView::RemoveScrollingDirection()
426 void RemoveScrollingDirection(Radian angle);
429 * Finds the closest Actor to the current center of the ScrollView.
431 * @return A handle to the actor if found, or an empty handle if not.
433 Actor FindClosestActor();
436 * Finds the closest Actor to position in ScrollView
438 * @param[in] position position within ScrollView.
439 * @param[in] dirX Whether to search only those elements that are Left,Right, or All
440 * @param[in] dirY Whether to search only those elements that are Up,Down, or All
441 * @param[in] dirZ Whether to search only those elements that are Out,In, or All
442 * @return A handle to the actor if found, or an empty handle if not.
444 Actor FindClosestActorToPosition(const Vector3& position, FindDirection dirX = All, FindDirection dirY = All, FindDirection dirZ = All);
447 * @copydoc Toolkit::ScrollView::ScrollToSnapPoint
449 bool ScrollToSnapPoint();
454 void StopAnimation(void);
457 * Stops the input animation
459 * @param[in] the animation to stop
461 void StopAnimation(Animation& animation);
464 * Animates to position transform.
466 * @param[in] position The position to animate to
467 * @param[in] positionDuration The number of seconds this animation should run for in each axis.
468 * @param[in] alpha The easing alpha function to use.
469 * @param[in] findShortcuts (optional) Whether to find the shortest route (in Wrap mode)
470 * @param[in] horizontalBias (optional) Whether to bias animation to left or right (or no biasing)
471 * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
472 * @return True if animation necessary and taking place to reach desired transform.
474 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);
477 * @copydoc Toolkit::Scrollable::AddOverlay()
479 void AddOverlay(Actor actor);
482 * @copydoc Toolkit::Scrollable::RemoveOverlay()
484 void RemoveOverlay(Actor actor);
487 * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize
489 void SetOvershootSize(const Vector2& size);
492 * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
494 void SetOvershootEffectColor(const Vector4& color);
499 * Called when a property of an object of this type is set.
500 * @param[in] object The object whose property is set.
501 * @param[in] index The property index.
502 * @param[in] value The new property value.
504 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
507 * Called to retrieve a property of an object of this type.
508 * @param[in] object The object whose property is to be retrieved.
509 * @param[in] index The property index.
510 * @return The current value of the property.
512 static Property::Value GetProperty(BaseObject* object, Property::Index index);
516 * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal()
518 Toolkit::ScrollView::SnapStartedSignalType& SnapStartedSignal();
521 * Connects a callback function with the object's signals.
522 * @param[in] object The object providing the signal.
523 * @param[in] tracker Used to disconnect the signal.
524 * @param[in] signalName The signal to connect to.
525 * @param[in] functor A newly allocated FunctorDelegate.
526 * @return True if the signal was connected.
527 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
529 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
531 private: // private overridden functions from CustomActorImpl and Controls
533 * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
535 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
538 * @copydoc CustomActorImpl::OnSizeSet(const Vector3&)
540 void OnSizeSet(const Vector3& size) override;
543 * From CustomActorImpl; called after a child has been added to the owning actor.
544 * @param[in] child The child which has been added.
546 void OnChildAdd(Actor& child) override;
549 * From CustomActorImpl; called shortly before a child is removed from the owning actor.
550 * @param[in] child The child being removed.
552 void OnChildRemove(Actor& child) override;
555 * Called after a wheelEvent is received by the owning actor.
556 * @param[in] actor Actor associated with the event.
557 * @param[in] event The wheel event.
558 * @return True if the event should be consumed.
560 bool OnWheelEvent(Actor actor, const WheelEvent& event);
563 * @copydoc Toolkit::Control::OnInitialize()
565 void OnInitialize() override;
568 * @copydoc CustomActorImpl::OnSceneConnection()
570 void OnSceneConnection(int depth) override;
573 * @copydoc CustomActorImpl::OnSceneDisconnection()
575 void OnSceneDisconnection() override;
578 * @copydoc Toolkit::Control::OnAccessibilityPan()
580 bool OnAccessibilityPan(PanGesture gesture) override;
583 * @copydoc Toolkit::Scrollable::EnableScrollOvershoot()
585 void EnableScrollOvershoot(bool enable) override;
589 * Called after a touchSignal is received by the owning actor.
591 * We don't consume these events as content within the container may consume events.
593 * @param[in] actor The touched actor.
594 * @param[in] touch The touch information.
595 * @return True if the event should be consumed.
597 bool OnTouch(Actor actor, const TouchEvent& touch);
600 * Start a timer which calls OnTouchDownTimeout()
602 void StartTouchDownTimer();
605 * Stop a timer which calls OnTouchDownTimeout()
607 void StopTouchDownTimer();
610 * Helper to detect when touch-point has been down (outside of pan gesture)
612 bool OnTouchDownTimeout();
615 * Called whenever a snap animation has completed
616 * @param[in] source the Animation instance that has completed.
617 * Resets all scrolling animations and states, leaving current scroll position at SCROLL_POSITION
619 void ResetScrolling();
622 * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
624 void UpdateLocalScrollProperties();
627 * Makes sure scroll values are ready for animated scrolling
629 void PreAnimatedScrollSetup();
632 * Finish an animated scroll, ensuring all scroll properties are updated
635 void FinaliseAnimatedScroll();
638 * Animates the internal x property to the given value
640 * @param[in] position The X position to animate to
641 * @param[in] duration The time in seconds for animation
642 * @param[in] alpha The alpha function to use for animating
644 void AnimateInternalXTo(float position, float duration, AlphaFunction alpha);
647 * Animates the internal y property to the given value
649 * @param[in] position The Y position to animate to
650 * @param[in] duration The time in seconds for animation
651 * @param[in] alpha The alpha function to use for animating
653 void AnimateInternalYTo(float position, float duration, AlphaFunction alpha);
656 * Called whenever a snap animation on the x-axis has completed
657 * @param[in] source the Animation instance that has completed.
659 void OnScrollAnimationFinished(Animation& source);
662 * Called when either the X or Y internal scroll positions have finished snapping back to SCROLL_PRE_POSITION
664 * @param[in] source the Animation instance that has completed.
666 void OnSnapInternalPositionFinished(Animation& source);
669 * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
670 * position to our clamped position
671 * @param[in] position The x position to snap pre scroll property to
673 void SnapInternalXTo(float position);
676 * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
677 * position to our clamped position
678 * @param[in] position The y position to snap pre scroll property to
680 void SnapInternalYTo(float position);
683 * This is called internally whenever the Scroll Rulers are
684 * modified. This will update the properties: 'scrollPositionMin'
685 * and 'scrollPositionMax' to reflect the changes.
687 void UpdatePropertyDomain();
690 * Called when the gesture starts.
692 void GestureStarted();
695 * Amalgamated Gesture Continuing event
697 * @param[in] panDelta average panning delta from base position (0)
699 void GestureContinuing(const Vector2& panDelta);
702 * Called upon pan gesture event.
704 * @param[in] gesture The gesture event.
706 void OnPan(const PanGesture& pan);
709 * Extension of the above gestures.
711 * @param[in] gesture The gesture event.
713 void OnGestureEx(GestureState state);
716 * Performs snapping while taking into account Velocity of gesture
717 * (velocity in pixels/sec)
719 * @param[in] velocity velocity in pixels/sec
721 bool SnapWithVelocity(Vector2 velocity);
724 * Finishes Container Transform
725 * (occurs upon finishing gesture i.e. releasing)
727 void FinishTransform();
730 * Returns overshoot vector based on current position
732 * Overshoot vector is defined as how far outside of bounds
733 * the viewport is trying to view (prior to being clamped).
735 * an overshoot of (100,50), means user is in bottom right corner,
736 * trying to pan +100 to the right, and +50 below. This can be used
737 * to determine an effect, such as stretching.
739 * @param[in] position The position for which you wish to obtain overshoot vector
741 Vector2 GetOvershoot(Vector2& position) const;
744 * Clamps position within the domain set up by X/Y Rulers
746 * @param[in,out] position The position you wish to clamp
748 void ClampPosition(Vector2& position) const;
751 * Clamps position within the domain set up by X/Y Rulers
753 * @param[in,out] position The position you wish to clamp
754 * @param[out] clamped The results of the clamping.
756 void ClampPosition(Vector2& position, ClampState2D& clamped) const;
759 * Wraps position within the domain set up by X/Y Rulers
761 * @note Only wraps if mWrapMode is enabled, and respective domains
764 * @param[in,out] position The position you wish to wrap
766 void WrapPosition(Vector2& position) const;
769 * Updates the main internal scroll constraints with new ruler and domain
772 void UpdateMainInternalConstraint();
775 * Enables/disables the overshoot constraints
777 * @param[in] enabled whether to enable or disable the overshoot constraints
779 void SetOvershootConstraintsEnabled(bool enabled);
782 * Sets internal constraints for this ScrollView.
783 * Many of these internal constraints are based on properties within
786 void SetInternalConstraints();
789 struct AccessibleImpl : public Scrollable::AccessibleImpl
791 using Scrollable::AccessibleImpl::AccessibleImpl;
793 bool ScrollToChild(Actor child) override;
797 * Construct a new ScrollView.
802 * A reference counted object may only be deleted by calling Unreference()
804 virtual ~ScrollView();
808 * Searches this ScrollView, and attempts to Unbind
809 * systematically this Actor from the ScrollView attached.
811 * @param[in] child The actor to be unbound.
813 void FindAndUnbindActor(Actor child) override;
816 * Gets position property.
818 * @return The current position
820 Vector2 GetPropertyPrePosition() const;
823 * Gets position property.
825 * @return The current position
827 Vector2 GetPropertyPosition() const;
830 * Handles a Stopped animation. Its position properties need to be saved, and the animation flag
833 void HandleStoppedAnimation();
836 * Handles a Stopped animation (whether the animation completed, or was
837 * manually stopped). Its position properties need to be saved, and the
838 * animation flag switched off.
840 void HandleSnapAnimationFinished();
843 * Checks if the property notifications are active and adds them if not
845 void SetScrollUpdateNotification(bool enabled);
848 * Refresh the ScrollView (used when animating to update application developer of changes)
849 * @return True if the refresh timer should be kept running.
851 void OnScrollUpdateNotification(Dali::PropertyNotification& source);
854 * Set up default rulers using a property map
855 * @param[in] scrollModeMap A map defining the characteristics of X and Y scrolling
856 * using either FixedRuler or DefaultRuler.
858 void SetScrollMode(const Property::Map& scrollModeMap);
862 ScrollView(const ScrollView&);
865 ScrollView& operator=(const ScrollView& rhs);
868 unsigned long mTouchDownTime; ///< The touch down time
870 int mGestureStackDepth; ///< How many gestures are currently occuring.
871 Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured
872 Vector2 mPanDelta; ///< Amount currently panned.
874 unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling
875 // Scroll delegate pre and post position properties...
876 Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
877 Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
878 Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll
879 Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
881 // Rulers for each axes...
885 // Last property values set to ScrollView
889 Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position
890 Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position
892 Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
895 Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior.
897 float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications
898 Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
899 Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification
901 Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
903 ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects.
905 Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
906 Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator
907 float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO
908 AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot.
910 float mSnapDuration; ///< Time for the snap animation to take (in seconds).
911 AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation.
913 Vector2 mMinFlickDistance; ///< Minimum pan distance required for a flick
914 float mFlickSpeedThreshold; ///< Minimum pan speed required for a flick in pixels/ms
915 float mFlickDuration; ///< Time for the flick animation to take (in seconds).
916 AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation.
918 float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
919 float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
920 float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
921 float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
923 Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received.
925 //ScrollInternalConstraintsPtr mScrollInternalConstraints;
926 Constraint mScrollMainInternalPrePositionConstraint;
927 Constraint mScrollMainInternalPositionConstraint;
928 Constraint mScrollMainInternalOvershootXConstraint;
929 Constraint mScrollMainInternalOvershootYConstraint;
930 Constraint mScrollMainInternalDeltaConstraint;
931 Constraint mScrollMainInternalFinalConstraint;
932 Constraint mScrollMainInternalRelativeConstraint;
933 Constraint mScrollMainInternalDomainConstraint;
934 Constraint mScrollMainInternalPrePositionMaxConstraint;
936 ScrollOvershootIndicatorPtr mOvershootIndicator;
937 WeakHandle<Toolkit::ScrollBar> mScrollBar;
939 Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal;
941 bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions
942 bool mScrolling : 1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
943 bool mScrollInterrupted : 1; ///< Flag set for when a down event interrupts a scroll
944 bool mPanning : 1; ///< Whether scroll view is currently panning or not
945 bool mSensitive : 1; ///< Scroll Sensitivity Flag.
946 bool mTouchDownTimeoutReached : 1; ///< Indicates when down event timeout occured without corresponding up event (touch still down)
947 bool mActorAutoSnapEnabled : 1; ///< Whether to automatically snap to closest actor.
948 bool mAutoResizeContainerEnabled : 1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
949 bool mWrapMode : 1; ///< Whether to wrap contents based on container size.
950 bool mAxisAutoLock : 1; ///< Whether to automatically lock axis when panning.
951 bool mAlterChild : 1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
952 bool mDefaultMaxOvershoot : 1; ///< Whether to use default max overshoot or application defined one
953 bool mCanScrollHorizontal : 1; ///< Local value of our property to check against
954 bool mCanScrollVertical : 1; ///< Local value of our property to check against
955 bool mTransientScrollBar : 1; ///< True if scroll-bar should be automatically show/hidden during/after panning
958 } // namespace Internal
960 // Helpers for public-api forwarding methods
962 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
964 DALI_ASSERT_ALWAYS(scrollView);
966 Dali::RefObject& handle = scrollView.GetImplementation();
968 return static_cast<Toolkit::Internal::ScrollView&>(handle);
971 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
973 DALI_ASSERT_ALWAYS(scrollView);
975 const Dali::RefObject& handle = scrollView.GetImplementation();
977 return static_cast<const Toolkit::Internal::ScrollView&>(handle);
980 } // namespace Toolkit
984 #endif // DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H