[Tizen] (Animation) Ensure AnimateBetween updates the cached event-side properties 77/130277/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Sat, 20 May 2017 03:08:52 +0000 (04:08 +0100)
committerHeeyong Song <heeyong.song@samsung.com>
Sat, 20 May 2017 04:20:58 +0000 (13:20 +0900)
Change-Id: I8d83611eebf8e9bdca7dd9390a207924706eeb97

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

index 3789489..6a1cc97 100644 (file)
@@ -8482,6 +8482,9 @@ int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
   // Start the animation
   animation.Play();
 
+  // Final key frame value should be retrievable straight away
+  DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
+
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
   animation.FinishedSignal().Connect(&application, finishCheck);
index 2b0bf2e..69c0040 100644 (file)
@@ -640,6 +640,14 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Alph
 
   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.propertyChangeType = Object::PropertyChange::SET;
+  mConnectorTargetValues.push_back( connectorPair );
+
   switch(keyFrames.GetType())
   {
     case Dali::Property::BOOLEAN:
index 031495e..d0ad603 100644 (file)
@@ -23,6 +23,22 @@ namespace Dali
 namespace Internal
 {
 
+namespace
+{
+
+/// Helper to retrieve the value of the final key frame
+template< typename PropertyType, typename KeyFrameType >
+inline void GetLastKeyFrameValueInternal( const IntrusivePtr< KeyFrameSpec >& keyFrames, Property::Value& value )
+{
+  KeyFrameType* kf = static_cast< KeyFrameType* >( keyFrames.Get() );
+  float time = 0;
+  PropertyType actualValue;
+  kf->GetKeyFrame( kf->GetNumberOfKeyFrames() - 1, time, actualValue );
+  value = actualValue;
+}
+
+} // unnamed namespace
+
 KeyFrames* KeyFrames::New()
 {
   return new KeyFrames();
@@ -160,5 +176,54 @@ KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
   return mKeyFrames.Get();
 }
 
+Property::Value KeyFrames::GetLastKeyFrameValue() const
+{
+  Property::Value value;
+
+  switch(mType)
+  {
+    case Property::BOOLEAN:
+    {
+      GetLastKeyFrameValueInternal< bool, KeyFrameBoolean >( mKeyFrames, value );
+      break;
+    }
+    case Property::INTEGER:
+    {
+      GetLastKeyFrameValueInternal< int, KeyFrameInteger >( mKeyFrames, value );
+      break;
+    }
+    case Property::FLOAT:
+    {
+      GetLastKeyFrameValueInternal< float, KeyFrameNumber >( mKeyFrames, value );
+      break;
+    }
+    case Property::VECTOR2:
+    {
+      GetLastKeyFrameValueInternal< Vector2, KeyFrameVector2 >( mKeyFrames, value );
+      break;
+    }
+    case Property::VECTOR3:
+    {
+      GetLastKeyFrameValueInternal< Vector3, KeyFrameVector3 >( mKeyFrames, value );
+      break;
+    }
+    case Property::VECTOR4:
+    {
+      GetLastKeyFrameValueInternal< Vector4, KeyFrameVector4 >( mKeyFrames, value );
+      break;
+    }
+    case Property::ROTATION:
+    {
+      GetLastKeyFrameValueInternal< Quaternion, KeyFrameQuaternion >( mKeyFrames, value );
+      break;
+    }
+    default:
+      DALI_ASSERT_DEBUG(!"Type not supported");
+      break;
+  }
+
+  return value;
+}
+
 } // Internal
 } // Dali
index 433d2bc..52d9384 100644 (file)
@@ -95,6 +95,11 @@ public:
    */
   KeyFrameSpec* GetKeyFramesBase() const;
 
+  /**
+   * Return the value of the last key frame.
+   */
+  Dali::Property::Value GetLastKeyFrameValue() const;
+
 private:
   Dali::Property::Type mType; // Type of the specialization
   IntrusivePtr<KeyFrameSpec> mKeyFrames;   // Pointer to the specialized key frame object