Property::Index index = actor.RegisterProperty("anIndex", startValue);
DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< int >( actor, index ), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
// Start the animation
animation.Play();
+ // Target value should be retrievable straight away
+ DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
+
bool signalReceived(false);
AnimationFinishCheck finishCheck(signalReceived);
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
finishCheck.CheckSignalReceived();
DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< int >( actor, index ), 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
END_TEST;
}
application.Render();
DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ 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( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
+
+ //////////////////////////////////////////////////////////////////////////////////
tet_infoline( "With two AnimateTo calls" );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
animation.Play();
+ tet_infoline( "The target position should change instantly" );
+ DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
+
application.SendNotification();
application.Render(5000); // After the animation is complete
DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
+
+ //////////////////////////////////////////////////////////////////////////////////
tet_infoline( "Same animation again but in a different order - should yield the same result" );
actor.SetX( 0.0f );
+ 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 );
+
application.SendNotification();
application.Render();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
+
animation = Animation::New( 0.0f );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
animation.Play();
+ tet_infoline( "The target position should change instantly" );
+ DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
+
application.SendNotification();
application.Render(5000); // After the animation is complete
DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
+
+ END_TEST;
+}
- tet_infoline( "Now with several AnimateTo calls" );
+int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
+{
+ tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place with several AnimateTo calls" );
+
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add( actor );
- actor.SetX( 0.0f );
application.SendNotification();
application.Render();
- animation = Animation::New( 0.0f );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ 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( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
+
+ //////////////////////////////////////////////////////////////////////////////////
+
+ tet_infoline( "" );
+
+ Animation animation = Animation::New( 0.0f );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
animation.Play();
+ tet_infoline( "The target position should change instantly" );
+ DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
+
application.SendNotification();
application.Render(14000); // After the animation is complete
DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
+
+ //////////////////////////////////////////////////////////////////////////////////
tet_infoline( "Same animation again but in a different order - should end up at the same point" );
actor.SetX( 0.0f );
+
+ 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 );
+
application.SendNotification();
application.Render();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
+
animation = Animation::New( 0.0f );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
animation.Play();
+ tet_infoline( "The target position should change instantly" );
+ DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
+
application.SendNotification();
application.Render(14000); // After the animation is complete
DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
END_TEST;
}
if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
{
- 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 ++)
- {
- // Use index to check if the current connector is next in the mConnectorTargetValues container, meaning targetValues have been pushed in AnimateXXFunction
- if ( connectorTargetValuesIndex < numberOfConnectorTargetValues )
- {
- ConnectorTargetValues& connectorPair = mConnectorTargetValues[ connectorTargetValuesIndex ];
+ // Sort according to end time with earlier end times coming first, if the end time is the same, then the connectors are not moved
+ std::stable_sort( mConnectorTargetValues.begin(), mConnectorTargetValues.end(), CompareConnectorEndTimes );
- 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 ];
+ // Loop through all connector target values sorted by increasing end time
+ ConnectorTargetValuesContainer::const_iterator iter = mConnectorTargetValues.begin();
+ const ConnectorTargetValuesContainer::const_iterator endIter = mConnectorTargetValues.end();
+ for( ; iter != endIter; ++iter )
+ {
+ AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
- Object* object = connector->GetObject();
- if( object )
- {
- object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), connectorPair.targetValue );
- }
- }
+ Object* object = connector->GetObject();
+ if( object )
+ {
+ object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue );
}
}
}
ConnectorTargetValues connectorPair;
connectorPair.targetValue = destinationValue;
connectorPair.connectorIndex = mConnectors.Count();
+ connectorPair.timePeriod = period;
mConnectorTargetValues.push_back( connectorPair );
switch ( destinationType )
return mPlayRange;
}
+bool Animation::CompareConnectorEndTimes( const Animation::ConnectorTargetValues& lhs, const Animation::ConnectorTargetValues& rhs )
+{
+ return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
+}
} // namespace Internal