}
Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
-: mEventThreadServices( eventThreadServices ),
+: mAnimation( NULL ),
+ mEventThreadServices( eventThreadServices ),
mPlaylist( playlist ),
- mAnimation( NULL ),
- mNotificationCount( 0 ),
- mFinishedCallback( NULL ),
- mFinishedCallbackObject( NULL ),
+ mFinishedSignal(),
+ mConnectors(),
+ mConnectorTargetValues(),
+ mPlayRange( Vector2(0.0f,1.0f)),
mDurationSeconds( durationSeconds ),
mSpeedFactor(1.0f),
+ mNotificationCount( 0 ),
mLoopCount(1),
mCurrentLoop(0),
- mPlayRange( Vector2(0.0f,1.0f)),
mEndAction( endAction ),
mDisconnectAction( disconnectAction ),
mDefaultAlpha( defaultAlpha ),
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 ];
-
- 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
+ // 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 );
- 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 )
Dali::Animation handle( this );
mFinishedSignal.Emit( handle );
}
-
- // This callback is used internally, to avoid the overhead of using a signal.
- if ( mFinishedCallback )
- {
- mFinishedCallback( mFinishedCallbackObject );
- }
}
bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
return connected;
}
-void Animation::SetFinishedCallback( FinishedCallback callback, Object* object )
-{
- mFinishedCallback = callback;
- mFinishedCallbackObject = object;
-}
-
void Animation::AddAnimatorConnector( AnimatorConnectorBase* connector )
{
DALI_ASSERT_DEBUG( NULL != connector );
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