X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.h;h=20215a43d99d29bdc66b1932f8c637582f65129c;hp=89c4c485460af6c0112c7f586b2bc21f39e0d1e5;hb=a342499604e471b0e0d80eac30eb28e898b06c69;hpb=d5e3ed5f5b1c8fdba3ae97ead8729620f54b3836 diff --git a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h index 89c4c48..20215a4 100644 --- a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h +++ b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h @@ -78,6 +78,19 @@ public: LockNone ///< Locking is set to none (free panning). }; + enum ScrollStateFlag + { + AnimatingInternalX = 0x01, ///< animating mPropertyX due to externally requested ScrollTo or internal snapping operation + AnimatingInternalY = 0x02, ///< animating mPropertyY due to externally requested ScrollTo or internal snapping operation + SnappingInternalX = 0x04, ///< snapping mPropertyX back to mPropertyPreScroll x value to remove x overshoot over time + 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_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY; + static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY; + public: /** @@ -253,16 +266,28 @@ public: void SetWrapMode(bool enable); /** + * @deprecated * @copydoc Toolkit::ScrollView::GetRefreshInterval */ int GetRefreshInterval() const; /** + * @deprecated * @copydoc Toolkit::ScrollView::SetRefreshInterval */ void SetRefreshInterval(int milliseconds); /** + * @copydoc Toolkit::ScrollView::GetScrollupdateDistance + */ + int GetScrollUpdateDistance() const; + + /** + * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance + */ + void SetScrollUpdateDistance(int distance); + + /** * @copydoc Toolkit::ScrollView::GetAxisAutoLock */ bool GetAxisAutoLock() const; @@ -303,6 +328,26 @@ public: void SetFlickSpeedCoefficient(float speed); /** + * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick + */ + Vector2 GetMinimumDistanceForFlick() const; + + /** + * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick + */ + void SetMinimumDistanceForFlick( const Vector2& distance ); + + /** + * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick + */ + float GetMinimumSpeedForFlick() const; + + /** + * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick + */ + void SetMinimumSpeedForFlick( float speed ); + + /** * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed */ float GetMaxFlickSpeed() const; @@ -333,6 +378,11 @@ public: Vector3 GetCurrentScrollPosition() const; /** + * @copydoc Toolkit::ScrollView::SetScrollPosition + */ + void SetScrollPosition(const Vector3& position); + + /** * @copydoc Toolkit::ScrollView::GetCurrentScrollScale */ Vector3 GetCurrentScrollScale() const; @@ -439,6 +489,13 @@ public: void StopAnimation(void); /** + * Stops the input animation + * + * @param[in] the animation to stop + */ + void StopAnimation(Animation& animation); + + /** * Animates to position/scale/rotation transform. * * @param[in] position The position to animate to @@ -470,6 +527,11 @@ public: */ void RemoveOverlay(Actor actor); + /** + * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor + */ + void SetOvershootEffectColor( const Vector4& color ); + public: //Signals /** @@ -513,6 +575,11 @@ private: // private overriden functions from CustomActorImpl and Controls virtual void OnChildRemove(Actor& child); /** + * @copydoc Dali::CustomActorImpl::OnPropertySet( Property::Index index, Property::Value propertyValue ) + */ + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ); + + /** * From CustomActorImpl; called after a touch-signal is received by the owning actor. * * We don't listen to these events as content within the contain may consume events. @@ -574,20 +641,70 @@ private: /** * Called whenever a snap animation has completed * @param[in] source the Animation instance that has completed. + * Resets all scrolling animations and states, leaving current scroll position at mPropertyPosition + */ + void ResetScrolling(); + + /** + * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts */ - void OnSnapAnimationFinished( Animation& source ); + void UpdateLocalScrollProperties(); + + /** + * Makes sure scroll values are ready for animated scrolling + */ + void PreAnimatedScrollSetup(); + + /** + * Finish an animated scroll, ensuring all scroll properties are updated + * and synchronised + */ + void FinaliseAnimatedScroll(); + + /** + * Animates the internal x property to the given value + * + * @param[in] position The X position to animate to + * @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 ); + + /** + * Animates the internal y property to the given value + * + * @param[in] position The Y position to animate to + * @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 ); /** * Called whenever a snap animation on the x-axis has completed * @param[in] source the Animation instance that has completed. */ - void OnSnapXAnimationFinished( Animation& source ); + void OnScrollAnimationFinished( Animation& source ); /** - * Called whenever a snap animation on the y-axis has completed + * Called when either the X or Y internal scroll positions have finished snapping back to mPropertyPrePosition + * * @param[in] source the Animation instance that has completed. */ - void OnSnapYAnimationFinished( 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 ); + + /** + * 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 @@ -610,7 +727,7 @@ private: * @param[in] scaleDelta average scale delta from base scale (1) * @param[in] rotationDelta average rotation delta from base angle (0) */ - void GestureContinuing(Vector2 panDelta, Vector2 scaleDelta, float rotationDelta); + void GestureContinuing(const Vector2& panDelta, const Vector2& scaleDelta, float rotationDelta); /** * Called upon pan gesture event. @@ -647,22 +764,6 @@ private: void FinishTransform(); /** - * Sets Overshoot to origin / cancels animation - */ - void SetOvershootToOrigin(); - - /** - * Animates Overshoot to origin - */ - void AnimateOvershootToOrigin(float xDelay, float yDelay); - - /** - * Called whenever a snap overshoot animation has completed. - * @param[in] source the Animation instance that has completed. - */ - void OnSnapOvershootAnimationFinished( Animation& source ); - - /** * Returns overshoot vector based on current position * * Overshoot vector is defined as how far outside of bounds @@ -793,20 +894,15 @@ private: void HandleSnapAnimationFinished(); /** - * Helper to start the refresh timer. - */ - void StartRefreshTimer(); - - /** - * Helper to cancel the refresh timer. + * Checks if the property notifications are active and adds them if not */ - void CancelRefreshTimer(); + void SetScrollUpdateNotification( bool enabled ); /** * Refresh the ScrollView (used when animating to update application developer of changes) * @return True if the refresh timer should be kept running. */ - bool OnRefreshTick(); + void OnScrollUpdateNotification(Dali::PropertyNotification& source); private: @@ -818,25 +914,19 @@ private: private: - bool mInitialized; - bool mScrolling; ///< Flag indicating whether the scroll view is being scrolled (by user or animation) - bool mScrollInterrupted; ///< Flag set for when a down event interrupts a scroll unsigned long mTouchDownTime; ///< The touch down time - bool mSensitive; ///< Scroll Sensitivity Flag. - int mGestureStackDepth; ///< How many gestures are currently occuring. - Vector2 mGestureReferencePosition; ///< Point where scaling should occur from. - Vector2 mPinchGestureLastPosition; - Vector2 mPinchGestureLastScale; Vector3 mPanDelta; ///< Amount currently panned. Vector3 mScaleDelta; ///< Amount currently scaled. float mRotationDelta; ///< Amount currently rotated. + unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling // Scroll delegate pre and post position/scale/rotation properties... - Vector3 mScrollPrePosition; ///< Scroll delegate pre-position - Vector3 mScrollPostPosition; ///< Scroll delegate post-position (affected by current touch) + Vector3 mScrollPrePosition; ///< Wrapped scroll position, but not clamped + Vector3 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used + Vector3 mScrollTargetPosition; ///< Final target position for an animated scroll Vector3 mScrollPreScale; ///< Scroll delegate pre-scale Vector3 mScrollPostScale; ///< Scroll delegate post-scale (affected by current touch) float mScrollPreRotation; ///< Scroll delegate pre-rotation @@ -849,42 +939,43 @@ private: RulerPtr mRulerScaleX; RulerPtr mRulerScaleY; RulerPtr mRulerRotation; - bool mTouchDownTimeoutReached; - bool mActorAutoSnapEnabled; ///< Whether to automatically snap to closest actor. - bool mAutoResizeContainerEnabled; ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes) - bool mWrapMode; ///< Whether to wrap contents based on container size. - bool mAxisAutoLock; ///< Whether to automatically lock axis when panning. + + // Last property values set to ScrollView + Vector3 mMinScroll; + Vector3 mMaxScroll; + unsigned int mMinTouchesForPanning; ///< Minimum number of touches for panning to be used. unsigned int mMaxTouchesForPanning; ///< Maximum number of touches for panning to be used. - Animation mSnapAnimation; - Animation mSnapXAnimation; ///< Animates from current x-axis position to the snapped (or scrolled) x-axis position. - Animation mSnapYAnimation; ///< Animates from current y-axis position to the snapped (or scrolled) y-axis position. - Animation mSnapOvershootAnimation; ///< Animates scroll-overshoot from current position to 0,0 based on specified easing equation. + Animation mSnapAnimation; ///< Used to animate rotation and scaling of scroll properties + 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) LockAxis mLockAxis; Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouchEvent without breaking fast flick behavior. - Timer mOvershootRefreshTimer; - Timer mRefreshTimer; ///< Refresh timer is used to provide the Application developer with updates as animations run. - int mRefreshIntervalMilliseconds; ///< Refresh timer interval. - bool mAlterChild; ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors. + 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. float mOvershootDelay; ///< Time to wait for input before reducing overshoot back to 0 Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f - bool mDefaultMaxOvershoot; ///< Whether to use default max overshoot or application defined one + Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector3::ZERO AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot. float mSnapDuration; ///< Time for the snap animation to take (in seconds). AlphaFunction mSnapAlphaFunction; ///< AlphaFunction to be used for the Snap Animation. + 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. @@ -910,7 +1001,21 @@ private: Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2; - bool mInAccessibilityPan : 1; // With AccessibilityPan its easier to move between snap positions + bool mInAccessibilityPan : 1; ///< With AccessibilityPan its easier to move between snap positions + bool mInitialized:1; + 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 }; } // namespace Internal