From 462cbee2270984cdca45488f3733d664dcf49187 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 9 May 2017 16:13:40 +0100 Subject: [PATCH] Ensure cached values of properties animated using AnimateTo are updated Change-Id: I76b93d51c807c6be75ed419e01b0fa5fdb575c08 --- automated-tests/src/dali/utc-Dali-Actor.cpp | 42 +++- automated-tests/src/dali/utc-Dali-Animation.cpp | 136 +++++++++++- automated-tests/src/dali/utc-Dali-Constrainer.cpp | 10 +- automated-tests/src/dali/utc-Dali-RenderTask.cpp | 24 +++ dali/internal/event/actors/actor-impl.cpp | 227 +++++++++++++++------ dali/internal/event/actors/actor-impl.h | 58 ++---- dali/internal/event/animation/animation-impl.cpp | 126 +++--------- dali/internal/event/animation/animation-impl.h | 2 +- dali/internal/event/common/object-impl.cpp | 26 +++ dali/internal/event/common/object-impl.h | 18 ++ .../event/render-tasks/render-task-impl.cpp | 28 +++ .../internal/event/render-tasks/render-task-impl.h | 5 + dali/public-api/animation/animation.h | 2 + 13 files changed, 501 insertions(+), 203 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index f4a6071..4794369 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -5960,6 +5960,7 @@ int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void) END_TEST; } + int utcDaliActorVisibilityChangeSignalSelf(void) { TestApplication application; @@ -6042,4 +6043,43 @@ int utcDaliActorVisibilityChangeSignalChildren(void) childData.Check( false /* not called */, TEST_LOCATION ); grandChildData.Check( false /* not called */, TEST_LOCATION ); - END_TEST;} + END_TEST; +} + +int utcDaliActorVisibilityChangeSignalAfterAnimation(void) +{ + TestApplication application; + tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" ); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + application.SendNotification(); + application.Render(); + + VisibilityChangedFunctorData data; + DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) ); + + Animation animation = Animation::New( 1.0f ); + animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false ); + + data.Check( false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION ); + + tet_infoline( "Play the animation and check the property value" ); + animation.Play(); + + data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION ); + + tet_infoline( "Animation not currently finished, so the current visibility should still be true" ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render( 1100 ); // After the animation + + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), false, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 36fb592..2a46bf5 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -5781,10 +5781,11 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void) application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - // We didn't expect the animation to finish yet + // We didn't expect the animation to finish yet, but cached value should be the final one application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty( actor, index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -5801,6 +5802,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalReceived(); DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( actor, index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } @@ -6518,9 +6520,21 @@ int UtcDaliAnimationAnimateToActorSizeP(void) Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + 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 ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6628,9 +6642,17 @@ int UtcDaliAnimationAnimateToActorSizeWidthP(void) float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6672,9 +6694,17 @@ int UtcDaliAnimationAnimateToActorSizeHeightP(void) float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6716,9 +6746,17 @@ int UtcDaliAnimationAnimateToActorSizeDepthP(void) float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6868,9 +6906,21 @@ int UtcDaliAnimationAnimateToActorPositionP(void) Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + 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 ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6913,9 +6963,17 @@ int UtcDaliAnimationAnimateToActorPositionXP(void) float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6961,9 +7019,17 @@ int UtcDaliAnimationAnimateToActorPositionYP(void) float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7009,9 +7075,17 @@ int UtcDaliAnimationAnimateToActorPositionZP(void) float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION ); + // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7210,6 +7284,9 @@ int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7504,6 +7581,12 @@ int UtcDaliAnimationAnimateToActorScaleP(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 ); + 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 ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7619,6 +7702,10 @@ int UtcDaliAnimationAnimateToActorScaleXP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7673,6 +7760,10 @@ int UtcDaliAnimationAnimateToActorScaleYP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7727,6 +7818,10 @@ int UtcDaliAnimationAnimateToActorScaleZP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7775,6 +7870,14 @@ int UtcDaliAnimationAnimateToActorColorP(void) // 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.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7900,6 +8003,10 @@ int UtcDaliAnimationAnimateToActorColorRedP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -7958,6 +8065,10 @@ int UtcDaliAnimationAnimateToActorColorGreenP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -8016,6 +8127,10 @@ int UtcDaliAnimationAnimateToActorColorBlueP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -8074,6 +8189,11 @@ int UtcDaliAnimationAnimateToActorColorAlphaP(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -10085,10 +10205,11 @@ int UtcDaliAnimationExtendDurationP(void) application.SendNotification(); application.Render(static_cast(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - // We didn't expect the animation to finish yet + // We didn't expect the animation to finish yet, but cached value should be the final one application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -10105,6 +10226,7 @@ int UtcDaliAnimationExtendDurationP(void) application.SendNotification(); finishCheck.CheckSignalReceived(); DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } @@ -10475,7 +10597,7 @@ int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionCol // Build the animation Animation animation = Animation::New(2.0f); - tet_infoline("Set target size in animation without intiating play"); + tet_infoline("Set target size in animation without initiating play"); animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR); tet_infoline("Set target position in animation without intiating play"); animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR); @@ -10484,7 +10606,7 @@ int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionCol application.SendNotification(); application.Render(); - tet_infoline("Ensure position of actor is still at intial size and position"); + tet_infoline("Ensure position of actor is still at initial size and position"); DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION ); @@ -10496,7 +10618,7 @@ int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionCol application.SendNotification(); application.Render(2000u); - tet_infoline("Ensure position and size of actor is at target value when aninmation playing"); + tet_infoline("Ensure position and size of actor is at target value when animation playing"); DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-Constrainer.cpp b/automated-tests/src/dali/utc-Dali-Constrainer.cpp index e212720..33e6ec9 100644 --- a/automated-tests/src/dali/utc-Dali-Constrainer.cpp +++ b/automated-tests/src/dali/utc-Dali-Constrainer.cpp @@ -189,14 +189,14 @@ int UtcPathConstrainerApplyRange(void) Vector3 position, tangent; float tValue; - actor.GetProperty(index).Get(tValue); + DevelHandle::GetCurrentProperty( actor, index ).Get(tValue); float currentCursor = ( tValue - range.x ) / (range.y-range.x); path.Sample(currentCursor, position, tangent ); DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - actor.GetProperty(index).Get(tValue); + DevelHandle::GetCurrentProperty( actor, index ).Get(tValue); currentCursor = ( tValue - range.x ) / (range.y-range.x); path.Sample(currentCursor, position, tangent ); path.Sample(0.5, position, tangent ); @@ -223,6 +223,12 @@ int UtcPathConstrainerApplyRange(void) path.Sample(currentCursor, position, tangent ); DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + // Ensure GetProperty also returns the final result + actor.GetProperty( index ).Get( tValue ); + currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index 061cb62..7e9ad26 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -1431,9 +1431,14 @@ int UtcDaliRenderTaskSetViewportPosition(void) animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR ); animation.Play(); + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); + // Perform 1000ms worth of updates at which point animation should have completed. Wait(application, 1000); DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, 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 ); END_TEST; } @@ -1483,9 +1488,14 @@ int UtcDaliRenderTaskSetViewportSize(void) animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR ); animation.Play(); + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); + // Perform 1000ms worth of updates at which point animation should have completed. Wait(application, 1000); DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, 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 ); END_TEST; } @@ -1521,6 +1531,20 @@ int UtcDaliRenderTaskSetClearColorP(void) DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); + + Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f); + Animation animation = Animation::New(1.0f); + animation.AnimateTo( Property( task, RenderTask::Property::CLEAR_COLOR ), newColor3, AlphaFunction::LINEAR ); + animation.Play(); + + DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, 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 ); + END_TEST; } diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 6ca8901..8df598e 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1056,19 +1056,7 @@ Matrix Actor::GetCurrentWorldMatrix() const void Actor::SetVisible( bool visible ) { - if( mVisible != visible ) - { - if( NULL != mNode ) - { - // mNode is being used in a separate thread; queue a message to set the value & base value - SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, &mNode->mVisible, &AnimatableProperty::Bake, visible ); - } - - mVisible = visible; - - // Emit the signal on this actor and all its children - EmitVisibilityChangedSignalRecursively( this, visible, DevelActor::VisibilityChange::SELF ); - } + SetVisibleInternal( visible, SendMessage::TRUE ); } bool Actor::IsVisible() const @@ -1290,53 +1278,6 @@ void Actor::SetSizeInternal( const Vector3& size ) } } -void Actor::NotifySizeAnimation( Animation& animation, const Vector3& targetSize ) -{ - mTargetSize = targetSize; - - // Notify deriving classes - OnSizeAnimation( animation, mTargetSize ); -} - -void Actor::NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property ) -{ - if ( Dali::Actor::Property::SIZE_WIDTH == property ) - { - mTargetSize.width = targetSize; - } - else if ( Dali::Actor::Property::SIZE_HEIGHT == property ) - { - mTargetSize.height = targetSize; - } - else if ( Dali::Actor::Property::SIZE_DEPTH == property ) - { - mTargetSize.depth = targetSize; - } - // Notify deriving classes - OnSizeAnimation( animation, mTargetSize ); -} - -void Actor::NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition ) -{ - mTargetPosition = targetPosition; -} - -void Actor::NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property ) -{ - if ( Dali::Actor::Property::POSITION_X == property ) - { - mTargetPosition.x = targetPosition; - } - else if ( Dali::Actor::Property::POSITION_Y == property ) - { - mTargetPosition.y = targetPosition; - } - else if ( Dali::Actor::Property::POSITION_Z == property ) - { - mTargetPosition.z = targetPosition; - } -} - void Actor::SetWidth( float width ) { if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout ) @@ -3301,6 +3242,149 @@ Property::Value Actor::GetDefaultPropertyCurrentValue( Property::Index index ) c return value; } +void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ) +{ + switch( index ) + { + 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_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; + } + } +} + const SceneGraph::PropertyOwner* Actor::GetPropertyOwner() const { return mNode; @@ -4223,6 +4307,12 @@ bool Actor::GetCurrentPropertyValue( Property::Index index, Property::Value& val break; } + case Dali::Actor::Property::VISIBLE: + { + value = IsVisible(); + break; + } + default: { // Must be an event-side only property @@ -4979,6 +5069,23 @@ Object* Actor::GetParentObject() const return mParent; } +void Actor::SetVisibleInternal( bool visible, SendMessage::Type sendMessage ) +{ + if( mVisible != visible ) + { + if( sendMessage == SendMessage::TRUE && NULL != mNode ) + { + // mNode is being used in a separate thread; queue a message to set the value & base value + SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, &mNode->mVisible, &AnimatableProperty::Bake, visible ); + } + + mVisible = visible; + + // Emit the signal on this actor and all its children + EmitVisibilityChangedSignalRecursively( this, visible, DevelActor::VisibilityChange::SELF ); + } +} + void Actor::SetSiblingOrder( unsigned int order ) { mSiblingOrder = std::min( order, static_cast( DevelLayer::SIBLING_ORDER_MULTIPLIER ) ); diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 6eac5aa..59e23d0 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -619,7 +619,7 @@ public: /** * Sets the visibility flag of an actor. - * @param [in] visible The new visibility flag. + * @param[in] visible The new visibility flag. */ void SetVisible( bool visible ); @@ -1486,23 +1486,6 @@ public: // For Animation /** - * This should only be called by Animation, when the actors SIZE property is animated. - * - * @param[in] animation The animation that resized the actor - * @param[in] targetSize The new target size of the actor - */ - void NotifySizeAnimation( Animation& animation, const Vector3& targetSize ); - - /** - * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT or SIZE_DEPTH property is animated. - * - * @param[in] animation The animation that resized the actor - * @param[in] targetSize The new target size of the actor - * @param[in] property The index of the property being animated - */ - void NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property ); - - /** * For use in derived classes. * This should only be called by Animation, when the actor is resized using Animation::Resize(). */ @@ -1510,23 +1493,6 @@ public: { } - /** - * This should only be called by Animation, when the actors POSITION property is animated. - * - * @param[in] animation The animation that repositioned the actor - * @param[in] targetPosition The new target position of the actor - */ - void NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition ); - - /** - * This should only be called by Animation, when the actors POSITION_X or POSITION_Y or POSITION_Z property is animated. - * - * @param[in] animation The animation that repositioned the actor - * @param[in] targetPosition The new target position of the actor - * @param[in] property The index of the property being animated - */ - void NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property ); - protected: enum DerivedType @@ -1688,6 +1654,11 @@ public: virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const; /** + * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation() + */ + virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ); + + /** * @copydoc Dali::Internal::Object::GetPropertyOwner() */ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const; @@ -1744,6 +1715,15 @@ public: private: + struct SendMessage + { + enum Type + { + FALSE = 0, + TRUE = 1, + }; + }; + // Undefined Actor(); @@ -1922,7 +1902,6 @@ private: */ bool ShiftSiblingsLevels( ActorContainer& siblings, int targetLevelToShiftFrom ); - /** * @brief Get the current position of the actor in screen coordinates. * @@ -1930,6 +1909,13 @@ private: */ const Vector2 GetCurrentScreenPosition() const; + /** + * Sets the visibility flag of an actor. + * @param[in] visible The new visibility flag. + * @param[in] sendMessage Whether to send a message to the update thread or not. + */ + void SetVisibleInternal( bool visible, SendMessage::Type sendMessage ); + protected: Actor* mParent; ///< Each actor (except the root) can have one parent diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index c09c4b1..c27f31b 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -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. @@ -22,14 +22,12 @@ // EXTERNAL INCLUDES // INTERNAL INCLUDES -#include #include #include #include #include #include #include -#include #include #include #include @@ -267,71 +265,33 @@ void Animation::Play() mState = Dali::Animation::PLAYING; - unsigned int connectorTargetValuesIndex( 0 ); - unsigned int numberOfConnectorTargetValues = mConnectorActorTargetValues.size(); - - /* - * Loop through all Animator connectors, if connector index matches the current index stored in mConnectorActorTargetValues container then - * should apply target values for this index to the Actor. - * Confirm object is an actor and it is a POSITION or SIZE Property Index before sending Notify message to Actor. - */ - for ( unsigned int connectorIndex = 0; connectorIndex < mConnectors.Count(); connectorIndex ++) + if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values { - // Use index to check if the current connector is next in the mConnectorActorTargetValues container, meaning targetValues have been pushed in AnimateXXFunction - if ( connectorTargetValuesIndex < numberOfConnectorTargetValues ) + unsigned int connectorTargetValuesIndex( 0 ); + unsigned int numberOfConnectorTargetValues = mConnectorTargetValues.size(); + + /* + * Loop through all Animator connectors, if connector index matches the current index stored in mConnectorTargetValues container then + * should apply target values for this index to the object. + */ + for ( unsigned int connectorIndex = 0; connectorIndex < mConnectors.Count(); connectorIndex ++) { - ConnectorTargetValues& connectorPair = mConnectorActorTargetValues[ connectorTargetValuesIndex ]; - - if ( connectorPair.connectorIndex == connectorIndex ) + // Use index to check if the current connector is next in the mConnectorTargetValues container, meaning targetValues have been pushed in AnimateXXFunction + if ( connectorTargetValuesIndex < numberOfConnectorTargetValues ) { - // Current connector index matches next in the stored connectors with target values so apply target value. - connectorTargetValuesIndex++; // Found a match for connector so increment index to next one - - AnimatorConnectorBase* connector = mConnectors[ connectorIndex ]; + ConnectorTargetValues& connectorPair = mConnectorTargetValues[ connectorTargetValuesIndex ]; - Actor* maybeActor = static_cast( connector->GetObject() ); // Only Actors would be in mConnectorActorTargetValues container - - if ( maybeActor ) + if ( connectorPair.connectorIndex == connectorIndex ) { - // Get Stored Target Value and corresponding connector index - const Property::Type valueType = connectorPair.targetValue.GetType(); - Property::Index propertyIndex = connector->GetPropertyIndex(); + // Current connector index matches next in the stored connectors with target values so apply target value. + connectorTargetValuesIndex++; // Found a match for connector so increment index to next one - if ( valueType == Property::VECTOR3 ) - { - Vector3 targetVector3 = connectorPair.targetValue.Get(); - - if ( propertyIndex == Dali::Actor::Property::POSITION ) - { - maybeActor->NotifyPositionAnimation( *this, targetVector3 ); - } - else if ( propertyIndex == Dali::Actor::Property::SIZE ) - { - maybeActor->NotifySizeAnimation( *this, targetVector3 ); - } - } - else if ( valueType == Property::FLOAT ) - { - float targetFloat = connectorPair.targetValue.Get(); - - if ( ( Dali::Actor::Property::POSITION_X == propertyIndex ) || - ( Dali::Actor::Property::POSITION_Y == propertyIndex ) || - ( Dali::Actor::Property::POSITION_Z == propertyIndex ) ) - { - maybeActor->NotifyPositionAnimation( *this, targetFloat, propertyIndex ); - } - else if ( ( Dali::Actor::Property::SIZE_WIDTH == propertyIndex ) || - ( Dali::Actor::Property::SIZE_HEIGHT == propertyIndex ) || - ( Dali::Actor::Property::SIZE_DEPTH == propertyIndex ) ) - - { - maybeActor->NotifySizeAnimation( *this, targetFloat, propertyIndex ); - } - } - else + AnimatorConnectorBase* connector = mConnectors[ connectorIndex ]; + + Object* object = connector->GetObject(); + if( object ) { - // Currently only FLOAT and VECTOR3 is supported for Target values in AnimateXXFunctions - DALI_LOG_WARNING("Animation::Play Unsupported Value Type provided as TargetValue\n"); + object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), connectorPair.targetValue ); } } } @@ -384,6 +344,9 @@ void Animation::Clear() // Remove all the connectors mConnectors.Clear(); + // Reset the connector target values + mConnectorTargetValues.clear(); + // Replace the old scene-object with a new one DestroySceneObject(); CreateSceneObject(); @@ -546,6 +509,12 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn ExtendDuration( period ); + // Store data to later notify the object that its property is being animated + ConnectorTargetValues connectorPair; + connectorPair.targetValue = destinationValue; + connectorPair.connectorIndex = mConnectors.Count(); + mConnectorTargetValues.push_back( connectorPair ); + switch ( destinationType ) { case Property::BOOLEAN: @@ -572,26 +541,6 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn case Property::FLOAT: { - if ( ( Dali::Actor::Property::SIZE_WIDTH == targetPropertyIndex ) || - ( Dali::Actor::Property::SIZE_HEIGHT == targetPropertyIndex ) || - ( Dali::Actor::Property::SIZE_DEPTH == targetPropertyIndex ) || - ( Dali::Actor::Property::POSITION_X == targetPropertyIndex ) || - ( Dali::Actor::Property::POSITION_Y == targetPropertyIndex ) || - ( Dali::Actor::Property::POSITION_Z == targetPropertyIndex ) ) - { - - Actor* maybeActor = dynamic_cast( &targetObject ); - if ( maybeActor ) - { - // Store data to later notify the actor that its size or position is being animated - ConnectorTargetValues connectorPair; - connectorPair.targetValue = destinationValue; - connectorPair.connectorIndex = mConnectors.Count(); - - mConnectorActorTargetValues.push_back( connectorPair ); - } - } - AddAnimatorConnector( AnimatorConnector::New( targetObject, targetPropertyIndex, componentIndex, @@ -614,21 +563,6 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn case Property::VECTOR3: { - if ( Dali::Actor::Property::SIZE == targetPropertyIndex || Dali::Actor::Property::POSITION == targetPropertyIndex ) - { - // Test whether this is actually an Actor - Actor* maybeActor = dynamic_cast( &targetObject ); - if ( maybeActor ) - { - // Store data to later notify the actor that its size or position is being animated - ConnectorTargetValues connectorPair; - connectorPair.targetValue = destinationValue; - connectorPair.connectorIndex = mConnectors.Count(); - - mConnectorActorTargetValues.push_back( connectorPair ); - } - } - AddAnimatorConnector( AnimatorConnector::New( targetObject, targetPropertyIndex, componentIndex, diff --git a/dali/internal/event/animation/animation-impl.h b/dali/internal/event/animation/animation-impl.h index 7239ed4..fa28101 100644 --- a/dali/internal/event/animation/animation-impl.h +++ b/dali/internal/event/animation/animation-impl.h @@ -469,7 +469,7 @@ private: AnimatorConnectorContainer mConnectors; ///< Owned by the Animation - std::vector< ConnectorTargetValues > mConnectorActorTargetValues; //< Store Actor target values and matchinf connector index that need to set value on Animation::Play + std::vector< ConnectorTargetValues > mConnectorTargetValues; //< Used to store animating property target value information // Cached for public getters float mDurationSeconds; diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index d43ccf7..344e72c 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -924,6 +924,32 @@ void Object::RemovePropertyNotifications() } } +void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ) +{ + if ( index < DEFAULT_PROPERTY_MAX_COUNT ) + { + OnNotifyDefaultPropertyAnimation( animation, index, value ); + } + else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index ); + if( animatableProperty ) + { + // update the cached property value + animatableProperty->SetPropertyValue( value ); + } + } + else + { + CustomPropertyMetadata* custom = FindCustomProperty( index ); + if( custom && custom->IsAnimatable() ) + { + // update the cached property value + custom->SetPropertyValue( value ); + } + } +} + void Object::EnablePropertyNotifications() { if( mPropertyNotifications ) diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index d378674..035e7ee 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -41,6 +41,7 @@ class PropertyNotification; namespace Internal { +class Animation; class ConstraintBase; class EventThreadServices; class Handle; @@ -239,6 +240,14 @@ public: */ virtual void RemovePropertyNotifications(); + /** + * Notifies that a property is being animated. + * @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. + */ + void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ); + /******************************** Uniform Mappings ********************************/ /** @@ -479,6 +488,15 @@ private: // Default property extensions for derived classes virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const = 0; /** + * Notifies that a default property is being animated so the deriving class should update the cached value. + * @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. + */ + virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ) + { } + + /** * @todo this is virtual so that for now actor can override it, * it needs to be removed and only have GetSceneObject but that requires changing actor and constraint logic * Retrieve the scene-graph object added by this object. diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 04dfbb1..a97069b 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -689,6 +689,34 @@ Property::Value RenderTask::GetDefaultPropertyCurrentValue( Property::Index inde return value; } +void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ) +{ + 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; + } + } +} + const SceneGraph::PropertyOwner* RenderTask::GetSceneObject() const { return mSceneObject; diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index b76d0a2..90d5cc3 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -323,6 +323,11 @@ public: // Implementation of Object virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const; /** + * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation() + */ + virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ); + + /** * @copydoc Dali::Internal::Object::GetSceneObject() */ virtual const SceneGraph::PropertyOwner* GetSceneObject() const; diff --git a/dali/public-api/animation/animation.h b/dali/public-api/animation/animation.h index 7480ff1..29160c3 100644 --- a/dali/public-api/animation/animation.h +++ b/dali/public-api/animation/animation.h @@ -102,6 +102,8 @@ class Animation; * * Using AnimateTo and AnimateBy for the same property of the same Actor will yield undefined behaviour especially if the TimePeriod overlaps. * + * After calling Animation::Play(), Handle::GetProperty will return the target value of the animated property. + * * Signals * | %Signal Name | Method | * |--------------|--------------------------| -- 2.7.4