[5.0] Add IsPositionOrSizeCurrentlyAnimating Actor devel API. 58/195458/2 accepted/tizen/5.0/unified/20181214.110738 submit/tizen_5.0/20181214.042026
authorAnton Obzhirov <a.obzhirov@samsung.com>
Thu, 13 Dec 2018 13:04:16 +0000 (13:04 +0000)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 14 Dec 2018 02:33:59 +0000 (11:33 +0900)
Change-Id: I81c0e681134b9d2601fb9b68785e09c0b222c022

13 files changed:
automated-tests/src/dali/utc-Dali-Animation.cpp
dali/devel-api/actors/actor-devel.cpp
dali/devel-api/actors/actor-devel.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animation-impl.h
dali/internal/event/common/object-impl.cpp
dali/internal/event/common/object-impl.h
dali/internal/event/render-tasks/render-task-impl.cpp
dali/internal/event/render-tasks/render-task-impl.h
dali/internal/event/rendering/renderer-impl.cpp
dali/internal/event/rendering/renderer-impl.h

index 83f3bad..0292620 100644 (file)
@@ -13115,3 +13115,47 @@ int UtcDaliAnimationAnimateBetweenInvalidParameters(void)
 
   END_TEST;
 }
+
+int UtcDaliAnimationIsPositionOrSizeCurrentlyAnimating(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+
+  // Build the animation
+  float durationSeconds(1.0f);
+  Animation animation = Animation::New(durationSeconds);
+  DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
+
+  // Start the animation
+  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+  animation.Play();
+
+  DALI_TEST_EQUALS( true, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+
+  bool signalReceived(false);
+  AnimationFinishCheck finishCheck(signalReceived);
+  animation.FinishedSignal().Connect(&application, finishCheck);
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
+
+  // We didn't expect the animation to finish yet
+  application.SendNotification();
+  finishCheck.CheckSignalNotReceived();
+
+  DALI_TEST_EQUALS( true, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+
+  application.Render(2u/*just beyond the animation duration*/);
+
+  // We did expect the animation to finish
+  application.SendNotification();
+  finishCheck.CheckSignalReceived();
+
+  DALI_TEST_EQUALS( false, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
+  END_TEST;
+}
index 9e89f7c..225a3cc 100644 (file)
@@ -45,7 +45,10 @@ ChildOrderChangedSignalType& ChildOrderChangedSignal( Actor actor )
   return GetImplementation( actor ).ChildOrderChangedSignal();
 }
 
-
+bool IsPositionOrSizeCurrentlyAnimating( Actor actor )
+{
+  return GetImplementation( actor ).IsPositionOrSizeCurrentlyAnimating();
+}
 
 } // namespace DevelActor
 
index 5a030a9..74f7488 100644 (file)
@@ -219,6 +219,11 @@ typedef Signal< void (Actor) > ChildOrderChangedSignalType; ///< Used when the a
  */
 DALI_CORE_API ChildOrderChangedSignalType& ChildOrderChangedSignal( Actor actor );
 
+/**
+ * @brief Returns weather the actor position or size are being animated
+ * @return The actor position or size are currently animating
+ */
+DALI_CORE_API bool IsPositionOrSizeCurrentlyAnimating( Actor actor );
 
 
 } // namespace DevelActor
index 37baa3b..6adea53 100644 (file)
@@ -2053,6 +2053,7 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
   mName(),
   mSortedDepth( 0u ),
   mDepth( 0u ),
+  mPositionOrSizeAnimatingCount( 0 ),
   mIsRoot( ROOT_LAYER == derivedType ),
   mIsLayer( LAYER == derivedType || ROOT_LAYER == derivedType ),
   mIsOnStage( false ),
@@ -2936,8 +2937,29 @@ Property::Value Actor::GetDefaultPropertyCurrentValue( Property::Index index ) c
   return value;
 }
 
-void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
 {
+  switch ( index )
+  {
+    case Dali::Actor::Property::SIZE:
+    case Dali::Actor::Property::SIZE_WIDTH:
+    case Dali::Actor::Property::SIZE_HEIGHT:
+    case Dali::Actor::Property::SIZE_DEPTH:
+    case Dali::Actor::Property::POSITION:
+    case Dali::Actor::Property::POSITION_X:
+    case Dali::Actor::Property::POSITION_Y:
+    case Dali::Actor::Property::POSITION_Z:
+    {
+      mPositionOrSizeAnimatingCount += ( animationStarted ? 1 : -1 );
+    }
+    break;
+  }
+
+  if( !animationStarted )
+  {
+    return;
+  }
+
   switch( animationType )
   {
     case Animation::TO:
@@ -5151,6 +5173,11 @@ void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::LayoutDirec
   }
 }
 
+bool Actor::IsPositionOrSizeCurrentlyAnimating()
+{
+  return mPositionOrSizeAnimatingCount != 0;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index 0a78f08..2f75faa 100755 (executable)
@@ -1659,7 +1659,7 @@ public:
   /**
    * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
 
   /**
    * @copydoc Dali::Internal::Object::GetPropertyOwner()
@@ -1725,6 +1725,12 @@ public:
    */
   void LowerBelow( Internal::Actor& target );
 
+  /**
+   * @brief Checks if the size or position is currently animating.
+   * @return true if the actor position or size are currently animating.
+   */
+  bool IsPositionOrSizeCurrentlyAnimating();
+
 private:
 
   struct SendMessage
@@ -1969,6 +1975,7 @@ protected:
   std::string     mName;              ///< Name of the actor
   uint32_t        mSortedDepth;       ///< The sorted depth index. A combination of tree traversal and sibling order.
   int16_t         mDepth;             ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
+  int32_t         mPositionOrSizeAnimatingCount;    ///< The current count of ongoing animations
 
   const bool mIsRoot                               : 1; ///< Flag to identify the root actor
   const bool mIsLayer                              : 1; ///< Flag to identify that this is a layer
index 587a96a..55c1923 100644 (file)
@@ -329,7 +329,7 @@ void Animation::Play()
 
   mState = Dali::Animation::PLAYING;
 
-  NotifyObjects();
+  NotifyObjects( true );
 
   SendFinalProgressNotificationMessage();
 
@@ -346,7 +346,7 @@ void Animation::PlayFrom( float progress )
 
     mState = Dali::Animation::PLAYING;
 
-    NotifyObjects();
+    NotifyObjects( true );
 
     SendFinalProgressNotificationMessage();
 
@@ -367,7 +367,7 @@ void Animation::PlayAfter( float delaySeconds )
 
   mState = Dali::Animation::PLAYING;
 
-  NotifyObjects();
+  NotifyObjects( true );
 
   SendFinalProgressNotificationMessage();
 
@@ -859,6 +859,11 @@ Dali::Animation::AnimationSignalType& Animation::ProgressReachedSignal()
 
 void Animation::EmitSignalFinish()
 {
+  if ( !mConnectors.Empty() )
+  {
+    NotifyObjects( false );
+  }
+
   if ( !mFinishedSignal.Empty() )
   {
     Dali::Animation handle( this );
@@ -1083,7 +1088,7 @@ 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( bool animationStarted )
 {
   if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
   {
@@ -1100,7 +1105,7 @@ void Animation::NotifyObjects()
       Object* object = connector->GetObject();
       if( object )
       {
-        object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType );
+        object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType, animationStarted );
       }
     }
   }
index c605ec2..6f44b25 100644 (file)
@@ -502,8 +502,9 @@ private:
 
   /**
    * Notifies all the objects whose properties are being animated.
+   * @param[in] animationStarted The animation is started
    */
-  void NotifyObjects();
+  void NotifyObjects( bool animationStarted );
 
   /**
    * Sends message to SceneGraph with final progress value
index 5e68a6e..a598bb2 100644 (file)
@@ -726,44 +726,47 @@ void Object::RemovePropertyNotifications()
   }
 }
 
-void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
 {
-  if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+  if( index < DEFAULT_PROPERTY_MAX_COUNT )
   {
-    OnNotifyDefaultPropertyAnimation( animation, index, value, animationType );
+    OnNotifyDefaultPropertyAnimation( animation, index, value, animationType, animationStarted );
   }
   else
   {
-    PropertyMetadata* propertyMetadata = NULL;
-    if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
-    {
-      propertyMetadata = FindAnimatableProperty( index );
-    }
-    else
+    if( animationStarted )
     {
-      CustomPropertyMetadata* custom = FindCustomProperty( index );
-      if( custom && custom->IsAnimatable() )
+      PropertyMetadata* propertyMetadata = NULL;
+      if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
       {
-        propertyMetadata = custom;
+        propertyMetadata = FindAnimatableProperty( index );
       }
-    }
-
-    if( propertyMetadata )
-    {
-      switch( animationType )
+      else
       {
-        case Animation::TO:
-        case Animation::BETWEEN:
+        CustomPropertyMetadata* custom = FindCustomProperty( index );
+        if( custom && custom->IsAnimatable() )
         {
-          // Update the cached property value
-          propertyMetadata->SetPropertyValue( value );
-          break;
+          propertyMetadata = custom;
         }
-        case Animation::BY:
+      }
+
+      if( propertyMetadata )
+      {
+        switch( animationType )
         {
-          // Adjust the cached property value
-          propertyMetadata->AdjustPropertyValueBy( value );
-          break;
+          case Animation::TO:
+          case Animation::BETWEEN:
+          {
+            // Update the cached property value
+            propertyMetadata->SetPropertyValue( value );
+            break;
+          }
+          case Animation::BY:
+          {
+            // Adjust the cached property value
+            propertyMetadata->AdjustPropertyValueBy( value );
+            break;
+          }
         }
       }
     }
index 889d589..c39bd1c 100644 (file)
@@ -262,8 +262,9 @@ public:
    * @param[in] index The index of the property.
    * @param[in] value The value of the property after the animation.
    * @param[in] animationType Whether the property value given is the target or a relative value.
+   * @param[in] animationStarted Whether the animation is started.
    */
-  void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+  void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
 
   /******************************** Uniform Mappings ********************************/
 
@@ -468,8 +469,9 @@ private: // Default property extensions for derived classes
    * @param[in] index The index of the property.
    * @param[in] value The value of the property after the animation.
    * @param[in] animationType Whether the property value given is the target or a relative value.
+   * @param[in] animationStarted Whether the animation is started.
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType )
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType, bool animationStarted )
   { }
 
   /**
index a95703f..95bf70b 100644 (file)
@@ -614,67 +614,70 @@ Property::Value RenderTask::GetDefaultPropertyCurrentValue( Property::Index inde
   return value;
 }
 
-void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
 {
-  switch( animationType )
+  if( animationStarted )
   {
-    case Animation::TO:
-    case Animation::BETWEEN:
+    switch( animationType )
     {
-      switch ( index )
+      case Animation::TO:
+      case Animation::BETWEEN:
       {
-        case Dali::RenderTask::Property::VIEWPORT_POSITION:
+        switch ( index )
         {
-          value.Get( mViewportPosition );
-          break;
-        }
-        case Dali::RenderTask::Property::VIEWPORT_SIZE:
-        {
-          value.Get( mViewportSize );
-          break;
-        }
-        case Dali::RenderTask::Property::CLEAR_COLOR:
-        {
-          value.Get( mClearColor );
-          break;
-        }
-        case Dali::RenderTask::Property::REQUIRES_SYNC:
-        default:
-        {
-          // Nothing to do as not animatable
-          break;
+          case Dali::RenderTask::Property::VIEWPORT_POSITION:
+          {
+            value.Get( mViewportPosition );
+            break;
+          }
+          case Dali::RenderTask::Property::VIEWPORT_SIZE:
+          {
+            value.Get( mViewportSize );
+            break;
+          }
+          case Dali::RenderTask::Property::CLEAR_COLOR:
+          {
+            value.Get( mClearColor );
+            break;
+          }
+          case Dali::RenderTask::Property::REQUIRES_SYNC:
+          default:
+          {
+            // Nothing to do as not animatable
+            break;
+          }
         }
+        break;
       }
-      break;
-    }
 
-    case Animation::BY:
-    {
-      switch ( index )
+      case Animation::BY:
       {
-        case Dali::RenderTask::Property::VIEWPORT_POSITION:
-        {
-          AdjustValue< Vector2 >( mViewportPosition, value );
-          break;
-        }
-        case Dali::RenderTask::Property::VIEWPORT_SIZE:
-        {
-          AdjustValue< Vector2 >( mViewportSize, value );
-          break;
-        }
-        case Dali::RenderTask::Property::CLEAR_COLOR:
+        switch ( index )
         {
-          AdjustValue< Vector4 >( mClearColor, value );
-          break;
-        }
-        case Dali::RenderTask::Property::REQUIRES_SYNC:
-        default:
-        {
-          // Nothing to do as not animatable
-          break;
+          case Dali::RenderTask::Property::VIEWPORT_POSITION:
+          {
+            AdjustValue< Vector2 >( mViewportPosition, value );
+            break;
+          }
+          case Dali::RenderTask::Property::VIEWPORT_SIZE:
+          {
+            AdjustValue< Vector2 >( mViewportSize, value );
+            break;
+          }
+          case Dali::RenderTask::Property::CLEAR_COLOR:
+          {
+            AdjustValue< Vector4 >( mClearColor, value );
+            break;
+          }
+          case Dali::RenderTask::Property::REQUIRES_SYNC:
+          default:
+          {
+            // Nothing to do as not animatable
+            break;
+          }
         }
+        break;
       }
-      break;
     }
   }
 }
index 8b9f8aa..d268b7b 100644 (file)
@@ -278,7 +278,7 @@ public: // Implementation of Object
   /**
    * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
    */
-  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+  virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
 
   /**
    * @copydoc Dali::Internal::Object::GetSceneObject()
index 2f66002..2e9e98e 100644 (file)
@@ -637,35 +637,38 @@ Property::Value Renderer::GetDefaultPropertyCurrentValue( Property::Index index
   return value;
 }
 
-void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
 {
-  switch( animationType )
+  if( animationStarted )
   {
-    case Animation::TO:
-    case Animation::BETWEEN:
+    switch( animationType )
     {
-      switch( index )
+      case Animation::TO:
+      case Animation::BETWEEN:
       {
-        case Dali::DevelRenderer::Property::OPACITY:
+        switch( index )
         {
-          value.Get( mOpacity );
-          break;
+          case Dali::DevelRenderer::Property::OPACITY:
+          {
+            value.Get( mOpacity );
+            break;
+          }
         }
+        break;
       }
-      break;
-    }
 
-    case Animation::BY:
-    {
-      switch( index )
+      case Animation::BY:
       {
-        case Dali::DevelRenderer::Property::OPACITY:
+        switch( index )
         {
-          AdjustValue< float >( mOpacity, value );
-          break;
+          case Dali::DevelRenderer::Property::OPACITY:
+          {
+            AdjustValue< float >( mOpacity, value );
+            break;
+          }
         }
+        break;
       }
-      break;
     }
   }
 }
index f02d39c..207b33d 100755 (executable)
@@ -192,7 +192,7 @@ public: // Default property extensions from Object
    /**
     * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
     */
-   virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+   virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
 
   /**
    * @copydoc Dali::Internal::Object::GetPropertyOwner()