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.cpp;h=e60962f0b4bf4cc2e8b249d8487a103fe1840aa2;hp=578fd897f76801a8b23830337d0bc4f039c45006;hb=97b1d370bbe662d6f2b813252b281e77926aa037;hpb=a342499604e471b0e0d80eac30eb28e898b06c69 diff --git a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 578fd89..e60962f 100644 --- a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -15,15 +15,22 @@ * */ -// INTERNAL INCLUDES +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include #include +#include +#include +#include +// INTERNAL INCLUDES #include #include -#include #include #include -#include //#define ENABLED_SCROLL_STATE_LOGGING @@ -34,10 +41,8 @@ #endif // TODO: Change to two class system: -// 1. DraggableActor (is an actor which can be dragged anywhere/scaled/rotated, can be set to range using the ruler) +// 1. DraggableActor (is an actor which can be dragged anywhere, can be set to range using the ruler) // 2. ScrollView (contains a draggable actor that can a) be dragged in the negative X, and Y domain, b) has a hitArea for touches) -// TODO: Rotation -// TODO: Asymetrical scaling // TODO: external components (page and status overlays). // TODO: Orientation. // TODO: upgrade Vector2/3 to support returning Unit vectors, normals, & cross product (dot product is already provided) @@ -71,27 +76,6 @@ const Vector2 ANGLE_OUTER_CUBE_SWING(Math::PI * 0.5f, Math::PI * 0.5f); ///< ou // Helpers //////////////////////////////////////////////////////////////////////////////////////// -// TODO: GetAngle for Vector2 can be moved. -// GetAngle for Vector3 needs to be measured against a normal/plane. - -/** - * @param[in] vector The 3D vector to be measured - * @return angle in radians from 0 to 2PI - */ -float GetAngle(const Vector3& vector) -{ - return atan2(vector.y, vector.x) + Math::PI; -} - -/** - * @param[in] vector The 2D vector to be measured - * @return angle in radians from 0 to 2PI - */ -float GetAngle(const Vector2& vector) -{ - return atan2(vector.y, vector.x) + Math::PI; -} - /** * Find the vector (distance) from (a) to (b) * in domain (start) to (end) @@ -272,17 +256,18 @@ ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis c * Generates position property based on current position + gesture displacement. * Or generates position property based on positionX/Y. * Note: This is the position prior to any clamping at scroll boundaries. - * TODO: Scale & Rotation Transforms. */ struct InternalPrePositionConstraint { - InternalPrePositionConstraint(const Vector2& initialPanMask, + InternalPrePositionConstraint(const Vector2& initialPanPosition, + const Vector2& initialPanMask, bool axisAutoLock, float axisAutoLockGradient, ScrollView::LockAxis initialLockAxis, const Vector2& maxOvershoot, const RulerDomain& domainX, const RulerDomain& domainY) - : mInitialPanMask(initialPanMask), + : mLocalStart(initialPanPosition), + mInitialPanMask(initialPanMask), mDomainMin( -domainX.min, -domainY.min ), mDomainMax( -domainX.max, -domainY.max ), mMaxOvershoot(maxOvershoot), @@ -297,7 +282,6 @@ struct InternalPrePositionConstraint Vector3 operator()(const Vector3& current, const PropertyInput& gesturePositionProperty, - const PropertyInput& gestureDisplacementProperty, const PropertyInput& sizeProperty) { Vector3 scrollPostPosition = current; @@ -305,7 +289,6 @@ struct InternalPrePositionConstraint if(!mWasPanning) { - mLocalStart = gesturePositionProperty.GetVector2() - gestureDisplacementProperty.GetVector2(); mPrePosition = current; mCurrentPanMask = mInitialPanMask; mWasPanning = true; @@ -487,26 +470,6 @@ struct OvershootYConstraint }; /** - * When panning, this constraint updates the X property, otherwise - * it has no effect on the X property. - */ -float InternalXConstraint(const float& current, - const PropertyInput& scrollPosition) -{ - return scrollPosition.GetVector3().x; -} - -/** - * When panning, this constraint updates the Y property, otherwise - * it has no effect on the Y property. - */ -float InternalYConstraint(const float& current, - const PropertyInput& scrollPosition) -{ - return scrollPosition.GetVector3().y; -} - -/** * Internal Position-Delta Property Constraint. * * Generates position-delta property based on scroll-position + scroll-offset properties. @@ -591,10 +554,7 @@ ScrollView::ScrollView() : ScrollBase(), mTouchDownTime(0u), mGestureStackDepth(0), - mRotationDelta(0.0f), mScrollStateFlags(0), - mScrollPreRotation(0.0f), - mScrollPostRotation(0.0f), mMinTouchesForPanning(1), mMaxTouchesForPanning(1), mLockAxis(LockPossible), @@ -652,8 +612,6 @@ void ScrollView::OnInitialize() RegisterProperties(); mScrollPostPosition = mScrollPrePosition = Vector3::ZERO; - mScrollPostScale = mScrollPreScale = Vector3::ONE; - mScrollPostRotation = mScrollPreRotation = 0.0f; mMouseWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; @@ -669,13 +627,8 @@ void ScrollView::OnInitialize() // By default we'll allow the user to freely drag the scroll view, // while disabling the other rulers. RulerPtr ruler = new DefaultRuler(); - RulerPtr rulerDisabled = new DefaultRuler(); - rulerDisabled->Disable(); mRulerX = ruler; mRulerY = ruler; - mRulerScaleX = rulerDisabled; - mRulerScaleY = rulerDisabled; - mRulerRotation = rulerDisabled; EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator); @@ -776,84 +729,6 @@ void ScrollView::ApplyEffect(Toolkit::ScrollViewEffect effect) GetImpl(effect).Attach(self); } -Toolkit::ScrollViewEffect ScrollView::ApplyEffect(Toolkit::ScrollView::PageEffect effect) -{ - Toolkit::ScrollViewEffect scrollEffect; - switch(effect) - { - case Toolkit::ScrollView::PageEffectNone: - { - break; - } - case Toolkit::ScrollView::PageEffectOuterCube: - { - Toolkit::ScrollViewCustomEffect customEffect; - scrollEffect = customEffect = Toolkit::ScrollViewCustomEffect::New(); - Vector2 pageSize = Stage::GetCurrent().GetSize(); - // set the page translation to the slide off distance, also add an extra value to space the pages, having a smaller spacing on translationOut will allow the spacing to reduce over time - // the page moving onto screen will start 50.0f further out (1.0f * 50.0f) and the spacing will reduce as its position reaches the centre (0.0f * 50.0f) - // the page moving off screen will slowly build a spacing from 0.0f to 20.0f - // the spacing from each page is added together for the final spacing between the two pages. - customEffect.SetPageTranslation(Vector3(pageSize.x, pageSize.y, 0) + Vector3(50.0f, 50.0f, 0.0f), Vector3(pageSize.x, pageSize.y, 0) + Vector3(20.0f, 20.0f, 0.0f)); - customEffect.SetSwingAngleOut(ANGLE_CUSTOM_CUBE_SWING.x, Vector3(0.0f, -1.0f, 0.0f)); - customEffect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT); - customEffect.SetOpacityThreshold(0.7f); - break; - } - case Toolkit::ScrollView::PageEffectDepth: - { - Toolkit::ScrollViewCustomEffect customEffect; - scrollEffect = customEffect = Toolkit::ScrollViewCustomEffect::New(); - break; - } - case Toolkit::ScrollView::PageEffectInnerCube: - { - Toolkit::ScrollViewCustomEffect customEffect; - scrollEffect = customEffect = Toolkit::ScrollViewCustomEffect::New(); - customEffect.SetPageSpacing(Vector2(30.0f, 30.0f)); - customEffect.SetAngledOriginPageRotation(ANGLE_CUBE_PAGE_ROTATE); - customEffect.SetSwingAngle(ANGLE_CUBE_PAGE_ROTATE.x, Vector3(0,-1,0)); - customEffect.SetOpacityThreshold(0.5f); - break; - } - case Toolkit::ScrollView::PageEffectCarousel: - { - Toolkit::ScrollViewCustomEffect customEffect; - scrollEffect = customEffect = Toolkit::ScrollViewCustomEffect::New(); - customEffect.SetPageTranslation(Vector3(0,0,0), Vector3(-30, 0, 0)); - customEffect.SetPageSpacing(Vector2(60.0f, 60.0f)); - customEffect.SetAngledOriginPageRotation(-ANGLE_CUBE_PAGE_ROTATE); - customEffect.SetOpacityThreshold(0.2f, 0.6f); - break; - } - case Toolkit::ScrollView::PageEffectSpiral: - { - Toolkit::ScrollViewCustomEffect customEffect; - scrollEffect = customEffect = Toolkit::ScrollViewCustomEffect::New(); - - Vector2 pageSize = Stage::GetCurrent().GetSize(); - customEffect.SetSwingAngle(-ANGLE_SPIRAL_SWING_IN.x, Vector3(0.0f, -1.0f, 0.0f), ANGLE_SPIRAL_SWING_OUT.x, Vector3(0.0f, -1.0f, 0.0f)); - //customEffect.SetSwingAngleAlphaFunctionOut(AlphaFunctions::EaseOut); - customEffect.SetSwingAnchor(AnchorPoint::CENTER_RIGHT); - customEffect.SetPageTranslation(Vector3(pageSize.x, pageSize.y, 0) + Vector3(100.0f, 100.0f, 0.0f), Vector3(pageSize.x, pageSize.y, -pageSize.y * 2.0f) * 0.33f); - //customEffect.SetPageTranslateAlphaFunctionOut(AlphaFunctions::EaseOut); - customEffect.SetOpacityThreshold(0.75f, 0.6f); - customEffect.SetOpacityAlphaFunctionIn(AlphaFunctions::EaseInOut); - break; - } - default: - { - DALI_ASSERT_DEBUG(0 && "unknown scroll view effect"); - } - } - RemoveConstraintsFromChildren(); - if(scrollEffect) - { - ApplyEffect(scrollEffect); - } - return scrollEffect; -} - void ScrollView::RemoveEffect(Toolkit::ScrollViewEffect effect) { Dali::Toolkit::ScrollView self = Dali::Toolkit::ScrollView::DownCast(Self()); @@ -1004,7 +879,7 @@ void ScrollView::UpdatePropertyDomain(const Vector3& size) domainChanged = true; min.y = 0.0f; max.y = 0.0f; - canScrollHorizontal = false; + canScrollVertical = false; } // avoid setting properties if possible, otherwise this will cause an entire update as well as triggering constraints using each property we update @@ -1032,24 +907,6 @@ void ScrollView::UpdatePropertyDomain(const Vector3& size) } } -void ScrollView::SetRulerScaleX(RulerPtr ruler) -{ - mRulerScaleX = ruler; - UpdateMainInternalConstraint(); -} - -void ScrollView::SetRulerScaleY(RulerPtr ruler) -{ - mRulerScaleY = ruler; - UpdateMainInternalConstraint(); -} - -void ScrollView::SetRulerRotation(RulerPtr ruler) -{ - mRulerRotation = ruler; - UpdateMainInternalConstraint(); -} - void ScrollView::SetScrollSensitive(bool sensitive) { Actor self = Self(); @@ -1141,16 +998,6 @@ void ScrollView::SetWrapMode(bool enable) Self().SetProperty(mPropertyWrap, enable); } -int ScrollView::GetRefreshInterval() const -{ - return mScrollUpdateDistance; -} - -void ScrollView::SetRefreshInterval(int milliseconds) -{ - mScrollUpdateDistance = milliseconds; -} - int ScrollView::GetScrollUpdateDistance() const { return mScrollUpdateDistance; @@ -1273,12 +1120,6 @@ void ScrollView::SetScrollPosition(const Vector3& position) mScrollPrePosition = position; } -Vector3 ScrollView::GetCurrentScrollScale() const -{ - // in case animation is currently taking place. - return GetPropertyScale(); -} - Vector3 ScrollView::GetDomainSize() const { Vector3 size = Self().GetCurrentSize(); @@ -1290,13 +1131,13 @@ Vector3 ScrollView::GetDomainSize() const return domainSize; } -void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, +void ScrollView::TransformTo(const Vector3& position, DirectionBias horizontalBias, DirectionBias verticalBias) { - TransformTo(position, scale, rotation, mSnapDuration, horizontalBias, verticalBias); + TransformTo(position, mSnapDuration, mSnapAlphaFunction, horizontalBias, verticalBias); } -void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration, +void ScrollView::TransformTo(const Vector3& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias) { Actor self( Self() ); @@ -1305,8 +1146,8 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa // Note that Emit() methods are called indirectly e.g. from within ScrollView::AnimateTo() Toolkit::ScrollView handle( GetOwner() ); - DALI_LOG_SCROLL_STATE("[0x%X] pos[%.2f,%.2f], scale[%.2f,%.2f], rot[%.2f], duration[%.2f] bias[%d, %d]", - this, position.x, position.y, scale.x, scale.y, rotation, duration, int(horizontalBias), int(verticalBias)); + DALI_LOG_SCROLL_STATE("[0x%X] pos[%.2f,%.2f], duration[%.2f] bias[%d, %d]", + this, position.x, position.y, duration, int(horizontalBias), int(verticalBias)); Vector3 currentScrollPosition = GetCurrentScrollPosition(); self.SetProperty( mPropertyScrollStartPagePosition, currentScrollPosition ); @@ -1339,11 +1180,7 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa mScrollStartedSignalV2.Emit( currentScrollPosition ); bool animating = AnimateTo(-position, Vector3::ONE * duration, - scale, - Vector3::ONE * duration, - rotation, - duration, - mSnapAlphaFunction, + alpha, true, horizontalBias, verticalBias, @@ -1379,13 +1216,22 @@ void ScrollView::ScrollTo(const Vector3& position, float duration) ScrollTo(position, duration, DirectionBiasNone, DirectionBiasNone); } +void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha) +{ + ScrollTo(position, duration, alpha, DirectionBiasNone, DirectionBiasNone); +} + void ScrollView::ScrollTo(const Vector3& position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias) { - DALI_LOG_SCROLL_STATE("[0x%X] position[%.2f, %.2f] duration[%.2f]", - this, position.x, position.y, duration, int(horizontalBias), int(verticalBias)); + ScrollTo(position, duration, mSnapAlphaFunction, horizontalBias, verticalBias); +} - TransformTo(position, mScrollPostScale, mScrollPostRotation, duration, horizontalBias, verticalBias); +void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha, + DirectionBias horizontalBias, DirectionBias verticalBias) +{ + DALI_LOG_SCROLL_STATE("[0x%X] position[%.2f, %.2f] duration[%.2f]", this, position.x, position.y, duration, int(horizontalBias), int(verticalBias)); + TransformTo(position, duration, alpha, horizontalBias, verticalBias); } void ScrollView::ScrollTo(unsigned int page) @@ -1531,17 +1377,6 @@ bool ScrollView::ScrollToSnapPoint() return SnapWithVelocity( stationaryVelocity ); } -void ScrollView::ScaleTo(const Vector3& scale) -{ - ScaleTo(scale, mSnapDuration); -} - -void ScrollView::ScaleTo(const Vector3& scale, float duration) -{ - TransformTo(mScrollPostPosition, scale, mScrollPostRotation, duration); -} - - // TODO: In situations where axes are different (X snap, Y free) // Each axis should really have their own independent animation (time and equation) // Consider, X axis snapping to nearest grid point (EaseOut over fixed time) @@ -1558,8 +1393,6 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) float speed2 = velocity.LengthSquared(); AlphaFunction alphaFunction = mSnapAlphaFunction; Vector3 positionDuration = Vector3::ONE * mSnapDuration; - Vector3 scaleDuration = Vector3::ONE * mSnapDuration; - float rotationDuration = mSnapDuration; float biasX = 0.5f; float biasY = 0.5f; FindDirection horizontal = None; @@ -1749,21 +1582,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) } positionSnap += clampDelta; - // Scale Snap /////////////////////////////////////////////////////////////// - Vector3 scaleSnap = mScrollPostScale; - - scaleSnap.x = mRulerScaleX->Snap(scaleSnap.x); - scaleSnap.y = mRulerScaleY->Snap(scaleSnap.y); - - ClampScale(scaleSnap); - - // Rotation Snap //////////////////////////////////////////////////////////// - float rotationSnap = mScrollPostRotation; - // TODO: implement rotation snap - bool animating = AnimateTo(positionSnap, positionDuration, - scaleSnap, scaleDuration, - rotationSnap, rotationDuration, alphaFunction, false, DirectionBiasNone, DirectionBiasNone, isFlick || isFreeFlick ? Flick : Snap); @@ -1774,7 +1593,6 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) void ScrollView::StopAnimation(void) { // Clear Snap animation if exists. - StopAnimation(mSnapAnimation); StopAnimation(mInternalXAnimation); StopAnimation(mInternalYAnimation); mScrollStateFlags = 0; @@ -1792,8 +1610,6 @@ void ScrollView::StopAnimation(Animation& animation) } bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDuration, - const Vector3& scale, const Vector3& scaleDuration, - float rotation, float rotationDuration, AlphaFunction alpha, bool findShortcuts, DirectionBias horizontalBias, DirectionBias verticalBias, SnapType snapType) @@ -1805,8 +1621,6 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat float totalDuration = 0.0f; bool positionChanged = (mScrollTargetPosition != mScrollPostPosition); - bool scaleChanged = (scale != mScrollPostScale); - bool rotationChanged = fabsf(rotation - mScrollPostRotation) > Math::MACHINE_EPSILON_0; if(positionChanged) { @@ -1820,16 +1634,6 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat positionChanged = true; } - if(scaleChanged) - { - totalDuration = std::max(totalDuration, scaleDuration.x); - totalDuration = std::max(totalDuration, scaleDuration.y); - } - - if(rotationChanged) - { - totalDuration = std::max(totalDuration, rotationDuration); - } StopAnimation(); // Position Delta /////////////////////////////////////////////////////// @@ -1872,35 +1676,12 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat DALI_LOG_SCROLL_STATE("[0x%X] mPropertyPrePosition[%.2f, %.2f], mPropertyPosition[%.2f, %.2f]", this, self.GetProperty( mPropertyPrePosition ).Get().x, self.GetProperty( mPropertyPrePosition ).Get().y, self.GetProperty( mPropertyPosition ).Get().x, self.GetProperty( mPropertyPosition ).Get().y ); } - // Scale Delta /////////////////////////////////////////////////////// - if(scaleChanged) - { - if(totalDuration > Math::MACHINE_EPSILON_1) - { - mSnapAnimation = Animation::New(totalDuration); - mSnapAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished); - // TODO: for non-uniform scaling to different bounds e.g. scaling a square to a 4:3 aspect ratio screen with a velocity - // the height will hit first, and then the width, so that would require two different animation times just like position. - mSnapAnimation.AnimateTo( Property(self, mPropertyScale), scale, alpha, TimePeriod(0.0f, scaleDuration.x)); - - mSnapAnimation.AnimateTo( Property(self, mPropertyTime), totalDuration, AlphaFunctions::Linear ); - mSnapAnimation.Play(); - } - else - { - self.SetProperty(mPropertyScale, scale); - - mScrollPreScale = mScrollPostScale = scale; - } - } SetScrollUpdateNotification(true); // Always send a snap event when AnimateTo is called. Toolkit::ScrollView::SnapEvent snapEvent; snapEvent.type = snapType; snapEvent.position = -mScrollTargetPosition; - snapEvent.scale = scale; - snapEvent.rotation = rotation; snapEvent.duration = totalDuration; DALI_LOG_SCROLL_STATE("[0x%X] mSnapStartedSignalV2 [%.2f, %.2f]", this, snapEvent.position.x, snapEvent.position.y); @@ -1987,11 +1768,6 @@ Vector3 ScrollView::GetPropertyPosition() const return position; } -Vector3 ScrollView::GetPropertyScale() const -{ - return Self().GetProperty(mPropertyScale); -} - void ScrollView::HandleStoppedAnimation() { SetScrollUpdateNotification(false); @@ -2121,21 +1897,7 @@ void ScrollView::OnChildRemove(Actor& child) void ScrollView::OnPropertySet( Property::Index index, Property::Value propertyValue ) { Actor self = Self(); - if( index == mPropertyX ) - { - self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition); - propertyValue.Get(mScrollPrePosition.x); - DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y ); - self.SetProperty(mPropertyPrePosition, mScrollPrePosition); - } - else if( index == mPropertyY ) - { - self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition); - propertyValue.Get(mScrollPrePosition.y); - DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y ); - self.SetProperty(mPropertyPrePosition, mScrollPrePosition); - } - else if( index == mPropertyPrePosition ) + if( index == mPropertyPrePosition ) { DALI_LOG_SCROLL_STATE("[0x%X]: mPropertyPrePosition[%.2f, %.2f]", this, propertyValue.Get().x, propertyValue.Get().y); propertyValue.Get(mScrollPrePosition); @@ -2351,13 +2113,7 @@ void ScrollView::PreAnimatedScrollSetup() mScrollStateFlags = 0; - mScrollPostScale = GetPropertyScale(); - // Update Actor position with this wrapped value. - // TODO Rotation - - mScrollPreScale = mScrollPostScale; - mScrollPreRotation = mScrollPostRotation; } void ScrollView::FinaliseAnimatedScroll() @@ -2418,14 +2174,6 @@ void ScrollView::OnScrollAnimationFinished( Animation& source ) // update our local scroll positions UpdateLocalScrollProperties(); - if( source == mSnapAnimation ) - { - DALI_LOG_SCROLL_STATE("[0x%X] mSnapAnimation[0x%X]", this, mSnapAnimation.GetObjectPtr() ); - - // generic snap animation used for scaling and rotation - mSnapAnimation.Reset(); - } - if( source == mInternalXAnimation ) { DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(mPropertyPrePosition).Get().x, mScrollPostPosition.x ); @@ -2560,8 +2308,6 @@ void ScrollView::GestureStarted() StopTouchDownTimer(); StopAnimation(); mPanDelta = Vector3::ZERO; - mScaleDelta = Vector3::ONE; - mRotationDelta = 0.0f; mLastVelocity = Vector2(0.0f, 0.0f); if( !mScrolling ) { @@ -2590,13 +2336,10 @@ void ScrollView::GestureStarted() } } -void ScrollView::GestureContinuing(const Vector2& panDelta, const Vector2& scaleDelta, float rotationDelta) +void ScrollView::GestureContinuing(const Vector2& panDelta) { mPanDelta.x+= panDelta.x; mPanDelta.y+= panDelta.y; - mScaleDelta.x*= scaleDelta.x; - mScaleDelta.y*= scaleDelta.y; - mRotationDelta+= rotationDelta; // Save the velocity, there is a bug in PanGesture // Whereby the Gesture::Finished's velocity is either: @@ -2612,11 +2355,9 @@ void ScrollView::GestureContinuing(const Vector2& panDelta, const Vector2& scale } // TODO: Upgrade to use a more powerful gesture detector (one that supports multiple touches on pan - so works as pan and flick gesture) -// TODO: Reimplement Scaling (pinching 2+ points) -// TODO: Reimplment Rotation (pinching 2+ points) // BUG: Gesture::Finished doesn't always return velocity on release (due to // timeDelta between last two events being 0 sometimes, or posiiton being the same) -void ScrollView::OnPan(PanGesture gesture) +void ScrollView::OnPan( const PanGesture& gesture ) { // Guard against destruction during signal emission // Note that Emit() methods are called indirectly e.g. from within ScrollView::OnGestureEx() @@ -2637,6 +2378,7 @@ void ScrollView::OnPan(PanGesture gesture) case Gesture::Started: { DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this); + mPanStartPosition = gesture.position - gesture.displacement; UpdateLocalScrollProperties(); GestureStarted(); mPanning = true; @@ -2652,7 +2394,7 @@ void ScrollView::OnPan(PanGesture gesture) if ( mPanning ) { DALI_LOG_SCROLL_STATE("[0x%X] Pan Continuing", this); - GestureContinuing(gesture.screenDisplacement, Vector2::ZERO, 0.0f); + GestureContinuing(gesture.screenDisplacement); } else { @@ -2742,11 +2484,6 @@ void ScrollView::OnGestureEx(Gesture::State state) } } -void ScrollView::UpdateTransform() -{ -// TODO: notify clamps using property notifications (or see if we need this, can deprecate it) -} - void ScrollView::FinishTransform() { // at this stage internal x and x scroll position should have followed prescroll position exactly @@ -2837,18 +2574,6 @@ void ScrollView::ClampPosition(Vector3& position, ClampState3 &clamped) const { Vector3 size = Self().GetCurrentSize(); - // determine size of viewport relative to current scaled size. - // e.g. if you're zoomed in 200%, then each pixel on screen is only 0.5 pixels on subject. - if(fabsf(mScrollPostScale.x) > Math::MACHINE_EPSILON_0) - { - size.x /= mScrollPostScale.x; - } - - if(fabsf(mScrollPostScale.y) > Math::MACHINE_EPSILON_0) - { - size.y /= mScrollPostScale.y; - } - position.x = -mRulerX->Clamp(-position.x, size.width, 1.0f, clamped.x); // NOTE: X & Y rulers think in -ve coordinate system. position.y = -mRulerY->Clamp(-position.y, size.height, 1.0f, clamped.y); // That is scrolling RIGHT (e.g. 100.0, 0.0) means moving LEFT. @@ -2874,19 +2599,6 @@ void ScrollView::WrapPosition(Vector3& position) const } } -void ScrollView::ClampScale(Vector3& scale) const -{ - ClampState3 clamped; - ClampScale(scale, clamped); -} - -void ScrollView::ClampScale(Vector3& scale, ClampState3 &clamped) const -{ - scale.x = mRulerScaleX->Clamp(scale.x, 0.0f, 1.0f, clamped.x); - scale.y = mRulerScaleY->Clamp(scale.y, 0.0f, 1.0f, clamped.y); - clamped.z = NotClamped; -} - void ScrollView::UpdateMainInternalConstraint() { // TODO: Only update the constraints which have changed, rather than remove all and add all again. @@ -2900,8 +2612,6 @@ void ScrollView::UpdateMainInternalConstraint() self.RemoveConstraint(mScrollMainInternalDeltaConstraint); self.RemoveConstraint(mScrollMainInternalFinalConstraint); self.RemoveConstraint(mScrollMainInternalRelativeConstraint); - self.RemoveConstraint(mScrollMainInternalXConstraint); - self.RemoveConstraint(mScrollMainInternalYConstraint); } if( mScrollMainInternalPrePositionConstraint ) { @@ -2928,9 +2638,8 @@ void ScrollView::UpdateMainInternalConstraint() { constraint = Constraint::New( mPropertyPrePosition, Source( detector, PanGestureDetector::LOCAL_POSITION ), - Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ), Source( self, Actor::SIZE ), - InternalPrePositionConstraint( initialPanMask, mAxisAutoLock, mAxisAutoLockGradient, mLockAxis, mMaxOvershoot, mRulerX->GetDomain(), mRulerY->GetDomain() ) ); + InternalPrePositionConstraint( mPanStartPosition, initialPanMask, mAxisAutoLock, mAxisAutoLockGradient, mLockAxis, mMaxOvershoot, mRulerX->GetDomain(), mRulerY->GetDomain() ) ); mScrollMainInternalPrePositionConstraint = self.ApplyConstraint( constraint ); } @@ -2966,16 +2675,6 @@ void ScrollView::UpdateMainInternalConstraint() InternalRelativePositionConstraint ); mScrollMainInternalRelativeConstraint = self.ApplyConstraint( constraint ); - constraint = Constraint::New( mPropertyX, - LocalSource( mPropertyPrePosition ), - InternalXConstraint ); - mScrollMainInternalXConstraint = self.ApplyConstraint( constraint ); - - constraint = Constraint::New( mPropertyY, - LocalSource( mPropertyPrePosition ), - InternalYConstraint ); - mScrollMainInternalYConstraint = self.ApplyConstraint( constraint ); - // When panning we want to make sure overshoot values are affected by pre position and post position SetOvershootConstraintsEnabled(!mWrapMode); } @@ -3022,26 +2721,15 @@ void ScrollView::SetInternalConstraints() // User definable constraints to apply to all child actors ////////////////// Actor self = Self(); - // LocalSource - The Actors to be moved. - // self - The ScrollView - - // Apply some default constraints to ScrollView. - // Movement + Scaling + Wrap function + // Apply some default constraints to ScrollView & its bound actors + // Movement + Wrap function Constraint constraint; - // MoveScaledActor (scrolling/zooming) + // MoveActor (scrolling) constraint = Constraint::New( Actor::POSITION, Source( self, mPropertyPosition ), - Source( self, mPropertyScale ), - MoveScaledActorConstraint ); - constraint.SetRemoveAction(Constraint::Discard); - ApplyConstraintToBoundActors(constraint); - - // ScaleActor (scrolling/zooming) - constraint = Constraint::New( Actor::SCALE, - Source( self, mPropertyScale ), - ScaleActorConstraint ); + MoveActorConstraint ); constraint.SetRemoveAction(Constraint::Discard); ApplyConstraintToBoundActors(constraint);