Set AnimatedVectorVisual play range by single marker
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / animated-vector-image-visual.cpp
index ca3b93d..5d987b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -23,6 +23,7 @@
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/rendering/renderer-devel.h>
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/math/math-utils.h>
 #include <dali/public-api/rendering/decorated-visual-renderer.h>
 
 // INTERNAL INCLUDES
@@ -117,6 +118,7 @@ AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
     if(mEventCallback)
     {
       mFactoryCache.GetVectorAnimationManager().UnregisterEventCallback(mEventCallback);
+      mEventCallback = nullptr;
     }
 
     // Finalize animation task and disconnect the signal in the main thread
@@ -292,6 +294,17 @@ void AnimatedVectorImageVisual::DoSetProperty(Property::Index index, const Prope
         mAnimationData.playRange = *array;
         mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
       }
+      else if(value.GetType() == Property::STRING)
+      {
+        std::string markerName;
+        if(value.Get(markerName))
+        {
+          Property::Array array;
+          array.Add(markerName);
+          mAnimationData.playRange = std::move(array);
+          mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
+        }
+      }
       break;
     }
     case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
@@ -697,7 +710,7 @@ void AnimatedVectorImageVisual::OnScaleNotification(PropertyNotification& source
   {
     Vector3 scale = actor.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
 
-    if((mVisualScale.width != scale.width || mVisualScale.height != scale.height) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f))
+    if((!Dali::Equals(mVisualScale.width, scale.width) || !Dali::Equals(mVisualScale.height, scale.height)) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f))
     {
       mVisualScale.width  = scale.width;
       mVisualScale.height = scale.height;
@@ -719,7 +732,7 @@ void AnimatedVectorImageVisual::OnSizeNotification(PropertyNotification& source)
   {
     Vector3 size = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE);
 
-    if(mVisualSize.width != size.width || mVisualSize.height != size.height)
+    if(!Dali::Equals(mVisualSize.width, size.width) || !Dali::Equals(mVisualSize.height, size.height))
     {
       mVisualSize.width  = size.width;
       mVisualSize.height = size.height;