[Tizen] Do not call NotifyObjects in case of finished animations
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-impl.cpp
index 5dbb390..f1f981f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -77,61 +77,90 @@ TypeAction action1( mType, ACTION_PLAY,  &Animation::DoAction );
 TypeAction action2( mType, ACTION_STOP,  &Animation::DoAction );
 TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction );
 
-const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::Bake );
-const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BakeFinal );
-const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::Linear );
+const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::BAKE );
+const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BAKE_FINAL );
+const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::LINEAR );
 const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION( Dali::AlphaFunction::DEFAULT );
 
-} // anon namespace
-
-
-AnimationPtr Animation::New(float durationSeconds)
+/**
+ * Helper to tell if a property is animatable (if we have animators for it)
+ *
+ * @param type type to check
+ * @return true if animatable
+ */
+inline bool IsAnimatable( Property::Type type )
 {
-  Stage* stage = Stage::GetCurrent();
-
-  if( stage )
+  bool animatable = false;
+  switch( type )
   {
-    AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
-
-    if( durationSeconds < 0.0f )
+    case Property::BOOLEAN :
+    case Property::FLOAT :
+    case Property::INTEGER :
+    case Property::VECTOR2 :
+    case Property::VECTOR3 :
+    case Property::VECTOR4 :
+    case Property::ROTATION :
     {
-      DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
-      durationSeconds = 0.0f;
+      animatable = true;
+      break;
+    }
+    case Property::MATRIX : // matrix is allowed as a scene graph property but there's no animators for it
+    case Property::MATRIX3 : // matrix3 is allowed as a scene graph property but there's no animators for it
+    case Property::NONE :
+    case Property::RECTANGLE :
+    case Property::STRING :
+    case Property::ARRAY :
+    case Property::MAP :
+    case Property::EXTENTS :
+    {
+      break;
     }
+  }
+  return animatable;
+}
 
-    AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+/**
+ * Helper to validate animation input values
+ *
+ * @param propertyType type of the property that is being animated
+ * @param destinationType type of the target
+ * @param period time period of the animation
+ */
+void ValidateParameters( Property::Type propertyType, Property::Type destinationType, const TimePeriod& period )
+{
+  // destination value has to be animatable
+  DALI_ASSERT_ALWAYS( IsAnimatable( propertyType ) && "Property type is not animatable" );
+  DALI_ASSERT_ALWAYS( IsAnimatable( destinationType ) && "Target value is not animatable" );
+  DALI_ASSERT_ALWAYS( propertyType == destinationType && "Property and target types don't match" );
+  DALI_ASSERT_ALWAYS( period.durationSeconds >= 0 && "Duration must be >=0" );
+}
 
-    // Second-phase construction
-    animation->Initialize();
+} // anonymous namespace
 
-    return animation;
-  }
-  else
+AnimationPtr Animation::New(float durationSeconds)
+{
+  if( durationSeconds < 0.0f )
   {
-    return NULL;
+    DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
+    durationSeconds = 0.0f;
   }
+
+  ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+  AnimationPtr animation = new Animation( tls.GetEventThreadServices(), tls.GetAnimationPlaylist(), durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+
+  // Second-phase construction
+  animation->Initialize();
+
+  return animation;
 }
 
-Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
-: mAnimation( NULL ),
-  mEventThreadServices( eventThreadServices ),
-  mPlaylist( playlist ),
-  mFinishedSignal(),
-  mConnectors(),
-  mConnectorTargetValues(),
-  mPlayRange( Vector2(0.0f,1.0f)),
-  mDurationSeconds( durationSeconds ),
-  mSpeedFactor(1.0f),
-  mNotificationCount( 0 ),
-  mLoopCount(1),
-  mCurrentLoop(0),
-  mEndAction( endAction ),
-  mDisconnectAction( disconnectAction ),
-  mDefaultAlpha( defaultAlpha ),
-  mState(Dali::Animation::STOPPED),
-  mProgressReachedMarker( 0.0f ),
-  mDelaySeconds( 0.0f ),
-  mAutoReverseEnabled( false )
+Animation::Animation(EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha)
+: mEventThreadServices(eventThreadServices),
+  mPlaylist(playlist),
+  mDefaultAlpha(defaultAlpha),
+  mDurationSeconds(durationSeconds),
+  mEndAction(endAction),
+  mDisconnectAction(disconnectAction)
 {
 }
 
@@ -171,11 +200,11 @@ void Animation::CreateSceneObject()
 
 void Animation::DestroySceneObject()
 {
-  if ( mAnimation != NULL )
+  if ( mAnimation != nullptr )
   {
     // Remove animation using a message to the update manager
     RemoveAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
-    mAnimation = NULL;
+    mAnimation = nullptr;
   }
 }
 
@@ -215,7 +244,7 @@ void Animation::SetLooping(bool on)
   SetLoopCount( on ? 0 : 1 );
 }
 
-void Animation::SetLoopCount(int count)
+void Animation::SetLoopCount(int32_t count)
 {
   // Cache for public getters
   mLoopCount = count;
@@ -224,12 +253,12 @@ void Animation::SetLoopCount(int count)
   SetLoopingMessage( mEventThreadServices, *mAnimation, mLoopCount );
 }
 
-int Animation::GetLoopCount()
+int32_t Animation::GetLoopCount()
 {
   return mLoopCount;
 }
 
-int Animation::GetCurrentLoop()
+int32_t Animation::GetCurrentLoop()
 {
   return mCurrentLoop;
 }
@@ -276,7 +305,7 @@ void Animation::Play()
 
   mState = Dali::Animation::PLAYING;
 
-  NotifyObjects();
+  NotifyObjects( Notify::USE_TARGET_VALUE );
 
   SendFinalProgressNotificationMessage();
 
@@ -293,7 +322,7 @@ void Animation::PlayFrom( float progress )
 
     mState = Dali::Animation::PLAYING;
 
-    NotifyObjects();
+    NotifyObjects( Notify::USE_TARGET_VALUE );
 
     SendFinalProgressNotificationMessage();
 
@@ -314,7 +343,7 @@ void Animation::PlayAfter( float delaySeconds )
 
   mState = Dali::Animation::PLAYING;
 
-  NotifyObjects();
+  NotifyObjects( Notify::USE_TARGET_VALUE );
 
   SendFinalProgressNotificationMessage();
 
@@ -328,6 +357,9 @@ void Animation::Pause()
 
   // mAnimation is being used in a separate thread; queue a Pause message
   PauseAnimationMessage( mEventThreadServices, *mAnimation );
+
+  // Notify the objects with the _paused_, i.e. current values
+  NotifyObjects( Notify::FORCE_CURRENT_VALUE );
 }
 
 Dali::Animation::State Animation::GetState() const
@@ -341,12 +373,24 @@ void Animation::Stop()
 
   // mAnimation is being used in a separate thread; queue a Stop message
   StopAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
+
+  // Only notify the objects with the _stopped_, i.e. current values if the end action is set to BAKE
+  if( mEndAction == EndAction::BAKE )
+  {
+    NotifyObjects( Notify::USE_CURRENT_VALUE );
+  }
 }
 
 void Animation::Clear()
 {
   DALI_ASSERT_DEBUG(mAnimation);
 
+  // Only notify the objects with the current values if the end action is set to BAKE
+  if(mEndAction == EndAction::BAKE && mState != Dali::Animation::STOPPED)
+  {
+    NotifyObjects( Notify::USE_CURRENT_VALUE );
+  }
+
   // Remove all the connectors
   mConnectors.Clear();
 
@@ -364,47 +408,38 @@ void Animation::Clear()
   mPlaylist.OnClear( *this );
 }
 
-void Animation::AnimateBy(Property& target, Property::Value& relativeValue)
+void Animation::AnimateBy(Property& target, Property::Value relativeValue)
 {
-  AnimateBy(target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
+  AnimateBy(target, std::move(relativeValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha)
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha)
 {
-  AnimateBy(target, relativeValue, alpha, TimePeriod(mDurationSeconds));
+  AnimateBy(target, std::move(relativeValue), alpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period)
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, TimePeriod period)
 {
-  AnimateBy(target, relativeValue, mDefaultAlpha, period);
+  AnimateBy(target, std::move(relativeValue), mDefaultAlpha, period);
 }
 
-void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period)
+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);
+  const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
   const Property::Type destinationType = relativeValue.GetType();
 
-  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");
-  }
+  // validate animation parameters, if component index is set then use float as checked type
+  ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+                      destinationType, period );
 
   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 )
+  // keep the current count.
+  auto connectorIndex = mConnectors.Count();
+
+  // using destination type so component animation gets correct type
+  switch ( destinationType )
   {
     case Property::BOOLEAN:
     {
@@ -419,12 +454,12 @@ void Animation::AnimateBy(Property& target, Property::Value& relativeValue, Alph
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int>::New( object,
-                                                         target.propertyIndex,
-                                                         target.componentIndex,
-                                                         new AnimateByInteger(relativeValue.Get<int>()),
-                                                         alpha,
-                                                         period ) );
+      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
+                                                             target.propertyIndex,
+                                                             target.componentIndex,
+                                                             new AnimateByInteger(relativeValue.Get<int32_t>()),
+                                                             alpha,
+                                                             period ) );
       break;
     }
 
@@ -487,65 +522,51 @@ void Animation::AnimateBy(Property& target, Property::Value& relativeValue, Alph
 
     default:
     {
-      // non animatable types handled already
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
+  // Store data to later notify the object that its property is being animated
+  mConnectorTargetValues.push_back({std::move(relativeValue), period, connectorIndex, Animation::BY});
 }
 
-void Animation::AnimateTo(Property& target, Property::Value& destinationValue)
+void Animation::AnimateTo(Property& target, Property::Value destinationValue)
 {
-  AnimateTo(target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
+  AnimateTo(target, std::move(destinationValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha)
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha)
 {
-  AnimateTo(target, destinationValue, alpha, TimePeriod(mDurationSeconds));
+  AnimateTo(target, std::move(destinationValue), alpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period)
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, TimePeriod period)
 {
-  AnimateTo(target, destinationValue, mDefaultAlpha, period);
+  AnimateTo(target, std::move(destinationValue), mDefaultAlpha, period);
 }
 
-void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
 {
-  Object& object = GetImplementation(target.object);
-
-  AnimateTo( object, target.propertyIndex, target.componentIndex, destinationValue, alpha, period );
-}
-
-void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
-{
-  Property::Type targetType = targetObject.GetPropertyType(targetPropertyIndex);
-  if( componentIndex != Property::INVALID_COMPONENT_INDEX )
-  {
-    if( ( targetType == Property::VECTOR2 ) ||
-        ( targetType == Property::VECTOR3 ) ||
-        ( targetType == Property::VECTOR4 ) )
-    {
-      targetType = Property::FLOAT;
-    }
-  }
+  Object& object = GetImplementation( target.object );
+  const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
   const Property::Type destinationType = destinationValue.GetType();
-  DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
+
+  // validate animation parameters, if component index is set then use float as checked type
+  ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+                      destinationType, period );
 
   ExtendDuration( period );
 
-  // Store data to later notify the object that its property is being animated
-  ConnectorTargetValues connectorPair;
-  connectorPair.targetValue = destinationValue;
-  connectorPair.connectorIndex = mConnectors.Count();
-  connectorPair.timePeriod = period;
-  connectorPair.animatorType = Animation::TO;
-  mConnectorTargetValues.push_back( connectorPair );
+  // keep the current count.
+  auto connectorIndex = mConnectors.Count();
 
+  // using destination type so component animation gets correct type
   switch ( destinationType )
   {
     case Property::BOOLEAN:
     {
-      AddAnimatorConnector( AnimatorConnector<bool>::New( targetObject,
-                                                          targetPropertyIndex,
-                                                          componentIndex,
+      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
+                                                          target.propertyIndex,
+                                                          target.componentIndex,
                                                           new AnimateToBoolean( destinationValue.Get<bool>() ),
                                                           alpha,
                                                           period ) );
@@ -554,20 +575,20 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int>::New( targetObject,
-                                                         targetPropertyIndex,
-                                                         componentIndex,
-                                                         new AnimateToInteger( destinationValue.Get<int>() ),
-                                                         alpha,
-                                                         period ) );
+      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
+                                                             target.propertyIndex,
+                                                             target.componentIndex,
+                                                             new AnimateToInteger( destinationValue.Get<int32_t>() ),
+                                                             alpha,
+                                                             period ) );
       break;
     }
 
     case Property::FLOAT:
     {
-      AddAnimatorConnector( AnimatorConnector<float>::New( targetObject,
-                                                           targetPropertyIndex,
-                                                           componentIndex,
+      AddAnimatorConnector( AnimatorConnector<float>::New( object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
                                                            new AnimateToFloat( destinationValue.Get<float>() ),
                                                            alpha,
                                                            period ) );
@@ -576,9 +597,9 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::VECTOR2:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( targetObject,
-                                                             targetPropertyIndex,
-                                                             componentIndex,
+      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
+                                                             target.propertyIndex,
+                                                             target.componentIndex,
                                                              new AnimateToVector2( destinationValue.Get<Vector2>() ),
                                                              alpha,
                                                              period ) );
@@ -587,9 +608,9 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::VECTOR3:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( targetObject,
-                                                             targetPropertyIndex,
-                                                             componentIndex,
+      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
+                                                             target.propertyIndex,
+                                                             target.componentIndex,
                                                              new AnimateToVector3( destinationValue.Get<Vector3>() ),
                                                              alpha,
                                                              period ) );
@@ -598,9 +619,9 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::VECTOR4:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( targetObject,
-                                                             targetPropertyIndex,
-                                                             componentIndex,
+      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
+                                                             target.propertyIndex,
+                                                             target.componentIndex,
                                                              new AnimateToVector4( destinationValue.Get<Vector4>() ),
                                                              alpha,
                                                              period ) );
@@ -609,9 +630,9 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::ROTATION:
     {
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( targetObject,
-                                                                targetPropertyIndex,
-                                                                componentIndex,
+      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
+                                                                target.propertyIndex,
+                                                                target.componentIndex,
                                                                 new RotateToQuaternion( destinationValue.Get<Quaternion>() ),
                                                                 alpha,
                                                                 period ) );
@@ -620,61 +641,65 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     default:
     {
-      // non animatable types handled already
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
+  // Store data to later notify the object that its property is being animated
+  mConnectorTargetValues.push_back({std::move(destinationValue), period, connectorIndex, Animation::TO});
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames )
 {
-  AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
+  AnimateBetween( target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation )
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Interpolation interpolation )
 {
-  AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation );
+  AnimateBetween( target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, TimePeriod period )
 {
-  AnimateBetween(target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION);
+  AnimateBetween( target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation )
 {
-  AnimateBetween(target, keyFrames, mDefaultAlpha, period, interpolation);
+  AnimateBetween( target, keyFrames, mDefaultAlpha, period, interpolation );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha )
 {
-  AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION);
+  AnimateBetween( target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation )
 {
-  AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation);
+  AnimateBetween( target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period )
 {
-  AnimateBetween(target, keyFrames, alpha, period, DEFAULT_INTERPOLATION);
+  AnimateBetween( target, keyFrames, alpha, period, DEFAULT_INTERPOLATION );
 }
 
-void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
+void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation )
 {
   Object& object = GetImplementation( target.object );
+  const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
+  const Property::Type destinationType = keyFrames.GetType();
+
+  // validate animation parameters, if component index is set then use float as checked type
+  ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+                      destinationType, period );
 
   ExtendDuration( period );
 
   // Store data to later notify the object that its property is being animated
-  ConnectorTargetValues connectorPair;
-  connectorPair.targetValue = keyFrames.GetLastKeyFrameValue();
-  connectorPair.connectorIndex = mConnectors.Count();
-  connectorPair.timePeriod = period;
-  connectorPair.animatorType = BETWEEN;
-  mConnectorTargetValues.push_back( connectorPair );
-
-  switch(keyFrames.GetType())
+  mConnectorTargetValues.push_back({keyFrames.GetLastKeyFrameValue(), period, mConnectors.Count(), BETWEEN});
+
+  // using destination type so component animation gets correct type
+  switch( destinationType )
   {
     case Dali::Property::BOOLEAN:
     {
@@ -695,7 +720,7 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Alph
       const KeyFrameInteger* kf;
       GetSpecialization(keyFrames, kf);
       KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<int>::New( object,
+      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
                                                          target.propertyIndex,
                                                          target.componentIndex,
                                                          new KeyFrameIntegerFunctor(kfCopy,interpolation),
@@ -776,7 +801,7 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Alph
 
     default:
     {
-      // non animatable types handled by keyframes
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
 }
@@ -784,7 +809,7 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Alph
 bool Animation::HasFinished()
 {
   bool hasFinished(false);
-  const int playedCount(mAnimation->GetPlayedCount());
+  const int32_t playedCount(mAnimation->GetPlayedCount());
 
   // If the play count has been incremented, then another notification is required
   mCurrentLoop = mAnimation->GetCurrentLoop();
@@ -1038,12 +1063,17 @@ bool Animation::CompareConnectorEndTimes( const Animation::ConnectorTargetValues
   return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
 }
 
-void Animation::NotifyObjects()
+void Animation::NotifyObjects( Animation::Notify notifyValueType )
 {
-  if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
+  // If the animation is discarded, then we do not want to change the target values unless we want to force the current values
+  if( mEndAction != EndAction::DISCARD || notifyValueType == Notify::FORCE_CURRENT_VALUE )
   {
     // 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 );
+    // Only do this if we're using the target value
+    if( notifyValueType == Notify::USE_TARGET_VALUE )
+    {
+      std::stable_sort( mConnectorTargetValues.begin(), mConnectorTargetValues.end(), CompareConnectorEndTimes );
+    }
 
     // Loop through all connector target values sorted by increasing end time
     ConnectorTargetValuesContainer::const_iterator iter = mConnectorTargetValues.begin();
@@ -1053,9 +1083,14 @@ void Animation::NotifyObjects()
       AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
 
       Object* object = connector->GetObject();
-      if( object )
+      if(object && object->IsAnimationPossible())
       {
-        object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType );
+        const auto propertyIndex = connector->GetPropertyIndex();
+        object->NotifyPropertyAnimation(
+          *this,
+          propertyIndex,
+          ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->targetValue  : object->GetCurrentProperty( propertyIndex ),
+          ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->animatorType : Animation::TO ); // If we're setting the current value, then use TO as we want to set, not adjust, the current value
       }
     }
   }