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-wobble-effect-impl.cpp;h=b3428bd80f2edde4e850bbb3909b9811c8e4bae0;hp=e21ef87f93c820cb8f0a2520703d9f553a23772f;hb=0176f9fd57aa372525893f9c3fff01be3408f2bd;hpb=1db0a8becea3dbdebaa942d934d91824a92434e7 diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp index e21ef87..b3428bd 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp @@ -77,8 +77,8 @@ struct ScrollViewWobbleEffectConstraint * @param[in,out] wobbleEffect Reference to wobbleEffect instance */ ScrollViewWobbleEffectConstraint(ScrollViewWobbleEffect& wobbleEffect) - : mChase(Vector3::ZERO), - mVelocity(Vector3::ZERO), + : mChase(Vector2::ZERO), + mVelocity(Vector2::ZERO), mTime(0.0f), mStabilityTimeCounter(0), mStabilized(true), @@ -89,19 +89,14 @@ struct ScrollViewWobbleEffectConstraint } /** - * @param[out] current The new wobble value - * @param[in] propertyTime The current time since the wobble effect started - * @param[in] propertyPosition The scroll-position - * @param[in] propertyOffset The scroll-overshoot + * @param[in,out] direction The new wobble value + * @param[in] inputs Contains: + * The current time since the wobble effect started + * The scroll-position + * The scroll-overshoot x & y */ - Vector3 operator()(const Vector3& current, - const PropertyInput& propertyTime, - const PropertyInput& propertyPosition, - const PropertyInput& propertyOffsetX, - const PropertyInput& propertyOffsetY) + void operator()( Vector3& direction, const PropertyInputContainer& inputs ) { - Vector3 dir; - if(mStabilized) { // check if animation cycle id has changed (if so then this spells @@ -114,16 +109,16 @@ struct ScrollViewWobbleEffectConstraint else { // not stable (i.e. wobbling) - Vector3 offset(propertyOffsetX.GetFloat(), propertyOffsetY.GetFloat(), 0.0f); - const Vector3& position = propertyPosition.GetVector3() - offset; - const float time = propertyTime.GetFloat(); + Vector2 offset(inputs[2]->GetFloat(), inputs[3]->GetFloat()); + const Vector2& position = inputs[1]->GetVector2() - offset; + const float time = inputs[0]->GetFloat(); const float timePassed = time - mTime; mTime = time; if(timePassed>0) { - const Vector3 delta = position - mChase; + const Vector2 delta = position - mChase; // Check to see if wobble has stabilized. if( (fabsf(delta.x) < STABILITY_DELTA_THRESHOLD) && @@ -159,15 +154,13 @@ struct ScrollViewWobbleEffectConstraint } } - dir.x = propertyPosition.GetVector3().x - mChase.x; - dir.y = propertyPosition.GetVector3().y - mChase.y; + direction.x = position.x - mChase.x; + direction.y = position.y - mChase.y; } // end else - - return dir; } - Vector3 mChase; ///< Chaser position - Vector3 mVelocity; ///< Velocity of Chaser + Vector2 mChase; ///< Chaser position + Vector2 mVelocity; ///< Velocity of Chaser float mTime; ///< Current time. float mStabilityTimeCounter; ///< Time in seconds that stable for. bool mStabilized; ///< Stabilized flag. @@ -231,10 +224,6 @@ void ScrollViewWobbleEffect::OnDetach(Toolkit::ScrollView& scrollView) void ScrollViewWobbleEffect::AttachActor(Actor actor) { - Property::Index propertyPosition = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME); - Property::Index propertyOvershootX = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME); - Property::Index propertyOvershootY = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME); - // Create effect-overshoot property if not already created. Property::Index propertyEffectOvershoot = actor.GetPropertyIndex(Toolkit::ScrollViewWobbleEffect::EFFECT_OVERSHOOT); if(propertyEffectOvershoot == Property::INVALID_INDEX) @@ -244,13 +233,12 @@ void ScrollViewWobbleEffect::AttachActor(Actor actor) Actor scrollView = GetScrollView(); - Constraint constraint = Constraint::New( propertyEffectOvershoot, - Source(scrollView, mPropertyTime), - Source(actor, propertyPosition), - Source(actor, propertyOvershootX), - Source(actor, propertyOvershootY), - ScrollViewWobbleEffectConstraint(*this) ); - actor.ApplyConstraint(constraint); + Constraint constraint = Constraint::New( actor, propertyEffectOvershoot, ScrollViewWobbleEffectConstraint(*this) ); + constraint.AddSource( Source( scrollView, mPropertyTime ) ); + constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::SCROLL_POSITION ) ); + constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::OVERSHOOT_X ) ); + constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::OVERSHOOT_Y ) ); + constraint.Apply(); } void ScrollViewWobbleEffect::DetachActor(Actor actor) @@ -272,13 +260,13 @@ void ScrollViewWobbleEffect::ContinueAnimation(float endTime) Actor scrollView = GetScrollView(); mAnimation = Animation::New(WOBBLEEFFECT_ANIMATION_MAX_TIME); - mAnimation.AnimateTo( Property(scrollView, mPropertyTime), endTime, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property(scrollView, mPropertyTime), endTime, AlphaFunction::LINEAR ); mAnimation.FinishedSignal().Connect(this, &ScrollViewWobbleEffect::OnAnimationFinished); mAnimation.Play(); } -void ScrollViewWobbleEffect::OnScrollStart( const Vector3& position ) +void ScrollViewWobbleEffect::OnScrollStart( const Vector2& position ) { // When animation starts, all constraints all unstable, // and we change the animation cycle id. @@ -290,12 +278,12 @@ void ScrollViewWobbleEffect::OnScrollStart( const Vector3& position ) ContinueAnimation(WOBBLEEFFECT_ANIMATION_MAX_TIME); } -void ScrollViewWobbleEffect::OnScrollUpdate( const Vector3& position ) +void ScrollViewWobbleEffect::OnScrollUpdate( const Vector2& position ) { // nothing to do } -void ScrollViewWobbleEffect::OnScrollComplete( const Vector3& position ) +void ScrollViewWobbleEffect::OnScrollComplete( const Vector2& position ) { // nothing to do }