application.Render(0);
DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
- // Animate again, but don't bake this time
+ // Test BakeFinal, animate again, for half the duration
+ finishCheck.Reset();
+ animation.SetEndAction(Animation::BakeFinal);
+ DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
+
+ // Stop the animation early
+ animation.Stop();
+
+ // We did NOT expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
+
+ // Go back to the start
+ actor.SetPosition(Vector3::ZERO);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
+
+ // Test EndAction::Discard, animate again, but don't bake this time
finishCheck.Reset();
animation.SetEndAction(Animation::Discard);
DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
animation.SetEndAction(Animation::Discard);
DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
+
+ animation.SetEndAction(Animation::BakeFinal);
+ DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
+
END_TEST;
}
animation.SetDestroyAction(Animation::Discard);
DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard);
+ animation.SetDestroyAction(Animation::BakeFinal);
+ DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::BakeFinal);
+
END_TEST;
}
typedef boost::function<Quaternion (float alpha, const Quaternion& current)> QuaternionAnimatorFunc; ///< Interpolation function
/**
- * @brief What to do when the animation ends.
+ * @brief What to do when the animation ends, is stopped or is destroyed
*/
enum EndAction
{
- Bake, ///< When the animation ends, the animated property values are saved.
- Discard ///< When the animation ends, the animated property values are forgotten.
+ Bake, ///< When the animation ends, the animated property values are saved.
+ Discard, ///< When the animation ends, the animated property values are forgotten.
+ BakeFinal ///< If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like Bake.
};
//Signal Names
{
animationFinished = true; // The actor-thread should be notified of this
- if (mEndAction == Dali::Animation::Bake)
+ if( mEndAction != Dali::Animation::Discard )
{
+ if( mEndAction == Dali::Animation::BakeFinal )
+ {
+ mElapsedSeconds = mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end
+ }
UpdateAnimators(bufferIndex, true/*bake the final result*/);
}
{
if (mState == Playing || mState == Paused)
{
- if (mDestroyAction == Dali::Animation::Bake)
+ if (mDestroyAction != Dali::Animation::Discard)
{
UpdateAnimators(bufferIndex, true/*bake the final result*/);
}
const bool animationFinished(mState == Playing && mElapsedSeconds > mDurationSeconds);
- UpdateAnimators(bufferIndex, animationFinished && (mEndAction == Dali::Animation::Bake));
+ UpdateAnimators(bufferIndex, animationFinished && (mEndAction != Dali::Animation::Discard));
if (animationFinished)
{