END_TEST;
}
+
+int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
+{
+ tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
+
+ TestApplication application;
+
+ tet_infoline("Set initial position and set up animation to re-position actor");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+ Vector3 initialPosition(0.0f, 0.0f, 0.0f);
+ actor.SetProperty( Actor::Property::POSITION, initialPosition );
+
+ // Build the animation
+ Animation animation = Animation::New(2.0f);
+
+ //Test GetCurrentProgress return 0.0 as the duration is 0.0
+ DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
+
+ tet_infoline("Set target position in animation without intiating play");
+
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Ensure position of actor is still at intial value");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
+
+ tet_infoline("Play animation and ensure actor position is now target");
+
+ animation.Play();
+ application.SendNotification();
+ application.Render(1000u);
+
+ tet_infoline("Ensure position of actor is at target value when aninmation half way");
+
+ 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 );
+
+ tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
+
+ application.Render(2000u);
+
+ tet_infoline("Ensure position of actor is still at target value when aninmation complete");
+
+ 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 );
+
+ END_TEST;
+}
+
+int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
+{
+ tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
+
+ TestApplication application;
+
+ std::vector<Vector3> targetPositions;
+
+ targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
+ targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
+ targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
+
+ tet_infoline("Set initial position and set up animation to re-position actor");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+ Vector3 initialPosition(0.0f, 0.0f, 0.0f);
+ actor.SetProperty( Actor::Property::POSITION, initialPosition );
+
+ // Build the animation
+ Animation animation = Animation::New(2.0f);
+
+ //Test GetCurrentProgress return 0.0 as the duration is 0.0
+ DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
+
+ tet_infoline("Set target position in animation without intiating play");
+
+ for ( unsigned int i = 0; i < targetPositions.size(); i++ )
+ {
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
+ }
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Ensure position of actor is still at intial value");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
+
+ tet_infoline("Play animation and ensure actor position is now target");
+
+ animation.Play();
+ application.SendNotification();
+ application.Render(1000u);
+
+ tet_infoline("Ensure position of actor is at target value when aninmation half way");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
+
+ tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
+
+ application.Render(2000u);
+
+ tet_infoline("Ensure position of actor is still at target value when aninmation complete");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
+{
+ tet_infoline("Setting up an animation should not effect it's size property until the animation plays even with mulitple animators of different Property Indexes");
+
+ TestApplication application;
+
+ std::vector<Vector3> targetSizes;
+ std::vector<Vector3> targetPositions;
+
+ targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
+ targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
+
+ targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
+
+ tet_infoline("Set initial position and set up animation to re-position actor");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+ Vector3 initialSize( 10.0f, 10.0f, 10.0f);
+ Vector3 initialPosition(10.0f, 10.0f, 10.0f);
+
+ actor.SetProperty( Actor::Property::SIZE, initialSize );
+ actor.SetProperty( Actor::Property::POSITION, initialPosition );
+
+ // Build the animation
+ Animation animation = Animation::New(2.0f);
+
+ tet_infoline("Set target size in animation without intiating 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::POSITION), targetPositions[0], AlphaFunction::LINEAR);
+ animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Ensure position of actor is still at intial size and position");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
+
+ tet_infoline("Play animation and ensure actor position and size is now matches targets");
+
+ animation.Play();
+ application.SendNotification();
+ application.Render(2000u);
+
+ tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
+{
+ tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
+
+ TestApplication application;
+
+ std::vector<Vector3> targetSizes;
+ std::vector<float> targetColors;
+
+ targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
+ targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
+
+ targetColors.push_back( 1.0f );
+
+ tet_infoline("Set initial position and set up animation to re-position actor");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+ Vector3 initialSize( 10.0f, 5.0f, 10.0f);
+
+ actor.SetProperty( Actor::Property::SIZE, initialSize );
+
+ // Build the animation
+ Animation animation = Animation::New(2.0f);
+
+ tet_infoline("Set target size in animation without intiating 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);
+ animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Ensure position of actor is still at intial size and position");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
+
+ tet_infoline("Play animation and ensure actor position and size is now matches targets");
+
+ animation.Play();
+ application.SendNotification();
+ application.Render(2000u);
+
+ tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
+
+ END_TEST;
+}
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/update/animation/scene-graph-animator.h>
#include <dali/internal/update/manager/update-manager.h>
using Dali::Internal::SceneGraph::UpdateManager;
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 ++)
+ {
+ // Use index to check if the current connector is next in the mConnectorActorTargetValues container, meaning targetValues have been pushed in AnimateXXFunction
+ if ( connectorTargetValuesIndex < numberOfConnectorTargetValues )
+ {
+ ConnectorTargetValues& connectorPair = mConnectorActorTargetValues[ connectorTargetValuesIndex ];
+
+ if ( connectorPair.connectorIndex == connectorIndex )
+ {
+ // 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 ];
+
+ Actor* maybeActor = static_cast<Actor*>( connector->GetObject() ); // Only Actors would be in mConnectorActorTargetValues container
+
+ if ( maybeActor )
+ {
+ // Get Stored Target Value and corresponding connector index
+ const Property::Type valueType = connectorPair.targetValue.GetType();
+ Property::Index propertyIndex = connector->GetPropertyIndex();
+
+ if ( valueType == Property::VECTOR3 )
+ {
+ Vector3 targetVector3 = connectorPair.targetValue.Get<Vector3>();
+
+ 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<float>();
+
+ 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
+ {
+ // Currently only FLOAT and VECTOR3 is supported for Target values in AnimateXXFunctions
+ DALI_LOG_WARNING("Animation::Play Unsupported Value Type provided as TargetValue\n");
+ }
+ }
+ }
+ }
+ }
+
// mAnimation is being used in a separate thread; queue a Play message
PlayAnimationMessage( mEventThreadServices, *mAnimation );
}
{
if ( ( Dali::Actor::Property::SIZE_WIDTH == targetPropertyIndex ) ||
( Dali::Actor::Property::SIZE_HEIGHT == targetPropertyIndex ) ||
- ( Dali::Actor::Property::SIZE_DEPTH == 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 ) )
{
- // Test whether this is actually an Actor
- Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
- if ( maybeActor )
- {
- // Notify the actor that its size is being animated
- maybeActor->NotifySizeAnimation( *this, destinationValue.Get<float>(), targetPropertyIndex );
- }
- }
- else if ( ( Dali::Actor::Property::POSITION_X == targetPropertyIndex ) ||
- ( Dali::Actor::Property::POSITION_Y == targetPropertyIndex ) ||
- ( Dali::Actor::Property::POSITION_Z == targetPropertyIndex ) )
- {
- // Test whether this is actually an Actor
+
Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
if ( maybeActor )
{
- // Notify the actor that its position is being animated
- maybeActor->NotifyPositionAnimation( *this, destinationValue.Get<float>(), targetPropertyIndex );
+ // 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 );
}
}
case Property::VECTOR3:
{
- if ( Dali::Actor::Property::SIZE == targetPropertyIndex )
+ if ( Dali::Actor::Property::SIZE == targetPropertyIndex || Dali::Actor::Property::POSITION == targetPropertyIndex )
{
// Test whether this is actually an Actor
Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
if ( maybeActor )
{
- // Notify the actor that its size is being animated
- maybeActor->NotifySizeAnimation( *this, destinationValue.Get<Vector3>() );
- }
- }
- else if ( Dali::Actor::Property::POSITION == targetPropertyIndex )
- {
- // Test whether this is actually an Actor
- Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
- if ( maybeActor )
- {
- // Notify the actor that its position is being animated
- maybeActor->NotifyPositionAnimation( *this, destinationValue.Get<Vector3>() );
+ // 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 );
}
}