Return target size and position while retrieving default actor property value 01/54001/6
authorRichard Huang <r.huang@samsung.com>
Thu, 10 Dec 2015 16:18:31 +0000 (16:18 +0000)
committerRichard Huang <r.huang@samsung.com>
Fri, 11 Dec 2015 10:21:01 +0000 (10:21 +0000)
Change-Id: Ib8c947ce956dac73f059274a7f47db67cb6b08d9

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

index 72caae2..e38d61b 100644 (file)
@@ -5472,7 +5472,6 @@ int UtcDaliAnimationAnimateToActorSizeWidthP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
@@ -5517,7 +5516,6 @@ int UtcDaliAnimationAnimateToActorSizeHeightP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
@@ -5562,7 +5560,6 @@ int UtcDaliAnimationAnimateToActorSizeDepthP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
@@ -5760,9 +5757,6 @@ int UtcDaliAnimationAnimateToActorPositionXP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
@@ -5811,9 +5805,6 @@ int UtcDaliAnimationAnimateToActorPositionYP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
@@ -5862,9 +5853,6 @@ int UtcDaliAnimationAnimateToActorPositionZP(void)
   application.SendNotification();
   finishCheck.CheckSignalNotReceived();
   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
index 614c6e4..244508b 100644 (file)
@@ -1143,10 +1143,35 @@ void Actor::NotifySizeAnimation( Animation& animation, float targetSize, Propert
   {
     mTargetSize.height = targetSize;
   }
+  else if ( Dali::Actor::Property::SIZE_DEPTH == property )
+  {
+    mTargetSize.depth = targetSize;
+  }
   // Notify deriving classes
   OnSizeAnimation( animation, mTargetSize );
 }
 
+void Actor::NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition )
+{
+  mTargetPosition = targetPosition;
+}
+
+void Actor::NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property )
+{
+  if ( Dali::Actor::Property::POSITION_X == property )
+  {
+    mTargetPosition.x = targetPosition;
+  }
+  else if ( Dali::Actor::Property::POSITION_Y == property )
+  {
+    mTargetPosition.y = targetPosition;
+  }
+  else if ( Dali::Actor::Property::POSITION_Z == property )
+  {
+    mTargetPosition.z = targetPosition;
+  }
+}
+
 void Actor::SetWidth( float width )
 {
   if( NULL != mNode )
@@ -2754,49 +2779,49 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const
 
     case Dali::Actor::Property::SIZE:
     {
-      value = GetCurrentSize();
+      value = GetTargetSize();
       break;
     }
 
     case Dali::Actor::Property::SIZE_WIDTH:
     {
-      value = GetCurrentSize().width;
+      value = GetTargetSize().width;
       break;
     }
 
     case Dali::Actor::Property::SIZE_HEIGHT:
     {
-      value = GetCurrentSize().height;
+      value = GetTargetSize().height;
       break;
     }
 
     case Dali::Actor::Property::SIZE_DEPTH:
     {
-      value = GetCurrentSize().depth;
+      value = GetTargetSize().depth;
       break;
     }
 
     case Dali::Actor::Property::POSITION:
     {
-      value = GetCurrentPosition();
+      value = GetTargetPosition();
       break;
     }
 
     case Dali::Actor::Property::POSITION_X:
     {
-      value = GetCurrentPosition().x;
+      value = GetTargetPosition().x;
       break;
     }
 
     case Dali::Actor::Property::POSITION_Y:
     {
-      value = GetCurrentPosition().y;
+      value = GetTargetPosition().y;
       break;
     }
 
     case Dali::Actor::Property::POSITION_Z:
     {
-      value = GetCurrentPosition().z;
+      value = GetTargetPosition().z;
       break;
     }
 
index 9e78b79..362b0b5 100644 (file)
@@ -1454,10 +1454,11 @@ public:
   void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
 
   /**
-   * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT property is animated.
+   * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT or SIZE_DEPTH property is animated.
    *
    * @param[in] animation The animation that resized the actor
    * @param[in] targetSize The new target size of the actor
+   * @param[in] property The index of the property being animated
    */
   void NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property );
 
@@ -1469,6 +1470,23 @@ public:
   {
   }
 
+  /**
+   * This should only be called by Animation, when the actors POSITION property is animated.
+   *
+   * @param[in] animation The animation that repositioned the actor
+   * @param[in] targetPosition The new target position of the actor
+   */
+  void NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition );
+
+  /**
+   * This should only be called by Animation, when the actors POSITION_X or POSITION_Y or POSITION_Z property is animated.
+   *
+   * @param[in] animation The animation that repositioned the actor
+   * @param[in] targetPosition The new target position of the actor
+   * @param[in] property The index of the property being animated
+   */
+  void NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property );
+
 protected:
 
   enum DerivedType
index 0c92623..04e9ac9 100644 (file)
@@ -467,8 +467,9 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
 
     case Property::FLOAT:
     {
-      if ( ( Dali::Actor::Property::SIZE_WIDTH == targetPropertyIndex )||
-           ( Dali::Actor::Property::SIZE_HEIGHT == targetPropertyIndex ) )
+      if ( ( Dali::Actor::Property::SIZE_WIDTH == targetPropertyIndex ) ||
+           ( Dali::Actor::Property::SIZE_HEIGHT == targetPropertyIndex ) ||
+           ( Dali::Actor::Property::SIZE_DEPTH == targetPropertyIndex ) )
       {
         // Test whether this is actually an Actor
         Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
@@ -478,6 +479,19 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
           maybeActor->NotifySizeAnimation( *this, destinationValue.Get<float>(), targetPropertyIndex );
         }
       }
+      else if ( ( Dali::Actor::Property::POSITION_X == targetPropertyIndex ) ||
+                 ( Dali::Actor::Property::POSITION_Y == targetPropertyIndex ) ||
+                 ( Dali::Actor::Property::POSITION_Z == targetPropertyIndex ) )
+      {
+        // Test whether this is actually an Actor
+        Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
+        if ( maybeActor )
+        {
+          // Notify the actor that its position is being animated
+          maybeActor->NotifyPositionAnimation( *this, destinationValue.Get<float>(), targetPropertyIndex );
+        }
+      }
+
       AddAnimatorConnector( AnimatorConnector<float>::New( targetObject,
                                                            targetPropertyIndex,
                                                            componentIndex,
@@ -510,6 +524,16 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn
           maybeActor->NotifySizeAnimation( *this, destinationValue.Get<Vector3>() );
         }
       }
+      else if ( Dali::Actor::Property::POSITION == targetPropertyIndex )
+      {
+        // Test whether this is actually an Actor
+        Actor* maybeActor = dynamic_cast<Actor*>( &targetObject );
+        if ( maybeActor )
+        {
+          // Notify the actor that its position is being animated
+          maybeActor->NotifyPositionAnimation( *this, destinationValue.Get<Vector3>() );
+        }
+      }
 
       AddAnimatorConnector( AnimatorConnector<Vector3>::New( targetObject,
                                                              targetPropertyIndex,