X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.h;h=406172728746cf9f7044b9cd982d27adeb7c2006;hp=ab5f862f67ded69c8996f457d0e97f0ac92747b0;hb=3ce558ca09f928cb18cacfa80f52eb0c591181b9;hpb=49156a77e39850cdb7f77143dc54ed2701c476ca diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h index ab5f862..4061727 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__ -#define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__ +#ifndef DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H +#define DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,53 +22,52 @@ #include #include #include -#include +#include // INTERNAL INCLUDES -#include -#include +#include #include -#include +#include #include +#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - class ScrollView; -typedef IntrusivePtr ScrollViewPtr; +typedef IntrusivePtr ScrollViewPtr; class ScrollInternalConstraints; -typedef IntrusivePtr ScrollInternalConstraintsPtr; +typedef IntrusivePtr ScrollInternalConstraintsPtr; class ScrollOvershootIndicator; typedef IntrusivePtr ScrollOvershootIndicatorPtr; +class ScrollViewPropertyHandler; + /** * @copydoc Toolkit::ScrollView */ class ScrollView : public ScrollBase { public: - /** * FindDirection specifies how searching is conducted within the Find... routines. */ enum FindDirection { - None = -3, ///< Includes none within the search query. - All = -2, ///< Includes all within the search query. - Left = -1, ///< Includes only those not right !(>) - Right = 1, ///< Includes only those right (>) - Up = -1, ///< Includes only those not below !(>) - Down = 1, ///< Includes only those below (>) - Out = -1, ///< Includes only those not infront !(>) - In = 1 ///< Includes only those infront (>) + None = -3, ///< Includes none within the search query. + All = -2, ///< Includes all within the search query. + Left = -1, ///< Includes only those not right !(>) + Right = 1, ///< Includes only those right (>) + Up = -1, ///< Includes only those not below !(>) + Down = 1, ///< Includes only those below (>) + Out = -1, ///< Includes only those not infront !(>) + In = 1 ///< Includes only those infront (>) }; enum LockAxis @@ -87,18 +86,16 @@ public: SnappingInternalY = 0x08, ///< snapping mPropertyY back to mPropertyPreScroll y value to remove y overshoot over time }; - static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX; - static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY; + static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX; + static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY; static const unsigned int SCROLL_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY; - static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY; + static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY; private: - typedef std::vector ScrollViewEffectContainer; ///< Container of Dali::Toolkit::ScrollViewEffect - typedef ScrollViewEffectContainer::iterator ScrollViewEffectIter; ///< Iterator for Dali::Toolkit::ScrollViewEffectContainer + typedef ScrollViewEffectContainer::iterator ScrollViewEffectIter; ///< Iterator for Dali::Toolkit::ScrollViewEffectContainer public: - /** * Create a new ScrollView. * @return A public handle to the newly allocated ScrollView. @@ -106,46 +103,69 @@ public: static Dali::Toolkit::ScrollView New(); public: - /** * @copydoc Toolkit::ScrollView::GetScrollSnapAlphaFunction */ - AlphaFunction GetScrollSnapAlphaFunction() const; + AlphaFunction GetScrollSnapAlphaFunction() const + { + return mSnapAlphaFunction; + } /** * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction */ - void SetScrollSnapAlphaFunction(AlphaFunction alpha); + void SetScrollSnapAlphaFunction(AlphaFunction alpha) + { + mSnapAlphaFunction = alpha; + } /** * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction */ - AlphaFunction GetScrollFlickAlphaFunction() const; + AlphaFunction GetScrollFlickAlphaFunction() const + { + return mFlickAlphaFunction; + } /** * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction */ - void SetScrollFlickAlphaFunction(AlphaFunction alpha); + void SetScrollFlickAlphaFunction(AlphaFunction alpha) + { + mFlickAlphaFunction = alpha; + } /** * @copydoc Toolkit::ScrollView::GetScrollSnapDuration */ - float GetScrollSnapDuration() const; + float GetScrollSnapDuration() const + { + return mSnapDuration; + } /** * @copydoc Toolkit::ScrollView::SetScrollSnapDuration */ - void SetScrollSnapDuration(float time); + void SetScrollSnapDuration(float time) + { + mSnapDuration = time; + } /** * @copydoc Toolkit::ScrollView::GetScrollFlickDuration */ - float GetScrollFlickDuration() const; + float GetScrollFlickDuration() const + { + return mFlickDuration; + } /** * @copydoc Toolkit::ScrollView::SetScrollFlickDuration */ - void SetScrollFlickDuration(float time); + void SetScrollFlickDuration(float time) + { + mFlickDuration = time; + } /** * @copydoc Toolkit::ScrollView::ApplyEffect @@ -175,12 +195,18 @@ public: /** * @copydoc Toolkit::ScrollView::GetRulerX */ - const RulerPtr GetRulerX() const; + const RulerPtr GetRulerX() const + { + return mRulerX; + } /** * @copydoc Toolkit::ScrollView::GetRulerY */ - const RulerPtr GetRulerY() const; + const RulerPtr GetRulerY() const + { + return mRulerY; + } /** * @copydoc Toolkit::ScrollView::SetRulerX @@ -197,7 +223,10 @@ public: * * @return whether the touch sensitivity is true or false. */ - bool GetScrollSensitive(); + bool GetScrollSensitive() + { + return mSensitive; + } /** * @copydoc Toolkit::ScrollView::SetScrollSensitive @@ -212,19 +241,28 @@ public: /** * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction */ - void SetSnapOvershootAlphaFunction(AlphaFunction alpha); + void SetSnapOvershootAlphaFunction(AlphaFunction alpha) + { + mSnapOvershootAlphaFunction = alpha; + } /** * Retrieve the duartion of Snap Overshoot animation * * @return the duration. */ - float GetSnapOvershootDuration(); + float GetSnapOvershootDuration() + { + return mSnapOvershootDuration; + } /** * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration */ - void SetSnapOvershootDuration(float duration); + void SetSnapOvershootDuration(float duration) + { + mSnapOvershootDuration = duration; + } /** * Retrieve whether Actor Auto-Snap mode is enabled or not. @@ -236,7 +274,10 @@ public: /** * @copydoc Toolkit::ScrollView::SetActorAutoSnap */ - void SetActorAutoSnap(bool enable); + void SetActorAutoSnap(bool enable) + { + mActorAutoSnapEnabled = enable; + } /** * Enables or Disables Auto Resizing mode for ScrollView contents. @@ -258,7 +299,10 @@ public: * * @return Wrap Mode Enabled flag. */ - bool GetWrapMode() const; + bool GetWrapMode() const + { + return mWrapMode; + } /** * @copydoc Toolkit::ScrollView::SetWrapMode @@ -268,17 +312,26 @@ public: /** * @copydoc Toolkit::ScrollView::GetScrollupdateDistance */ - int GetScrollUpdateDistance() const; + int GetScrollUpdateDistance() const + { + return mScrollUpdateDistance; + } /** * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance */ - void SetScrollUpdateDistance(int distance); + void SetScrollUpdateDistance(int distance) + { + mScrollUpdateDistance = distance; + } /** * @copydoc Toolkit::ScrollView::GetAxisAutoLock */ - bool GetAxisAutoLock() const; + bool GetAxisAutoLock() const + { + return mAxisAutoLock; + } /** * @copydoc Toolkit::ScrollView::SetAxisAutoLock @@ -288,7 +341,10 @@ public: /** * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient */ - float GetAxisAutoLockGradient() const; + float GetAxisAutoLockGradient() const + { + return mAxisAutoLockGradient; + } /** * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient @@ -298,7 +354,10 @@ public: /** * @copydoc Toolkit::ScrollView::GetFrictionCoefficient */ - float GetFrictionCoefficient() const; + float GetFrictionCoefficient() const + { + return mFrictionCoefficient; + } /** * @copydoc Toolkit::ScrollView::SetFrictionCoefficient @@ -308,52 +367,82 @@ public: /** * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient */ - float GetFlickSpeedCoefficient() const; + float GetFlickSpeedCoefficient() const + { + return mFlickSpeedCoefficient; + } /** * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient */ - void SetFlickSpeedCoefficient(float speed); + void SetFlickSpeedCoefficient(float speed) + { + mFlickSpeedCoefficient = speed; + } /** * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick */ - Vector2 GetMinimumDistanceForFlick() const; + Vector2 GetMinimumDistanceForFlick() const + { + return mMinFlickDistance; + } /** * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick */ - void SetMinimumDistanceForFlick( const Vector2& distance ); + void SetMinimumDistanceForFlick(const Vector2& distance) + { + mMinFlickDistance = distance; + } /** * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick */ - float GetMinimumSpeedForFlick() const; + float GetMinimumSpeedForFlick() const + { + return mFlickSpeedThreshold; + } /** * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick */ - void SetMinimumSpeedForFlick( float speed ); + void SetMinimumSpeedForFlick(float speed) + { + mFlickSpeedThreshold = speed; + } /** * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed */ - float GetMaxFlickSpeed() const; + float GetMaxFlickSpeed() const + { + return mMaxFlickSpeed; + } /** * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed */ - void SetMaxFlickSpeed(float speed); + void SetMaxFlickSpeed(float speed) + { + mMaxFlickSpeed = speed; + } /** * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep */ - Vector2 GetWheelScrollDistanceStep() const; + Vector2 GetWheelScrollDistanceStep() const + { + return mWheelScrollDistanceStep; + } /** * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep */ - void SetWheelScrollDistanceStep(Vector2 step); + void SetWheelScrollDistanceStep(Vector2 step) + { + mWheelScrollDistanceStep = step; + } /** * @copydoc Toolkit::ScrollView::GetCurrentPage @@ -369,18 +458,18 @@ public: * @copydoc ScrollTo(const Vector2&) */ void TransformTo(const Vector2& position, - DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone); + DirectionBias horizontalBias = DIRECTION_BIAS_NONE, + DirectionBias verticalBias = DIRECTION_BIAS_NONE); /** * @copydoc ScrollTo(const Vector2&, float, AlhpaFunction, DirectionBias, DirectionBias) */ - void TransformTo(const Vector2& position, float duration, AlphaFunction alpha, - DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone); + void TransformTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias = DIRECTION_BIAS_NONE, DirectionBias verticalBias = DIRECTION_BIAS_NONE); /** * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position) */ - void ScrollTo(const Vector2 &position); + void ScrollTo(const Vector2& position); /** * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration) @@ -395,14 +484,12 @@ public: /** * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias) */ - void ScrollTo(const Vector2& position, float duration, - DirectionBias horizontalBias, DirectionBias verticalBias); + void ScrollTo(const Vector2& position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias); /** * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias) */ - void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, - DirectionBias horizontalBias, DirectionBias verticalBias); + void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias); /** * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page) @@ -412,34 +499,34 @@ public: /** * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias) */ - void ScrollTo(unsigned int page, float duration, DirectionBias bias = DirectionBiasNone); + void ScrollTo(unsigned int page, float duration, DirectionBias bias = DIRECTION_BIAS_NONE); /** * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor) */ - void ScrollTo(Actor &actor); + void ScrollTo(Actor& actor); /** * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration) */ - void ScrollTo(Actor &actor, float duration); + void ScrollTo(Actor& actor, float duration); /** * @copydoc Toolkit::ScrollView::SetScrollingDirection() */ - void SetScrollingDirection( Radian direction, Radian threshold ); + void SetScrollingDirection(Radian direction, Radian threshold); /** * @copydoc Toolkit::ScrollView::RemoveScrollingDirection() */ - void RemoveScrollingDirection( Radian angle ); + void RemoveScrollingDirection(Radian angle); /** * Finds the closest Actor to the current center of the ScrollView. * * @return A handle to the actor if found, or an empty handle if not. */ - Actor FindClosestActor(); + Actor FindClosestActor(); /** * Finds the closest Actor to position in ScrollView @@ -480,10 +567,7 @@ public: * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing) * @return True if animation necessary and taking place to reach desired transform. */ - bool AnimateTo(const Vector2& position, const Vector2& positionDuration, - AlphaFunction alpha, bool findShortcuts = true, - DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone, - SnapType snapType = Snap); + 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); /** * @copydoc Toolkit::Scrollable::AddOverlay() @@ -498,12 +582,12 @@ public: /** * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize */ - void SetOvershootSize( const Vector2& size ); + void SetOvershootSize(const Vector2& size); /** * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor */ - void SetOvershootEffectColor( const Vector4& color ); + void SetOvershootEffectColor(const Vector4& color); //properties @@ -513,7 +597,7 @@ public: * @param[in] index The property index. * @param[in] value The new property value. */ - static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); + static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value); /** * Called to retrieve a property of an object of this type. @@ -521,10 +605,9 @@ public: * @param[in] index The property index. * @return The current value of the property. */ - static Property::Value GetProperty( BaseObject* object, Property::Index index ); + static Property::Value GetProperty(BaseObject* object, Property::Index index); public: //Signals - /** * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal() */ @@ -539,66 +622,65 @@ public: //Signals * @return True if the signal was connected. * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor); private: // private overridden functions from CustomActorImpl and Controls - /** * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&) */ - virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); + void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override; /** * @copydoc CustomActorImpl::OnSizeSet(const Vector3&) */ - virtual void OnSizeSet( const Vector3& size ); + void OnSizeSet(const Vector3& size) override; /** * From CustomActorImpl; called after a child has been added to the owning actor. * @param[in] child The child which has been added. */ - virtual void OnChildAdd(Actor& child); + void OnChildAdd(Actor& child) override; /** * From CustomActorImpl; called shortly before a child is removed from the owning actor. * @param[in] child The child being removed. */ - virtual void OnChildRemove(Actor& child); + void OnChildRemove(Actor& child) override; /** - * From CustomActorImpl; called after a wheelEvent is received by the owning actor. + * Called after a wheelEvent is received by the owning actor. + * @param[in] actor Actor associated with the event. * @param[in] event The wheel event. * @return True if the event should be consumed. */ - virtual bool OnWheelEvent(const WheelEvent& event); + bool OnWheelEvent(Actor actor, const WheelEvent& event); /** * @copydoc Toolkit::Control::OnInitialize() */ - virtual void OnInitialize(); + void OnInitialize() override; /** - * @copydoc CustomActorImpl::OnStageConnection() + * @copydoc CustomActorImpl::OnSceneConnection() */ - virtual void OnStageConnection( int depth ); + void OnSceneConnection(int depth) override; /** - * @copydoc CustomActorImpl::OnStageDisconnection() + * @copydoc CustomActorImpl::OnSceneDisconnection() */ - virtual void OnStageDisconnection(); + void OnSceneDisconnection() override; /** * @copydoc Toolkit::Control::OnAccessibilityPan() */ - virtual bool OnAccessibilityPan(PanGesture gesture); + bool OnAccessibilityPan(PanGesture gesture) override; /** * @copydoc Toolkit::Scrollable::EnableScrollOvershoot() */ - virtual void EnableScrollOvershoot(bool enable); + void EnableScrollOvershoot(bool enable) override; private: - /** * Called after a touchSignal is received by the owning actor. * @@ -608,7 +690,7 @@ private: * @param[in] touch The touch information. * @return True if the event should be consumed. */ - bool OnTouch( Actor actor, const TouchData& touch ); + bool OnTouch(Actor actor, const TouchEvent& touch); /** * Start a timer which calls OnTouchDownTimeout() @@ -655,7 +737,7 @@ private: * @param[in] duration The time in seconds for animation * @param[in] alpha The alpha function to use for animating */ - void AnimateInternalXTo( float position, float duration, AlphaFunction alpha ); + void AnimateInternalXTo(float position, float duration, AlphaFunction alpha); /** * Animates the internal y property to the given value @@ -664,41 +746,34 @@ private: * @param[in] duration The time in seconds for animation * @param[in] alpha The alpha function to use for animating */ - void AnimateInternalYTo( float position, float duration, AlphaFunction alpha ); + void AnimateInternalYTo(float position, float duration, AlphaFunction alpha); /** * Called whenever a snap animation on the x-axis has completed * @param[in] source the Animation instance that has completed. */ - void OnScrollAnimationFinished( Animation& source ); + void OnScrollAnimationFinished(Animation& source); /** * Called when either the X or Y internal scroll positions have finished snapping back to SCROLL_PRE_POSITION * * @param[in] source the Animation instance that has completed. */ - void OnSnapInternalPositionFinished( Animation& source ); + void OnSnapInternalPositionFinished(Animation& source); /** * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll * position to our clamped position * @param[in] position The x position to snap pre scroll property to */ - void SnapInternalXTo( float position ); + void SnapInternalXTo(float position); /** * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll * position to our clamped position * @param[in] position The y position to snap pre scroll property to */ - void SnapInternalYTo( float position ); - - /** - * This is called internally whenever the Scroll Rulers are - * modified. This will update the properties: 'scrollPositionMin' - * and 'scrollPositionMax' to reflect the changes. - */ - void UpdatePropertyDomain(); + void SnapInternalYTo(float position); /** * Called when the gesture starts. @@ -717,14 +792,14 @@ private: * * @param[in] gesture The gesture event. */ - void OnPan( const PanGesture& pan); + void OnPan(const PanGesture& pan); /** * Extension of the above gestures. * * @param[in] gesture The gesture event. */ - void OnGestureEx(Gesture::State state); + void OnGestureEx(GestureState state); /** * Performs snapping while taking into account Velocity of gesture @@ -741,20 +816,6 @@ private: void FinishTransform(); /** - * Returns overshoot vector based on current position - * - * Overshoot vector is defined as how far outside of bounds - * the viewport is trying to view (prior to being clamped). - * - * an overshoot of (100,50), means user is in bottom right corner, - * trying to pan +100 to the right, and +50 below. This can be used - * to determine an effect, such as stretching. - * - * @param[in] position The position for which you wish to obtain overshoot vector - */ - Vector2 GetOvershoot(Vector2& position) const; - - /** * Clamps position within the domain set up by X/Y Rulers * * @param[in,out] position The position you wish to clamp @@ -767,7 +828,7 @@ private: * @param[in,out] position The position you wish to clamp * @param[out] clamped The results of the clamping. */ - void ClampPosition(Vector2& position, ClampState2D &clamped) const; + void ClampPosition(Vector2& position, ClampState2D& clamped) const; /** * Wraps position within the domain set up by X/Y Rulers @@ -779,27 +840,13 @@ private: */ void WrapPosition(Vector2& position) const; - /** - * Updates the main internal scroll constraints with new ruler and domain - * values - */ - void UpdateMainInternalConstraint(); - - /** - * Enables/disables the overshoot constraints - * - * @param[in] enabled whether to enable or disable the overshoot constraints - */ - void SetOvershootConstraintsEnabled(bool enabled); - - /** - * Sets internal constraints for this ScrollView. - * Many of these internal constraints are based on properties within - * ScrollView. - */ - void SetInternalConstraints(); - protected: + struct AccessibleImpl : public Scrollable::AccessibleImpl + { + using Scrollable::AccessibleImpl::AccessibleImpl; + + bool ScrollToChild(Actor child) override; + }; /** * Construct a new ScrollView. @@ -812,14 +859,13 @@ protected: virtual ~ScrollView(); private: - /** * Searches this ScrollView, and attempts to Unbind * systematically this Actor from the ScrollView attached. * * @param[in] child The actor to be unbound. */ - virtual void FindAndUnbindActor(Actor child); + void FindAndUnbindActor(Actor child) override; /** * Gets position property. @@ -851,7 +897,7 @@ private: /** * Checks if the property notifications are active and adds them if not */ - void SetScrollUpdateNotification( bool enabled ); + void SetScrollUpdateNotification(bool enabled); /** * Refresh the ScrollView (used when animating to update application developer of changes) @@ -859,15 +905,7 @@ private: */ void OnScrollUpdateNotification(Dali::PropertyNotification& source); - /** - * Set up default rulers using a property map - * @param[in] scrollModeMap A map defining the characteristics of X and Y scrolling - * using either FixedRuler or DefaultRuler. - */ - void SetScrollMode( const Property::Map& scrollModeMap ); - private: - // Undefined ScrollView(const ScrollView&); @@ -875,19 +913,20 @@ private: ScrollView& operator=(const ScrollView& rhs); private: + ScrollViewConstraints mConstraints; - unsigned long mTouchDownTime; ///< The touch down time + unsigned long mTouchDownTime; ///< The touch down time - int mGestureStackDepth; ///< How many gestures are currently occuring. - Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured - Vector2 mPanDelta; ///< Amount currently panned. + int mGestureStackDepth; ///< How many gestures are currently occuring. + Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured + Vector2 mPanDelta; ///< Amount currently panned. - unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling + unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling // Scroll delegate pre and post position properties... - Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped - Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used - Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll - Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses) + Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped + Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used + Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll + Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses) // Rulers for each axes... RulerPtr mRulerX; @@ -897,76 +936,78 @@ private: Vector2 mMinScroll; Vector2 mMaxScroll; - Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position - Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position + Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position + Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position - - Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity) + Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity) LockAxis mLockAxis; - Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior. + Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior. - float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications + float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification - Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches) - - ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects. + Actor mInternalActor; ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches) - Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f - Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator - float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO - AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot. + ScrollViewEffectContainer mEffects; ///< Container keeping track of all the applied effects. - float mSnapDuration; ///< Time for the snap animation to take (in seconds). - AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation. + Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f + Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator + float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO + AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot. - Vector2 mMinFlickDistance; ///< Minimum pan distance required for a flick - float mFlickSpeedThreshold; ///< Minimum pan speed required for a flick in pixels/ms - float mFlickDuration; ///< Time for the flick animation to take (in seconds). - AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation. + float mSnapDuration; ///< Time for the snap animation to take (in seconds). + AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation. - float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis. - float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec - float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this. - float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec. + Vector2 mMinFlickDistance; ///< Minimum pan distance required for a flick + float mFlickSpeedThreshold; ///< Minimum pan speed required for a flick in pixels/ms + float mFlickDuration; ///< Time for the flick animation to take (in seconds). + AlphaFunction mFlickAlphaFunction; ///< AlphaFunction to be used for the Flick Animation. - Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received. + float mAxisAutoLockGradient; ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis. + float mFrictionCoefficient; ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec + float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this. + float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec. - //ScrollInternalConstraintsPtr mScrollInternalConstraints; - Constraint mScrollMainInternalPrePositionConstraint; - Constraint mScrollMainInternalPositionConstraint; - Constraint mScrollMainInternalOvershootXConstraint; - Constraint mScrollMainInternalOvershootYConstraint; - Constraint mScrollMainInternalDeltaConstraint; - Constraint mScrollMainInternalFinalConstraint; - Constraint mScrollMainInternalRelativeConstraint; - Constraint mScrollMainInternalDomainConstraint; - Constraint mScrollMainInternalPrePositionMaxConstraint; + Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received. - ScrollOvershootIndicatorPtr mOvershootIndicator; + ScrollOvershootIndicatorPtr mOvershootIndicator; WeakHandle mScrollBar; Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal; - bool mInAccessibilityPan:1; ///< With AccessibilityPan its easier to move between snap positions - bool mScrolling:1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation) - bool mScrollInterrupted:1; ///< Flag set for when a down event interrupts a scroll - bool mPanning:1; ///< Whether scroll view is currently panning or not - bool mSensitive:1; ///< Scroll Sensitivity Flag. - bool mTouchDownTimeoutReached:1; ///< Indicates when down event timeout occured without corresponding up event (touch still down) - bool mActorAutoSnapEnabled:1; ///< Whether to automatically snap to closest actor. - bool mAutoResizeContainerEnabled:1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes) - bool mWrapMode:1; ///< Whether to wrap contents based on container size. - bool mAxisAutoLock:1; ///< Whether to automatically lock axis when panning. - bool mAlterChild:1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors. - bool mDefaultMaxOvershoot:1; ///< Whether to use default max overshoot or application defined one - bool mCanScrollHorizontal:1; ///< Local value of our property to check against - bool mCanScrollVertical:1; ///< Local value of our property to check against - bool mTransientScrollBar:1; ///< True if scroll-bar should be automatically show/hidden during/after panning + bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions + bool mScrolling : 1; ///< Flag indicating whether the scroll view is being scrolled (by user or animation) + bool mScrollInterrupted : 1; ///< Flag set for when a down event interrupts a scroll + bool mPanning : 1; ///< Whether scroll view is currently panning or not + bool mSensitive : 1; ///< Scroll Sensitivity Flag. + bool mTouchDownTimeoutReached : 1; ///< Indicates when down event timeout occured without corresponding up event (touch still down) + bool mActorAutoSnapEnabled : 1; ///< Whether to automatically snap to closest actor. + bool mAutoResizeContainerEnabled : 1; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes) + bool mWrapMode : 1; ///< Whether to wrap contents based on container size. + bool mAxisAutoLock : 1; ///< Whether to automatically lock axis when panning. + bool mAlterChild : 1; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors. + bool mDefaultMaxOvershoot : 1; ///< Whether to use default max overshoot or application defined one + bool mCanScrollHorizontal : 1; ///< Local value of our property to check against + bool mCanScrollVertical : 1; ///< Local value of our property to check against + bool mTransientScrollBar : 1; ///< True if scroll-bar should be automatically show/hidden during/after panning + + friend ScrollViewConstraints; + friend ScrollViewPropertyHandler; }; +/** + * Returns whether to lock scrolling to a particular axis + * + * @param[in] panDelta Distance panned since gesture started + * @param[in] currentLockAxis The current lock axis value + * @param[in] lockGradient How quickly to lock to a particular axis + * + * @return The new axis lock state + */ +ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis currentLockAxis, float lockGradient); + } // namespace Internal // Helpers for public-api forwarding methods @@ -993,4 +1034,4 @@ inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& s } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__ +#endif // DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H