(Animation) Ensure AnimateBy updates the cached event-side properties 23/130223/8
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 19 May 2017 10:30:29 +0000 (11:30 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 26 May 2017 11:25:10 +0000 (12:25 +0100)
Change-Id: If7c50137a729f6072f39c8768a127326ca56d389

16 files changed:
automated-tests/src/dali/utc-Dali-Animation.cpp
automated-tests/src/dali/utc-Dali-RenderTask.cpp
automated-tests/src/dali/utc-Dali-TypeRegistry.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animation-impl.h
dali/internal/event/animation/animator-connector-base.h
dali/internal/event/common/object-impl.cpp
dali/internal/event/common/object-impl.h
dali/internal/event/common/property-helper.h
dali/internal/event/common/property-metadata.cpp
dali/internal/event/common/property-metadata.h
dali/internal/event/render-tasks/render-task-impl.cpp
dali/internal/event/render-tasks/render-task-impl.h
dali/public-api/animation/animation.cpp

index 2ef1975..e91881e 100644 (file)
@@ -2805,6 +2805,9 @@ int UtcDaliAnimationAnimateByBooleanP(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -3098,6 +3101,9 @@ int UtcDaliAnimationAnimateByFloatP(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -3332,6 +3338,9 @@ int UtcDaliAnimationAnimateByIntegerP(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -3541,6 +3550,44 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
   END_TEST;
 }
 
+int UtcDaliAnimationAnimateByQuaternionP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  // Register a quaternion property
+  const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
+  Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
+
+  // Build the animation
+  float durationSeconds(2.0f);
+  Animation animation = Animation::New(durationSeconds);
+  const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
+  const Quaternion finalValue( startValue * relativeValue );
+  animation.AnimateBy(Property(actor, index), relativeValue);
+
+  DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
+
+  application.SendNotification();
+  application.Render( 2000 ); // animation complete
+
+  DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
+
+  END_TEST;
+}
+
 int UtcDaliAnimationAnimateByVector2P(void)
 {
   TestApplication application;
@@ -3566,6 +3613,9 @@ int UtcDaliAnimationAnimateByVector2P(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -3801,6 +3851,9 @@ int UtcDaliAnimationAnimateByVector3P(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -4037,6 +4090,9 @@ int UtcDaliAnimationAnimateByVector4P(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -4273,6 +4329,9 @@ int UtcDaliAnimationAnimateByActorPositionP(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -4301,6 +4360,45 @@ int UtcDaliAnimationAnimateByActorPositionP(void)
   END_TEST;
 }
 
+int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector3 targetPosition(200.0f, 300.0f, 400.0f);
+  Vector3 relativePosition(targetPosition - Vector3::ZERO);
+  animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
+  animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
+  animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
+
+  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
 {
   TestApplication application;
@@ -4488,6 +4586,9 @@ int UtcDaliAnimationAnimateByActorOrientationP1(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -4790,6 +4891,9 @@ int UtcDaliAnimationAnimateByActorScaleP(void)
   // Start the animation
   animation.Play();
 
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
@@ -4879,6 +4983,239 @@ int UtcDaliAnimationAnimateByActorScaleP(void)
   END_TEST;
 }
 
+int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector3 targetScale(2.0f, 3.0f, 4.0f);
+  Vector3 relativeScale(targetScale - Vector3::ONE);
+  animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
+  animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
+  animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
+
+  DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliAnimationAnimateByActorColorP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
+  Vector4 relativeColor( targetColor - Color::WHITE );
+  animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliAnimationAnimateByActorColorComponentsP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
+  Vector4 relativeColor( targetColor - Color::WHITE );
+  animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
+  animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
+  animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
+  animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliAnimationAnimateByActorSizeP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector3 targetSize( 100.0f, 200.0f, 300.0f );
+  Vector3 relativeSize( targetSize - Vector3::ZERO );
+  animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  Vector3 targetSize( 100.0f, 200.0f, 300.0f );
+  Vector3 relativeSize( targetSize - Vector3::ZERO );
+  animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
+  animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
+  animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliAnimationAnimateByActorVisibilityP(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+  DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
+
+  actor.SetVisible( false );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  bool targetVisibility( true );
+  bool relativeVisibility( targetVisibility );
+  animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
+
+  DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+
+  // Target value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet
+
+  application.SendNotification();
+  application.Render( 1000 ); // 1 second progress
+
+  DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliAnimationAnimateToBooleanP(void)
 {
   TestApplication application;
index 20b9728..b747b8c 100644 (file)
@@ -1438,6 +1438,23 @@ int UtcDaliRenderTaskSetViewportPosition(void)
   DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+  // Create another animation which animates by a certain value
+  const Vector2 newPosition4( 75.0f, 45.0f );
+  const Vector2 relativePosition( newPosition4 - newPosition3 );
+  animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_POSITION ), relativePosition );
+  animation.Play();
+
+  DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, TEST_LOCATION );
+
+  // Perform 1000ms worth of updates at which point animation should have completed.
+  Wait(application, 1000);
+  DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -1496,6 +1513,22 @@ int UtcDaliRenderTaskSetViewportSize(void)
   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE  ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
 
+  // Create another animation which animates by a certain value
+  const Vector2 newSize4( 75.0f, 45.0f );
+  const Vector2 relativeSize( newSize4 - newSize3 );
+  animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_SIZE ), relativeSize );
+  animation.Play();
+
+  DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, TEST_LOCATION );
+
+  // Perform 1000ms worth of updates at which point animation should have completed.
+  Wait(application, 1000);
+  DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -1544,6 +1577,21 @@ int UtcDaliRenderTaskSetClearColorP(void)
   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR  ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
 
+  // Create another animation which animates by a certain value
+  const Vector4 newColor4( 0.45f, 0.35f, 0.25f, 0.1f );
+  const Vector4 relativeColor( newColor4 - newColor3 );
+  animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( task, RenderTask::Property::CLEAR_COLOR ), relativeColor );
+  animation.Play();
+
+  DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION );
+
+  // Perform 1000ms worth of updates at which point animation should have completed.
+  Wait(application, 1000);
+  DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
+  DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
+
   END_TEST;
 }
 
index b2231d2..42b24c2 100644 (file)
@@ -1432,6 +1432,183 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
   END_TEST;
 }
 
+int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
+{
+  TestApplication application;
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+  DALI_TEST_CHECK( typeInfo );
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+  Actor customActor = Actor::DownCast( handle );
+  DALI_TEST_CHECK( customActor );
+
+  const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
+  const unsigned int xComponentIndex = index + 1;
+  const unsigned int yComponentIndex = index + 2;
+  const Vector2 initialValue( 20.0f, 40.0f );
+
+  // Register animatable property & its components
+  AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
+
+  // Check the animatable property value
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Check the animatable property current value
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+
+  // Do an AnimateBy
+  const Vector2 targetValue( 45.0f, 53.0f );
+  const Vector2 relativeValue( targetValue - initialValue );
+
+  Animation animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
+  animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
+  animation.Play();
+
+  // Target values should change straight away
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
+{
+  TestApplication application;
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+  DALI_TEST_CHECK( typeInfo );
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+  Actor customActor = Actor::DownCast( handle );
+  DALI_TEST_CHECK( customActor );
+
+  const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
+  const unsigned int xComponentIndex = index + 1;
+  const unsigned int yComponentIndex = index + 2;
+  const unsigned int zComponentIndex = index + 3;
+  const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
+
+  // Register animatable property & its components
+  AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
+
+  // Check the animatable property value
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Check the animatable property current value
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
+
+  // Do an AnimateBy
+  const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
+  const Vector3 relativeValue( targetValue - initialValue );
+
+  Animation animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
+  animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
+  animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
+  animation.Play();
+
+  // Target values should change straight away
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
+{
+  TestApplication application;
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+  DALI_TEST_CHECK( typeInfo );
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+  Actor customActor = Actor::DownCast( handle );
+  DALI_TEST_CHECK( customActor );
+
+  const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
+  const unsigned int xComponentIndex = index + 1;
+  const unsigned int yComponentIndex = index + 2;
+  const unsigned int zComponentIndex = index + 3;
+  const unsigned int wComponentIndex = index + 4;
+  const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
+
+  // Register animatable property & its components
+  AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
+  AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
+
+  // Check the animatable property value
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Check the animatable property current value
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
+
+  // Do an AnimateBy
+  const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
+  const Vector4 relativeValue( targetValue - initialValue );
+
+  Animation animation = Animation::New( 1.0f );
+  animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
+  animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
+  animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
+  animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
+  animation.Play();
+
+  // Target values should change straight away
+  DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
+  DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
 {
   TestApplication application;
index 8df598e..2ab1558 100644 (file)
@@ -3242,144 +3242,305 @@ Property::Value Actor::GetDefaultPropertyCurrentValue( Property::Index index ) c
   return value;
 }
 
-void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value )
+void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
 {
-  switch( index )
+  switch( animationType )
   {
-    case Dali::Actor::Property::SIZE:
+    case Animation::TO:
+    case Animation::BETWEEN:
     {
-      if( value.Get( mTargetSize ) )
+      switch( index )
       {
-        // Notify deriving classes
-        OnSizeAnimation( animation, mTargetSize );
-      }
-      break;
-    }
+        case Dali::Actor::Property::SIZE:
+        {
+          if( value.Get( mTargetSize ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::SIZE_WIDTH:
-    {
-      if( value.Get( mTargetSize.width ) )
-      {
-        // Notify deriving classes
-        OnSizeAnimation( animation, mTargetSize );
-      }
-      break;
-    }
+        case Dali::Actor::Property::SIZE_WIDTH:
+        {
+          if( value.Get( mTargetSize.width ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::SIZE_HEIGHT:
-    {
-      if( value.Get( mTargetSize.height ) )
-      {
-        // Notify deriving classes
-        OnSizeAnimation( animation, mTargetSize );
+        case Dali::Actor::Property::SIZE_HEIGHT:
+        {
+          if( value.Get( mTargetSize.height ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_DEPTH:
+        {
+          if( value.Get( mTargetSize.depth ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION:
+        {
+          value.Get( mTargetPosition );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_X:
+        {
+          value.Get( mTargetPosition.x );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Y:
+        {
+          value.Get( mTargetPosition.y );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Z:
+        {
+          value.Get( mTargetPosition.z );
+          break;
+        }
+
+        case Dali::Actor::Property::ORIENTATION:
+        {
+          value.Get( mTargetOrientation );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE:
+        {
+          value.Get( mTargetScale );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_X:
+        {
+          value.Get( mTargetScale.x );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Y:
+        {
+          value.Get( mTargetScale.y );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Z:
+        {
+          value.Get( mTargetScale.z );
+          break;
+        }
+
+        case Dali::Actor::Property::VISIBLE:
+        {
+          SetVisibleInternal( value.Get< bool >(), SendMessage::FALSE );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR:
+        {
+          value.Get( mTargetColor );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_RED:
+        {
+          value.Get( mTargetColor.r );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_GREEN:
+        {
+          value.Get( mTargetColor.g );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_BLUE:
+        {
+          value.Get( mTargetColor.b );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_ALPHA:
+        case Dali::DevelActor::Property::OPACITY:
+        {
+          value.Get( mTargetColor.a );
+          break;
+        }
+
+        default:
+        {
+          // Not an animatable property. Do nothing.
+          break;
+        }
       }
       break;
     }
 
-    case Dali::Actor::Property::SIZE_DEPTH:
+    case Animation::BY:
     {
-      if( value.Get( mTargetSize.depth ) )
+      switch( index )
       {
-        // Notify deriving classes
-        OnSizeAnimation( animation, mTargetSize );
-      }
-      break;
-    }
+        case Dali::Actor::Property::SIZE:
+        {
+          if( AdjustValue< Vector3 >( mTargetSize, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::POSITION:
-    {
-      value.Get( mTargetPosition );
-      break;
-    }
+        case Dali::Actor::Property::SIZE_WIDTH:
+        {
+          if( AdjustValue< float >( mTargetSize.width, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::POSITION_X:
-    {
-      value.Get( mTargetPosition.x );
-      break;
-    }
+        case Dali::Actor::Property::SIZE_HEIGHT:
+        {
+          if( AdjustValue< float >( mTargetSize.height, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::POSITION_Y:
-    {
-      value.Get( mTargetPosition.y );
-      break;
-    }
+        case Dali::Actor::Property::SIZE_DEPTH:
+        {
+          if( AdjustValue< float >( mTargetSize.depth, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::POSITION_Z:
-    {
-      value.Get( mTargetPosition.z );
-      break;
-    }
+        case Dali::Actor::Property::POSITION:
+        {
+          AdjustValue< Vector3 >( mTargetPosition, value );
+          break;
+        }
 
-    case Dali::Actor::Property::ORIENTATION:
-    {
-      value.Get( mTargetOrientation );
-      break;
-    }
+        case Dali::Actor::Property::POSITION_X:
+        {
+          AdjustValue< float >( mTargetPosition.x, value );
+          break;
+        }
 
-    case Dali::Actor::Property::SCALE:
-    {
-      value.Get( mTargetScale );
-      break;
-    }
+        case Dali::Actor::Property::POSITION_Y:
+        {
+          AdjustValue< float >( mTargetPosition.y, value );
+          break;
+        }
 
-    case Dali::Actor::Property::SCALE_X:
-    {
-      value.Get( mTargetScale.x );
-      break;
-    }
+        case Dali::Actor::Property::POSITION_Z:
+        {
+          AdjustValue< float >( mTargetPosition.z, value );
+          break;
+        }
 
-    case Dali::Actor::Property::SCALE_Y:
-    {
-      value.Get( mTargetScale.y );
-      break;
-    }
+        case Dali::Actor::Property::ORIENTATION:
+        {
+          Quaternion relativeValue;
+          if( value.Get( relativeValue ) )
+          {
+            mTargetOrientation *= relativeValue;
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::SCALE_Z:
-    {
-      value.Get( mTargetScale.z );
-      break;
-    }
+        case Dali::Actor::Property::SCALE:
+        {
+          AdjustValue< Vector3 >( mTargetScale, value );
+          break;
+        }
 
-    case Dali::Actor::Property::VISIBLE:
-    {
-      SetVisibleInternal( value.Get< bool >(), SendMessage::FALSE );
-      break;
-    }
+        case Dali::Actor::Property::SCALE_X:
+        {
+          AdjustValue< float >( mTargetScale.x, value );
+          break;
+        }
 
-    case Dali::Actor::Property::COLOR:
-    {
-      value.Get( mTargetColor );
-      break;
-    }
+        case Dali::Actor::Property::SCALE_Y:
+        {
+          AdjustValue< float >( mTargetScale.y, value );
+          break;
+        }
 
-    case Dali::Actor::Property::COLOR_RED:
-    {
-      value.Get( mTargetColor.r );
-      break;
-    }
+        case Dali::Actor::Property::SCALE_Z:
+        {
+          AdjustValue< float >( mTargetScale.z, value );
+          break;
+        }
 
-    case Dali::Actor::Property::COLOR_GREEN:
-    {
-      value.Get( mTargetColor.g );
-      break;
-    }
+        case Dali::Actor::Property::VISIBLE:
+        {
+          bool relativeValue = false;
+          if( value.Get( relativeValue ) )
+          {
+            bool visible = mVisible || relativeValue;
+            SetVisibleInternal( visible, SendMessage::FALSE );
+          }
+          break;
+        }
 
-    case Dali::Actor::Property::COLOR_BLUE:
-    {
-      value.Get( mTargetColor.b );
-      break;
-    }
+        case Dali::Actor::Property::COLOR:
+        {
+          AdjustValue< Vector4 >( mTargetColor, value );
+          break;
+        }
 
-    case Dali::Actor::Property::COLOR_ALPHA:
-    case Dali::DevelActor::Property::OPACITY:
-    {
-      value.Get( mTargetColor.a );
-      break;
-    }
+        case Dali::Actor::Property::COLOR_RED:
+        {
+          AdjustValue< float >( mTargetColor.r, value );
+          break;
+        }
 
-    default:
-    {
-      // Not an animatable property. Do nothing.
+        case Dali::Actor::Property::COLOR_GREEN:
+        {
+          AdjustValue< float >( mTargetColor.g, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_BLUE:
+        {
+          AdjustValue< float >( mTargetColor.b, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_ALPHA:
+        case Dali::DevelActor::Property::OPACITY:
+        {
+          AdjustValue< float >( mTargetColor.a, value );
+          break;
+        }
+
+        default:
+        {
+          // Not an animatable property. Do nothing.
+          break;
+        }
+      }
       break;
     }
   }
index 59e23d0..b7e177d 100644 (file)
@@ -1656,7 +1656,7 @@ public:
   /**
    * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value );
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
 
   /**
    * @copydoc Dali::Internal::Object::GetPropertyOwner()
index 2191e2a..bb2b50c 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali/public-api/math/radian.h>
 #include <dali/internal/event/animation/animation-playlist.h>
 #include <dali/internal/event/animation/animator-connector.h>
+#include <dali/internal/event/animation/path-impl.h>
 #include <dali/internal/event/common/notification-manager.h>
 #include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/event/common/stage-impl.h>
@@ -281,7 +282,7 @@ void Animation::Play()
       Object* object = connector->GetObject();
       if( object )
       {
-        object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue );
+        object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType );
       }
     }
   }
@@ -363,12 +364,28 @@ void Animation::AnimateBy(Property& target, Property::Value& relativeValue, Time
 
 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period)
 {
-  Object& object = GetImplementation( target.object );
-  const Property::Type targetType = object.GetPropertyType( target.propertyIndex );
+  Object& object = GetImplementation(target.object);
+  const Property::Type targetType = object.GetPropertyType(target.propertyIndex);
   const Property::Type destinationType = relativeValue.GetType();
-  DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
 
-  ExtendDuration( period );
+  if ( object.GetPropertyComponentIndex( target.propertyIndex ) != Property::INVALID_COMPONENT_INDEX )
+  {
+    DALI_ASSERT_ALWAYS(Property::FLOAT == destinationType && "Animated value and Property type don't match");
+  }
+  else
+  {
+    DALI_ASSERT_ALWAYS(targetType == destinationType && "Animated value and Property type don't match");
+  }
+
+  ExtendDuration(period);
+
+  // Store data to later notify the object that its property is being animated
+  ConnectorTargetValues connectorPair;
+  connectorPair.targetValue = relativeValue;
+  connectorPair.connectorIndex = mConnectors.Count();
+  connectorPair.timePeriod = period;
+  connectorPair.animatorType = Animation::BY;
+  mConnectorTargetValues.push_back( connectorPair );
 
   switch ( targetType )
   {
@@ -502,6 +519,7 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
   connectorPair.targetValue = destinationValue;
   connectorPair.connectorIndex = mConnectors.Count();
   connectorPair.timePeriod = period;
+  connectorPair.animatorType = Animation::TO;
   mConnectorTargetValues.push_back( connectorPair );
 
   switch ( destinationType )
index 92dff74..cc4ec12 100644 (file)
@@ -23,9 +23,9 @@
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/object/base-object.h>
-#include <dali/internal/event/animation/animator-connector-base.h>
+#include <dali/devel-api/common/owner-container.h>
 #include <dali/internal/event/animation/key-frames-impl.h>
-#include <dali/internal/event/animation/path-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
 
 namespace Dali
 {
@@ -42,7 +42,9 @@ class UpdateManager;
 class Actor;
 class Animation;
 class AnimationPlaylist;
+class AnimatorConnectorBase;
 class Object;
+class Path;
 
 typedef IntrusivePtr<Animation> AnimationPtr;
 typedef std::vector<AnimationPtr> AnimationContainer;
@@ -59,6 +61,13 @@ class Animation : public BaseObject
 {
 public:
 
+  enum Type
+  {
+    TO,      ///< Animating TO the given value
+    BY,      ///< Animating BY the given value
+    BETWEEN  ///< Animating BETWEEN key-frames
+  };
+
   typedef Dali::Animation::EndAction EndAction;
   typedef Dali::Animation::Interpolation Interpolation;
 
@@ -445,13 +454,15 @@ private:
     ConnectorTargetValues()
     : targetValue(),
       timePeriod( 0.0f ),
-      connectorIndex( 0 )
+      connectorIndex( 0 ),
+      animatorType( TO )
     {
     }
 
     Property::Value targetValue;
     TimePeriod timePeriod;
     unsigned int connectorIndex;
+    Animation::Type animatorType;
   };
 
 private:
@@ -473,6 +484,7 @@ private:
 
   Dali::Animation::AnimationSignalType mFinishedSignal;
 
+  typedef OwnerContainer< AnimatorConnectorBase* > AnimatorConnectorContainer;
   AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
 
   typedef std::vector< ConnectorTargetValues > ConnectorTargetValuesContainer;
index 8ab2a8c..15cee6f 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ANIMATOR_CONNECTOR_BASE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -20,8 +20,6 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/devel-api/common/owner-container.h>
 #include <dali/public-api/animation/alpha-function.h>
 #include <dali/public-api/animation/time-period.h>
 #include <dali/public-api/common/dali-common.h>
@@ -33,14 +31,6 @@ namespace Internal
 {
 
 class Animation;
-class AnimatorConnectorBase;
-
-typedef OwnerPointer<AnimatorConnectorBase> AnimatorConnectorPtr;
-
-typedef OwnerContainer< AnimatorConnectorBase* > AnimatorConnectorContainer;
-
-typedef AnimatorConnectorContainer::Iterator AnimatorConnectorIter;
-typedef AnimatorConnectorContainer::ConstIterator AnimatorConnectorConstIter;
 
 /**
  * An abstract base class for animator connectors.
index da2f58d..fb2d388 100644 (file)
@@ -924,28 +924,46 @@ void Object::RemovePropertyNotifications()
   }
 }
 
-void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value )
+void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
 {
   if ( index < DEFAULT_PROPERTY_MAX_COUNT )
   {
-    OnNotifyDefaultPropertyAnimation( animation, index, value );
+    OnNotifyDefaultPropertyAnimation( animation, index, value, animationType );
   }
-  else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+  else
   {
-    AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index );
-    if( animatableProperty )
+    PropertyMetadata* propertyMetadata = NULL;
+    if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
     {
-      // update the cached property value
-      animatableProperty->SetPropertyValue( value );
+      propertyMetadata = FindAnimatableProperty( index );
     }
-  }
-  else
-  {
-    CustomPropertyMetadata* custom = FindCustomProperty( index );
-    if( custom && custom->IsAnimatable() )
+    else
     {
-      // update the cached property value
-      custom->SetPropertyValue( value );
+      CustomPropertyMetadata* custom = FindCustomProperty( index );
+      if( custom && custom->IsAnimatable() )
+      {
+        propertyMetadata = custom;
+      }
+    }
+
+    if( propertyMetadata )
+    {
+      switch( animationType )
+      {
+        case Animation::TO:
+        case Animation::BETWEEN:
+        {
+          // Update the cached property value
+          propertyMetadata->SetPropertyValue( value );
+          break;
+        }
+        case Animation::BY:
+        {
+          // Adjust the cached property value
+          propertyMetadata->AdjustPropertyValueBy( value );
+          break;
+        }
+      }
     }
   }
 }
index 035e7ee..89fc73f 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/public-api/object/property-input.h>
 #include <dali/public-api/object/property-notification.h>
 #include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/event/animation/animation-impl.h>
 #include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/event/common/property-input-impl.h>
 #include <dali/internal/event/common/property-metadata.h>
@@ -41,7 +42,6 @@ class PropertyNotification;
 
 namespace Internal
 {
-class Animation;
 class ConstraintBase;
 class EventThreadServices;
 class Handle;
@@ -245,8 +245,9 @@ public:
    * @param[in] animation The animation animating the property.
    * @param[in] index The index of the property.
    * @param[in] value The value of the property after the animation.
+   * @param[in] animationType Whether the property value given is the target or a relative value.
    */
-  void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value );
+  void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
 
   /******************************** Uniform Mappings ********************************/
 
@@ -492,8 +493,9 @@ private: // Default property extensions for derived classes
    * @param[in] animation The animation animating the property.
    * @param[in] index The index of the property.
    * @param[in] value The value of the property after the animation.
+   * @param[in] animationType Whether the property value given is the target or a relative value.
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value )
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType )
   { }
 
   /**
index 0fa0a47..e66a524 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_PROPERTY_HELPER_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -90,6 +90,25 @@ struct PropertyDetails
  */
 bool CompareTokens( const char * first, const char * second, size_t& size );
 
+
+/**
+ * @brief Helper to adjust the current value of a variable from the given property-value
+ * @param[in] currentValue The current value of the property
+ * @param[in] value The relative value as a Property::Value
+ * @return true if value adjusted, false otherwise
+ */
+template< typename PropertyType >
+bool AdjustValue( PropertyType& currentValue, const Property::Value& value )
+{
+  PropertyType relativeValue;
+  if( value.Get( relativeValue ) )
+  {
+    currentValue += relativeValue;
+    return true;
+  }
+  return false;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index abbe62e..41e0848 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/event/common/property-metadata.h>
 
 // INTERNAL INCLUDES
+#include <dali/public-api/math/quaternion.h>
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/math/vector3.h>
 #include <dali/public-api/math/vector4.h>
@@ -30,6 +31,23 @@ namespace Dali
 namespace Internal
 {
 
+namespace
+{
+
+/// Helper to adjust the property value by an amount specified in another property-value
+template < typename PropertyType >
+inline void AdjustProperty( Property::Value& currentPropertyValue, const Property::Value& relativePropertyValue )
+{
+  PropertyType currentValue;
+  PropertyType relativeValue;
+  if( currentPropertyValue.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+  {
+    currentPropertyValue = currentValue + relativeValue;
+  }
+}
+
+} // unnamed namespace
+
 void PropertyMetadata::SetPropertyValue( const Property::Value& propertyValue )
 {
   switch ( GetType() )
@@ -235,6 +253,146 @@ Property::Value PropertyMetadata::GetPropertyValue() const
   return propertyValue;
 }
 
+void PropertyMetadata::AdjustPropertyValueBy( const Property::Value& relativePropertyValue )
+{
+  switch ( GetType() )
+  {
+    case Property::NONE:
+    case Property::RECTANGLE:
+    case Property::STRING:
+    case Property::ARRAY:
+    case Property::MAP:
+    case Property::MATRIX:
+    case Property::MATRIX3:
+    {
+      // Not animated
+      break;
+    }
+
+    case Property::BOOLEAN:
+    {
+      bool currentValue = false;
+      bool relativeValue = false;
+      if( value.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+      {
+        value = currentValue || relativeValue;
+      }
+      break;
+    }
+
+    case Property::INTEGER:
+    {
+      AdjustProperty< int >( value, relativePropertyValue );
+      break;
+    }
+
+    case Property::FLOAT:
+    {
+      AdjustProperty< float >( value, relativePropertyValue );
+      break;
+    }
+
+    case Property::ROTATION:
+    {
+      Quaternion currentValue;
+      Quaternion relativeValue;
+      if( value.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+      {
+        value = currentValue * relativeValue;
+      }
+      break;
+    }
+
+    case Property::VECTOR2:
+    {
+      if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+      {
+        AdjustProperty< Vector2 >( value, relativePropertyValue );
+      }
+      else
+      {
+        Vector2 vector2Value;
+        value.Get( vector2Value );
+
+        if( componentIndex == 0 )
+        {
+          vector2Value.x += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 1 )
+        {
+          vector2Value.y += relativePropertyValue.Get< float >();
+        }
+
+        value = vector2Value;
+      }
+
+      break;
+    }
+
+    case Property::VECTOR3:
+    {
+      if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+      {
+        AdjustProperty< Vector3 >( value, relativePropertyValue );
+      }
+      else
+      {
+        Vector3 vector3Value;
+        value.Get( vector3Value );
+
+        if( componentIndex == 0 )
+        {
+          vector3Value.x += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 1 )
+        {
+          vector3Value.y += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 2 )
+        {
+          vector3Value.z += relativePropertyValue.Get< float >();
+        }
+
+        value = vector3Value;
+      }
+      break;
+    }
+
+    case Property::VECTOR4:
+    {
+      if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+      {
+        AdjustProperty< Vector4 >( value, relativePropertyValue );
+      }
+      else
+      {
+        Vector4 vector4Value;
+        value.Get( vector4Value );
+
+        if( componentIndex == 0 )
+        {
+          vector4Value.x += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 1 )
+        {
+          vector4Value.y += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 2 )
+        {
+          vector4Value.z += relativePropertyValue.Get< float >();
+        }
+        else if( componentIndex == 3 )
+        {
+          vector4Value.w += relativePropertyValue.Get< float >();
+        }
+
+        value = vector4Value;
+      }
+      break;
+    }
+  }
+}
+
 } // namespace Internal
 
 } // namespace Dali
index a06f262..b845eaa 100644 (file)
@@ -116,6 +116,12 @@ public:
    */
   Property::Value GetPropertyValue() const;
 
+  /**
+   * Modifies the stored value by the relativeValue.
+   * @param[in] relativeValue The value to change by.
+   */
+  void AdjustPropertyValueBy( const Property::Value& relativeValue );
+
 protected:
 
   /**
index a97069b..8da4425 100644 (file)
@@ -689,29 +689,66 @@ Property::Value RenderTask::GetDefaultPropertyCurrentValue( Property::Index inde
   return value;
 }
 
-void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value )
+void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
 {
-  switch ( index )
+  switch( animationType )
   {
-    case Dali::RenderTask::Property::VIEWPORT_POSITION:
+    case Animation::TO:
+    case Animation::BETWEEN:
     {
-      value.Get( mViewportPosition );
-      break;
-    }
-    case Dali::RenderTask::Property::VIEWPORT_SIZE:
-    {
-      value.Get( mViewportSize );
-      break;
-    }
-    case Dali::RenderTask::Property::CLEAR_COLOR:
-    {
-      value.Get( mClearColor );
+      switch ( index )
+      {
+        case Dali::RenderTask::Property::VIEWPORT_POSITION:
+        {
+          value.Get( mViewportPosition );
+          break;
+        }
+        case Dali::RenderTask::Property::VIEWPORT_SIZE:
+        {
+          value.Get( mViewportSize );
+          break;
+        }
+        case Dali::RenderTask::Property::CLEAR_COLOR:
+        {
+          value.Get( mClearColor );
+          break;
+        }
+        case Dali::RenderTask::Property::REQUIRES_SYNC:
+        default:
+        {
+          // Nothing to do as not animatable
+          break;
+        }
+      }
       break;
     }
-    case Dali::RenderTask::Property::REQUIRES_SYNC:
-    default:
+
+    case Animation::BY:
     {
-      // Nothing to do as not animatable
+      switch ( index )
+      {
+        case Dali::RenderTask::Property::VIEWPORT_POSITION:
+        {
+          AdjustValue< Vector2 >( mViewportPosition, value );
+          break;
+        }
+        case Dali::RenderTask::Property::VIEWPORT_SIZE:
+        {
+          AdjustValue< Vector2 >( mViewportSize, value );
+          break;
+        }
+        case Dali::RenderTask::Property::CLEAR_COLOR:
+        {
+          AdjustValue< Vector4 >( mClearColor, value );
+          break;
+        }
+        case Dali::RenderTask::Property::REQUIRES_SYNC:
+        default:
+        {
+          // Nothing to do as not animatable
+          break;
+        }
+      }
       break;
     }
   }
index 90d5cc3..1639b35 100644 (file)
@@ -325,7 +325,7 @@ public: // Implementation of Object
   /**
    * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value );
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
 
   /**
    * @copydoc Dali::Internal::Object::GetSceneObject()
index 0afc168..0e14bdb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -23,6 +23,7 @@
 #include <dali/public-api/animation/time-period.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/animation/animation-impl.h>
+#include <dali/internal/event/animation/path-impl.h>
 
 namespace Dali
 {