(Animation) Ensure PlayFrom updates the cached event-side properties 99/131099/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 25 May 2017 10:42:06 +0000 (11:42 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 26 May 2017 11:25:10 +0000 (12:25 +0100)
Change-Id: Id5dd3a1e78fabc7c426b81e3909738bbc1887040

automated-tests/src/dali/utc-Dali-Animation.cpp
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animation-impl.h

index 5b56b88..01180b8 100644 (file)
@@ -2362,6 +2362,8 @@ int UtcDaliAnimationPlayFromP(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
+
   // Build the animation
   float durationSeconds(1.0f);
   Animation animation = Animation::New(durationSeconds);
@@ -2371,6 +2373,9 @@ int UtcDaliAnimationPlayFromP(void)
   // Start the animation from 40% progress
   animation.PlayFrom( 0.4f );
 
+  // Target value should be updated straight away
+  DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
index 83837ea..c87941d 100644 (file)
@@ -267,25 +267,7 @@ void Animation::Play()
 
   mState = Dali::Animation::PLAYING;
 
-  if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
-  {
-    // 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 );
-
-    // 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(), iter->targetValue, iter->animatorType );
-      }
-    }
-  }
+  NotifyObjects();
 
   // mAnimation is being used in a separate thread; queue a Play message
   PlayAnimationMessage( mEventThreadServices, *mAnimation );
@@ -300,6 +282,8 @@ void Animation::PlayFrom( float progress )
 
     mState = Dali::Animation::PLAYING;
 
+    NotifyObjects();
+
     // mAnimation is being used in a separate thread; queue a Play message
     PlayAnimationFromMessage( mEventThreadServices, *mAnimation, progress );
   }
@@ -997,6 +981,29 @@ bool Animation::CompareConnectorEndTimes( const Animation::ConnectorTargetValues
   return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
 }
 
+void Animation::NotifyObjects()
+{
+  if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
+  {
+    // 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 );
+
+    // 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(), iter->targetValue, iter->animatorType );
+      }
+    }
+  }
+}
+
 } // namespace Internal
 
 } // namespace Dali
index cc4ec12..c329a51 100644 (file)
@@ -475,6 +475,11 @@ private:
    */
   static bool CompareConnectorEndTimes( const ConnectorTargetValues& lhs, const ConnectorTargetValues& rhs );
 
+  /**
+   * Notifies all the objects whose properties are being animated.
+   */
+  void NotifyObjects();
+
 private:
 
   const SceneGraph::Animation* mAnimation;