[NUI] Refine KeyFrames PropertyValues with propertyValueConverter
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 2 Jul 2024 08:14:27 +0000 (17:14 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 10 Jul 2024 09:12:11 +0000 (18:12 +0900)
Let we allow to convert PropertyValue by propertyValueConverter when we
use AnimateBetween keyword by KeyFrames.

It will be useful when we animate some BackgroundColor or somethings
with Integer value.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/internal/Common/PropertyHelper.cs

index a63aa7d..8c5be95 100755 (executable)
@@ -294,18 +294,22 @@ namespace Tizen.NUI
                 var refined = keyFrames;
                 if (propertyValueConverter != null)
                 {
-                    // TODO Enable this code when csharp-binder is ready
-                    // refined = new KeyFrames();
-                    // for (uint i = 0; i < keyFrames.Count; i++)
-                    // {
-                    //     var keyFrame = keyFrames.GetKeyFrame(i);
-                    //     var newKeyFrame = propertyValueConverter(keyFrame);
-                    //     if (newKeyFrame == null)
-                    //     {
-                    //         return null;
-                    //     }
-                    //     refined.Add(newKeyFrame);
-                    // }
+                    uint keyFramesCount = keyFrames.GetKeyFrameCount();
+                    float keyFrameProgress;
+                    using PropertyValue keyFrameValue = new PropertyValue();
+
+                    refined = new KeyFrames();
+
+                    for (uint i = 0; i < keyFramesCount; i++)
+                    {
+                        keyFrames.GetKeyFrame(i, out keyFrameProgress, keyFrameValue);
+                        using var newKeyFrameValue = propertyValueConverter(keyFrameValue);
+                        if (newKeyFrameValue == null)
+                        {
+                            return null;
+                        }
+                        refined.Add(keyFrameProgress, newKeyFrameValue);
+                    }
                 }
 
                 return refined;