1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
5 * Copyright (c) 2014 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/dali.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
28 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
30 // predefined effect includes
31 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-custom-effect.h>
43 typedef IntrusivePtr<ScrollView> ScrollViewPtr;
45 class ScrollInternalConstraints;
46 typedef IntrusivePtr<ScrollInternalConstraints> ScrollInternalConstraintsPtr;
48 class ScrollOvershootIndicator;
49 typedef IntrusivePtr<ScrollOvershootIndicator> ScrollOvershootIndicatorPtr;
52 * @copydoc Toolkit::ScrollView
54 class ScrollView : public ScrollBase
59 * FindDirection specifies how searching is conducted within the Find... routines.
63 None = -3, ///< Includes none within the search query.
64 All = -2, ///< Includes all within the search query.
65 Left = -1, ///< Includes only those not right !(>)
66 Right = 1, ///< Includes only those right (>)
67 Up = -1, ///< Includes only those not below !(>)
68 Down = 1, ///< Includes only those below (>)
69 Out = -1, ///< Includes only those not infront !(>)
70 In = 1 ///< Includes only those infront (>)
75 LockPossible = 0, ///< Locking is possible, but not set in stone yet.
76 LockHorizontal, ///< Locking is set to horizontal. (can pan vertically)
77 LockVertical, ///< Locking is set to vertical. (can pan horizontally)
78 LockNone ///< Locking is set to none (free panning).
83 AnimatingInternalX = 0x01, ///< animating mPropertyX due to externally requested ScrollTo or internal snapping operation
84 AnimatingInternalY = 0x02, ///< animating mPropertyY due to externally requested ScrollTo or internal snapping operation
85 SnappingInternalX = 0x04, ///< snapping mPropertyX back to mPropertyPreScroll x value to remove x overshoot over time
86 SnappingInternalY = 0x08, ///< snapping mPropertyY back to mPropertyPreScroll y value to remove y overshoot over time
89 static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX;
90 static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY;
91 static const unsigned int SCROLL_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY;
92 static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY;
97 * Create a new ScrollView.
98 * @return A public handle to the newly allocated ScrollView.
100 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 * @brief ApplyEffect Applies a predefined effect
153 Toolkit::ScrollViewEffect ApplyEffect(Toolkit::ScrollView::PageEffect effect);
156 * @copydoc Toolkit::ScrollView::RemoveEffect
158 void RemoveEffect(Toolkit::ScrollViewEffect effect);
161 * @copydoc Toolkit::ScrollView::RemoveAllEffects
163 void RemoveAllEffects();
166 * @copydoc Toolkit::ScrollView::ApplyConstraintToChildren
168 void ApplyConstraintToChildren(Constraint constraint);
171 * @copydoc Toolkit::ScrollView::RemoveConstraintsFromChildren
173 void RemoveConstraintsFromChildren();
176 * @copydoc Toolkit::ScrollView::GetRulerX
178 const RulerPtr GetRulerX() const;
181 * @copydoc Toolkit::ScrollView::GetRulerY
183 const RulerPtr GetRulerY() const;
186 * @copydoc Toolkit::ScrollView::SetRulerX
188 void SetRulerX(RulerPtr ruler);
191 * @copydoc Toolkit::ScrollView::SetRulerY
193 void SetRulerY(RulerPtr ruler);
196 * @copydoc Toolkit::ScrollView::SetRulerScaleX
198 void SetRulerScaleX(RulerPtr ruler);
201 * @copydoc Toolkit::ScrollView::SetRulerScaleY
203 void SetRulerScaleY(RulerPtr ruler);
206 * Set Rotation axis ruler (defines how rotating is snapped in radians)
207 * @param[in] ruler The ruler to be used for the Rotation axis
209 void SetRulerRotation(RulerPtr ruler);
212 * @copydoc Toolkit::ScrollView::SetScrollSensitive
214 void SetScrollSensitive(bool sensitive);
217 * @copydoc Toolkit::ScrollView::SetMaxOvershoot
219 void SetMaxOvershoot(float overshootX, float overshootY);
222 * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
224 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
227 * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
229 void SetSnapOvershootDuration(float duration);
232 * @copydoc Toolkit::ScrollView::SetTouchesRequiredForPanning
234 void SetTouchesRequiredForPanning(unsigned int minTouches, unsigned int maxTouches, bool endOutside);
237 * @copydoc Toolkit::ScrollView::SetActorAutoSnap
239 void SetActorAutoSnap(bool enable);
242 * Enables or Disables Auto Resizing mode for ScrollView contents.
244 * When enabled, the ScrollView's X/Y Domains are restricted to the
245 * dimensions of the content's bounds, which may change as Actors are
246 * Added/Removed, and repositioned.
248 * @note This has been disabled for now, as this requires some fundamental
249 * changes to the way Actors positions and bounds are retrieved.
250 * (currently only constraints have these initial state knowledge)
252 * @param[in] enable Enables (true), or disables (false) Auto Resize.
254 void SetAutoResize(bool enable);
257 * Returns whether the wrap mode has been enabled (true) or not (false).
259 * @return Wrap Mode Enabled flag.
261 bool GetWrapMode() const;
264 * @copydoc Toolkit::ScrollView::SetWrapMode
266 void SetWrapMode(bool enable);
270 * @copydoc Toolkit::ScrollView::GetRefreshInterval
272 int GetRefreshInterval() const;
276 * @copydoc Toolkit::ScrollView::SetRefreshInterval
278 void SetRefreshInterval(int milliseconds);
281 * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
283 int GetScrollUpdateDistance() const;
286 * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
288 void SetScrollUpdateDistance(int distance);
291 * @copydoc Toolkit::ScrollView::GetAxisAutoLock
293 bool GetAxisAutoLock() const;
296 * @copydoc Toolkit::ScrollView::SetAxisAutoLock
298 void SetAxisAutoLock(bool enable);
301 * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
303 float GetAxisAutoLockGradient() const;
306 * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
308 void SetAxisAutoLockGradient(float gradient);
311 * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
313 float GetFrictionCoefficient() const;
316 * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
318 void SetFrictionCoefficient(float friction);
321 * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
323 float GetFlickSpeedCoefficient() const;
326 * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
328 void SetFlickSpeedCoefficient(float speed);
331 * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
333 float GetMaxFlickSpeed() const;
336 * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
338 void SetMaxFlickSpeed(float speed);
341 * @copydoc Toolkit::ScrollView::GetMouseWheelScrollDistanceStep
343 Vector2 GetMouseWheelScrollDistanceStep() const;
346 * @copydoc Toolkit::ScrollView::SetMouseWheelScrollDistanceStep
348 void SetMouseWheelScrollDistanceStep(Vector2 step);
351 * @copydoc Toolkit::ScrollView::GetCurrentPage
353 unsigned int GetCurrentPage() const;
356 * @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
358 Vector3 GetCurrentScrollPosition() const;
361 * @copydoc Toolkit::ScrollView::SetScrollPosition
363 void SetScrollPosition(const Vector3& position);
366 * @copydoc Toolkit::ScrollView::GetCurrentScrollScale
368 Vector3 GetCurrentScrollScale() const;
371 * @copydoc Toolkit::Scrollable::GetDomainSize
373 Vector3 GetDomainSize() const;
376 * @copydoc Toolkit::ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation)
378 void TransformTo(const Vector3& position, const Vector3& scale, float rotation,
379 DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
382 * @copydoc Toolkit::ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration)
384 void TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration,
385 DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
388 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position)
390 void ScrollTo(const Vector3 &position);
393 * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration)
395 void ScrollTo(const Vector3& position, float duration);
398 * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
400 void ScrollTo(const Vector3& position, float duration,
401 DirectionBias horizontalBias, DirectionBias verticalBias);
404 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page)
406 void ScrollTo(unsigned int page);
409 * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
411 void ScrollTo(unsigned int page, float duration, DirectionBias bias = DirectionBiasNone);
414 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor)
416 void ScrollTo(Actor &actor);
419 * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration)
421 void ScrollTo(Actor &actor, float duration);
424 * @copydoc Toolkit::ScrollView::SetScrollingDirection()
426 void SetScrollingDirection( Radian direction, Radian threshold );
429 * @copydoc Toolkit::ScrollView::RemoveScrollingDirection()
431 void RemoveScrollingDirection( Radian angle );
434 * Finds the closest Actor to the current center of the ScrollView.
436 * @return A handle to the actor if found, or an empty handle if not.
438 Actor FindClosestActor();
441 * Finds the closest Actor to position in ScrollView
443 * @param[in] position position within ScrollView.
444 * @param[in] dirX Whether to search only those elements that are Left,Right, or All
445 * @param[in] dirY Whether to search only those elements that are Up,Down, or All
446 * @param[in] dirZ Whether to search only those elements that are Out,In, or All
447 * @return A handle to the actor if found, or an empty handle if not.
449 Actor FindClosestActorToPosition(const Vector3& position, FindDirection dirX = All, FindDirection dirY = All, FindDirection dirZ = All);
452 * @copydoc Toolkit::ScrollView::ScrollToSnapPoint
454 bool ScrollToSnapPoint();
457 * @copydoc Toolkit::ScrollView::ScaleTo(const Vector3& scale)
459 void ScaleTo(const Vector3& scale);
462 * @copydoc Toolkit::ScrollView::ScaleTo(const Vector3& scale, float duration)
464 void ScaleTo(const Vector3& scale, float duration);
469 void StopAnimation(void);
472 * Stops the input animation
474 * @param[in] the animation to stop
476 void StopAnimation(Animation& animation);
479 * Animates to position/scale/rotation transform.
481 * @param[in] position The position to animate to
482 * @param[in] positionDuration The number of seconds this animation should run for in each axis.
483 * @param[in] scale The scale to animate to
484 * @param[in] scaleDuration The number of seconds this animation should run for in each axis.
485 * @param[in] rotation The angle to animate to
486 * @param[in] rotationDuration The number of seconds this animation should run for in each axis.
487 * @param[in] alpha The easing alpha function to use.
488 * @param[in] findShortcuts (optional) Whether to find the shortest route (in Wrap mode)
489 * @param[in] horizontalBias (optional) Whether to bias animation to left or right (or no biasing)
490 * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
491 * @return True if animation necessary and taking place to reach desired transform.
493 bool AnimateTo(const Vector3& position, const Vector3& positionDuration,
494 const Vector3& scale, const Vector3& scaleDuration,
495 float rotation, float rotationDuration,
496 AlphaFunction alpha, bool findShortcuts = true,
497 DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone,
498 SnapType snapType = Snap);
501 * @copydoc Toolkit::Scrollable::AddOverlay()
503 void AddOverlay(Actor actor);
506 * @copydoc Toolkit::Scrollable::RemoveOverlay()
508 void RemoveOverlay(Actor actor);
513 * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal()
515 Toolkit::ScrollView::SnapStartedSignalV2& SnapStartedSignal();
518 * Connects a callback function with the object's signals.
519 * @param[in] object The object providing the signal.
520 * @param[in] tracker Used to disconnect the signal.
521 * @param[in] signalName The signal to connect to.
522 * @param[in] functor A newly allocated FunctorDelegate.
523 * @return True if the signal was connected.
524 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
526 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
528 private: // private overriden functions from CustomActorImpl and Controls
531 * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
533 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
536 * @copydoc Dali::Control::OnControlSizeSet(const Vector3&)
538 virtual void OnControlSizeSet( const Vector3& size );
541 * From CustomActorImpl; called after a child has been added to the owning actor.
542 * @param[in] child The child which has been added.
544 virtual void OnChildAdd(Actor& child);
547 * From CustomActorImpl; called shortly before a child is removed from the owning actor.
548 * @param[in] child The child being removed.
550 virtual void OnChildRemove(Actor& child);
553 * @copydoc Dali::CustomActorImpl::OnPropertySet( Property::Index index, Property::Value propertyValue )
555 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
558 * From CustomActorImpl; called after a touch-signal is received by the owning actor.
560 * We don't listen to these events as content within the contain may consume events.
562 * @param[in] event The touch event.
563 * @return True if the event should be consumed.
565 virtual bool OnTouchEvent(const TouchEvent& event);
568 * From CustomActorImpl; called after a mouse-wheel-event is received by the owning actor.
569 * @param[in] event The mouse wheel event.
570 * @return True if the event should be consumed.
572 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event);
575 * @copydoc Toolkit::Control::OnInitialize()
577 virtual void OnInitialize();
580 * @copydoc Toolkit::Control::OnControlStageConnection()
582 virtual void OnControlStageConnection();
585 * @copydoc Toolkit::Control::OnControlStageConnection()
587 virtual void OnControlStageDisconnection();
590 * @copydoc Toolkit::Control::OnAccessibilityPan()
592 virtual bool OnAccessibilityPan(PanGesture gesture);
595 * @copydoc Toolkit::Scrollable::SetOvershootEnabled()
597 virtual void SetOvershootEnabled(bool enable);
602 * Start a timer which calls OnTouchDownTimeout()
604 void StartTouchDownTimer();
607 * Stop a timer which calls OnTouchDownTimeout()
609 void StopTouchDownTimer();
612 * Helper to detect when touch-point has been down (outside of pan gesture)
614 bool OnTouchDownTimeout();
617 * Called whenever a snap animation has completed
618 * @param[in] source the Animation instance that has completed.
619 * Resets all scrolling animations and states, leaving current scroll position at mPropertyPosition
621 void ResetScrolling();
624 * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
626 void UpdateLocalScrollProperties();
629 * Makes sure scroll values are ready for animated scrolling
631 void PreAnimatedScrollSetup();
634 * Finish an animated scroll, ensuring all scroll properties are updated
637 void FinaliseAnimatedScroll();
640 * Animates the internal x property to the given value
642 * @param[in] position The X position to animate to
643 * @param[in] duration The time in seconds for animation
644 * @param[in] alpha The alpha function to use for animating
646 void AnimateInternalXTo( float position, float duration, AlphaFunction alpha );
649 * Animates the internal y property to the given value
651 * @param[in] position The Y position to animate to
652 * @param[in] duration The time in seconds for animation
653 * @param[in] alpha The alpha function to use for animating
655 void AnimateInternalYTo( float position, float duration, AlphaFunction alpha );
658 * Called whenever a snap animation on the x-axis has completed
659 * @param[in] source the Animation instance that has completed.
661 void OnScrollAnimationFinished( Animation& source );
664 * Called when either the X or Y internal scroll positions have finished snapping back to mPropertyPrePosition
666 * @param[in] source the Animation instance that has completed.
668 void OnSnapInternalPositionFinished( Animation& source );
671 * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
672 * position to our clamped position
673 * @param[in] position The x position to snap pre scroll property to
675 void SnapInternalXTo( float position );
678 * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
679 * position to our clamped position
680 * @param[in] position The y position to snap pre scroll property to
682 void SnapInternalYTo( float position );
685 * This is called internally whenever the Scroll Rulers are
686 * modified. This will update the properties: 'scroll-position-min'
687 * and 'scroll-position-max' to reflect the changes.
689 * @param[in] size size of the visible scroll area (ScrollView control size)
691 void UpdatePropertyDomain(const Vector3& size);
694 * Called when the gesture starts.
696 void GestureStarted();
699 * Amalgamated Gesture Continuing event
701 * @param[in] panDelta average panning delta from base position (0)
702 * @param[in] scaleDelta average scale delta from base scale (1)
703 * @param[in] rotationDelta average rotation delta from base angle (0)
705 void GestureContinuing(const Vector2& panDelta, const Vector2& scaleDelta, float rotationDelta);
708 * Called upon pan gesture event.
710 * @param[in] gesture The gesture event.
712 void OnPan(PanGesture pan);
715 * Extension of the above gestures.
717 * @param[in] gesture The gesture event.
719 void OnGestureEx(Gesture::State state);
722 * Performs snapping while taking into account Velocity of gesture
723 * (velocity in pixels/sec)
725 * @param[in] velocity velocity in pixels/sec
727 bool SnapWithVelocity(Vector2 velocity);
730 * Updates Container Transform based on Pan, Scale, and Rotation props.
731 * (occurs when continuing gesture i.e. dragging/pinching.)
733 void UpdateTransform();
736 * Finishes Container Transform
737 * (occurs upon finishing gesture i.e. releasing)
739 void FinishTransform();
742 * Returns overshoot vector based on current position
744 * Overshoot vector is defined as how far outside of bounds
745 * the viewport is trying to view (prior to being clamped).
747 * an overshoot of (100,50), means user is in bottom right corner,
748 * trying to pan +100 to the right, and +50 below. This can be used
749 * to determine an effect, such as stretching.
751 * @param[in] position The position for which you wish to obtain overshoot vector
753 Vector3 GetOvershoot(Vector3& position) const;
756 * Clamps position within the domain set up by X/Y Rulers
758 * @param[in,out] position The position you wish to clamp
760 void ClampPosition(Vector3& position) const;
763 * Clamps position within the domain set up by X/Y Rulers
765 * @param[in,out] position The position you wish to clamp
766 * @param[out] clamped The results of the clamping.
768 void ClampPosition(Vector3& position, ClampState3 &clamped) const;
771 * Wraps position within the domain set up by X/Y Rulers
773 * @note Only wraps if mWrapMode is enabled, and respective domains
776 * @param[in,out] position The position you wish to wrap
778 void WrapPosition(Vector3& position) const;
781 * Clamps scale within the domain set up by Scale-X/Scale-Y Rulers
783 * @param[in,out] scale The scale you wish to clamp
785 void ClampScale(Vector3& scale) const;
788 * Clamps scale within the domain set up by Scale-X/Scale-Y Rulers
790 * @param[in,out] scale The scale you wish to clamp
791 * @param[out] clamped The results of the clamping.
793 void ClampScale(Vector3& scale, ClampState3 &clamped) const;
796 * Updates the main internal scroll constraints with new ruler and domain
799 void UpdateMainInternalConstraint();
802 * Enables/disables the overshoot constraints
804 * @param[in] enabled whether to enable or disable the overshoot constraints
806 void SetOvershootConstraintsEnabled(bool enabled);
809 * Sets internal constraints for this ScrollView.
810 * Many of these internal constraints are based on properties within
813 void SetInternalConstraints();
818 * Construct a new ScrollView.
823 * A reference counted object may only be deleted by calling Unreference()
825 virtual ~ScrollView();
830 * Searches this ScrollView, and attempts to Unbind
831 * systematically this Actor from the ScrollView attached.
833 * @param[in] child The actor to be unbound.
835 virtual void FindAndUnbindActor(Actor child);
838 * Gets position property.
840 * @return The current position
842 Vector3 GetPropertyPrePosition() const;
845 * Gets position property.
847 * @return The current position
849 Vector3 GetPropertyPosition() const;
852 * Gets scale property.
854 * @return The current scale
856 Vector3 GetPropertyScale() const;
859 * Handles a Stopped animation. Its position/scale/rotation properties need to be
860 * saved, and the animation flag switched off.
862 void HandleStoppedAnimation();
865 * Handles a Stopped animation (whether the animation completed, or was
866 * manually stopped). Its position/scale/rotation properties need to be
867 * saved, and the animation flag switched off.
869 void HandleSnapAnimationFinished();
872 * Checks if the property notifications are active and adds them if not
874 void SetScrollUpdateNotification( bool enabled );
877 * Refresh the ScrollView (used when animating to update application developer of changes)
878 * @return True if the refresh timer should be kept running.
880 void OnScrollUpdateNotification(Dali::PropertyNotification& source);
885 ScrollView(const ScrollView&);
888 ScrollView& operator=(const ScrollView& rhs);
892 unsigned long mTouchDownTime; ///< The touch down time
894 int mGestureStackDepth; ///< How many gestures are currently occuring.
895 Vector2 mGestureReferencePosition; ///< Point where scaling should occur from.
896 Vector2 mPinchGestureLastPosition;
897 Vector2 mPinchGestureLastScale;
899 Vector3 mPanDelta; ///< Amount currently panned.
900 Vector3 mScaleDelta; ///< Amount currently scaled.
901 float mRotationDelta; ///< Amount currently rotated.
903 unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling
904 // Scroll delegate pre and post position/scale/rotation properties...
905 Vector3 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
906 Vector3 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
907 Vector3 mScrollTargetPosition; ///< Final target position for an animated scroll
908 Vector3 mScrollPreScale; ///< Scroll delegate pre-scale
909 Vector3 mScrollPostScale; ///< Scroll delegate post-scale (affected by current touch)
910 float mScrollPreRotation; ///< Scroll delegate pre-rotation
911 float mScrollPostRotation; ///< Scroll delegate post-rotation (affected by current touch)
912 Vector3 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
914 // Rulers for each axes...
917 RulerPtr mRulerScaleX;
918 RulerPtr mRulerScaleY;
919 RulerPtr mRulerRotation;
921 // Last property values set to ScrollView
925 unsigned int mMinTouchesForPanning; ///< Minimum number of touches for panning to be used.
926 unsigned int mMaxTouchesForPanning; ///< Maximum number of touches for panning to be used.
928 Animation mSnapAnimation; ///< Used to animate rotation and scaling of scroll properties
929 Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position
930 Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position
933 Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
936 Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouchEvent without breaking fast flick behavior.
938 float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications
939 Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
940 Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification
942 Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
944 ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects.
946 float mOvershootDelay; ///< Time to wait for input before reducing overshoot back to 0
947 Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
948 Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator
949 float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector3::ZERO
950 AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot.
952 float mSnapDuration; ///< Time for the snap animation to take (in seconds).
953 AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation.
955 float mFlickDuration; ///< Time for the flick animation to take (in seconds).
956 AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation.
958 float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
959 float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
960 float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
961 float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
963 Vector2 mMouseWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each mouse wheel event received.
965 //ScrollInternalConstraintsPtr mScrollInternalConstraints;
966 ActiveConstraint mScrollMainInternalPrePositionConstraint;
967 ActiveConstraint mScrollMainInternalPositionConstraint;
968 ActiveConstraint mScrollMainInternalXConstraint;
969 ActiveConstraint mScrollMainInternalYConstraint;
970 ActiveConstraint mScrollMainInternalOvershootXConstraint;
971 ActiveConstraint mScrollMainInternalOvershootYConstraint;
972 ActiveConstraint mScrollMainInternalDeltaConstraint;
973 ActiveConstraint mScrollMainInternalFinalConstraint;
974 ActiveConstraint mScrollMainInternalRelativeConstraint;
976 ScrollOvershootIndicatorPtr mOvershootIndicator;
978 Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
980 bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions
982 bool mScrolling:1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
983 bool mScrollInterrupted:1; ///< Flag set for when a down event interrupts a scroll
984 bool mPanning:1; ///< Whether scroll view is currently panning or not
985 bool mSensitive:1; ///< Scroll Sensitivity Flag.
986 bool mTouchDownTimeoutReached:1; ///< Indicates when down event timeout occured without corresponding up event (touch still down)
987 bool mActorAutoSnapEnabled:1; ///< Whether to automatically snap to closest actor.
988 bool mAutoResizeContainerEnabled:1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
989 bool mWrapMode:1; ///< Whether to wrap contents based on container size.
990 bool mAxisAutoLock:1; ///< Whether to automatically lock axis when panning.
991 bool mAlterChild:1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
992 bool mDefaultMaxOvershoot:1; ///< Whether to use default max overshoot or application defined one
993 bool mUserSetPosition:1; ///< SetScrollPosition has been called, return this position until internals get control of scroll position again
994 bool mCanScrollHorizontal:1; ///< Local value of our property to check against
995 bool mCanScrollVertical:1; ///< Local value of our property to check against
998 } // namespace Internal
1000 // Helpers for public-api forwarding methods
1002 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
1004 DALI_ASSERT_ALWAYS(scrollView);
1006 Dali::RefObject& handle = scrollView.GetImplementation();
1008 return static_cast<Toolkit::Internal::ScrollView&>(handle);
1011 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
1013 DALI_ASSERT_ALWAYS(scrollView);
1015 const Dali::RefObject& handle = scrollView.GetImplementation();
1017 return static_cast<const Toolkit::Internal::ScrollView&>(handle);
1020 } // namespace Toolkit
1024 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__