From 559b8ce040018094f288ee8eb4d6ca7fd3bf5cf5 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 21 Jun 2023 12:36:02 +0900 Subject: [PATCH] [NUI] Add some API for KeyFrames 1. `GetKeyFrameCount()` to know how many keyframes are added. 2. `GetKeyFrame()` to know the information of specific index. 3. `SetKeyFrameValue()` to change the value for specific index. Signed-off-by: Eunki, Hong --- .../src/internal/Interop/Interop.KeyFrames.cs | 9 ++ src/Tizen.NUI/src/public/Animation/KeyFrames.cs | 45 +++++++- .../Tizen.NUI.Devel.Tests/testcase/TSKeyFrames.cs | 122 +++++++++++++++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100755 test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/TSKeyFrames.cs diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.KeyFrames.cs b/src/Tizen.NUI/src/internal/Interop/Interop.KeyFrames.cs index 4047db6..da98110 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.KeyFrames.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.KeyFrames.cs @@ -42,6 +42,15 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_KeyFrames_GetType")] public static extern int GetType(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_KeyFrames_GetKeyFrameCount")] + public static extern uint GetKeyFrameCount(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_KeyFrames_GetKeyFrame")] + public static extern void GetKeyFrame(global::System.Runtime.InteropServices.HandleRef jarg1, uint index, out float time, global::System.Runtime.InteropServices.HandleRef value); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_KeyFrames_SetKeyFrameValue")] + public static extern void SetKeyFrameValue(global::System.Runtime.InteropServices.HandleRef jarg1, uint index, global::System.Runtime.InteropServices.HandleRef value); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_KeyFrames_Add__SWIG_0")] public static extern void Add(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); diff --git a/src/Tizen.NUI/src/public/Animation/KeyFrames.cs b/src/Tizen.NUI/src/public/Animation/KeyFrames.cs index 1a9cb86..818e191 100755 --- a/src/Tizen.NUI/src/public/Animation/KeyFrames.cs +++ b/src/Tizen.NUI/src/public/Animation/KeyFrames.cs @@ -67,7 +67,9 @@ namespace Tizen.NUI } /// - /// Gets the type of the key frame. + /// Gets the type of the key frame.
+ /// An empty key frame will return PropertyType.None, wheras an initialised
+ /// key frame object will return the type of it's first element. ///
/// The key frame property type /// 3 @@ -103,6 +105,47 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + /// + /// Get the number of added key frame. + /// + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetKeyFrameCount() + { + uint ret = Interop.KeyFrames.GetKeyFrameCount(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Get the progress and value from specific key frame.
+ /// If index is greater or equal than total key frame count, progress and value is not changed. + ///
+ /// The index of keyframe. + /// A progress value between 0.0 and 1.0. + /// A value. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void GetKeyFrame(uint index, out float progress, PropertyValue value) + { + Interop.KeyFrames.GetKeyFrame(SwigCPtr, index, out progress, PropertyValue.getCPtr(value)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Set the value to specific key frame.
+ /// If index is greater or equal than total key frame count or value's PropertyType is not matched, Nothing happened. + ///
+ /// The index of keyframe. + /// A value. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetKeyFrameValue(uint index, PropertyValue value) + { + Interop.KeyFrames.SetKeyFrameValue(SwigCPtr, index, PropertyValue.getCPtr(value)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) diff --git a/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/TSKeyFrames.cs b/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/TSKeyFrames.cs new file mode 100755 index 0000000..0c51976 --- /dev/null +++ b/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/TSKeyFrames.cs @@ -0,0 +1,122 @@ +using global::System; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.NUI.Components; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Tests +{ + using tlog = Tizen.Log; + + [TestFixture] + [Description("public/Animation/KeyFrames")] + public class InternalKeyFramesTests + { + private string tag = "NUITEST"; + + [SetUp] + public void Init() + { + tlog.Info(tag, "Init() is called!"); + } + + [TearDown] + public void Destroy() + { + tlog.Info(tag, "Destroy() is called!"); + } + + [Test] + [Category("P1")] + [Description("Test GetKeyFrameCount. Check whether it return the right value.")] + [Property("SPEC", "Tizen.NUI.KeyFrames.GetKeyFrameCount M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")] + public void GetKeyFrameCount_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + var keyFrames = new KeyFrames(); + Assert.AreEqual(0u, keyFrames.GetKeyFrameCount(), "The number of keyframes must be matched."); + keyFrames.Add(0.0f, new Position(0.1f, 0.2f, 0.3f)); + Assert.AreEqual(1u, keyFrames.GetKeyFrameCount(), "The number of keyframes must be matched."); + keyFrames.Add(0.5f, new Position(0.9f, 0.8f, 0.7f)); + Assert.AreEqual(2u, keyFrames.GetKeyFrameCount(), "The number of keyframes must be matched."); + keyFrames.Add(1.0f, new Position(1.0f, 1.0f, 1.0f)); + Assert.AreEqual(3u, keyFrames.GetKeyFrameCount(), "The number of keyframes must be matched."); + } + + [Test] + [Category("P1")] + [Description("Test GetKeyFrame. Check whether it return the right value.")] + [Property("SPEC", "Tizen.NUI.KeyFrames.GetKeyFrame M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")] + public void GetKeyFrame_GET_VALUE() + { + /* TEST CODE */ + var keyFrames = new KeyFrames(); + float returnProgress = -1.0f; + PropertyValue returnValue = new PropertyValue(); + float returnValueFloat = -1.0f; + + keyFrames.GetKeyFrame(2u, out returnProgress, returnValue); + Assert.AreEqual(false, returnValue.Get(out returnValueFloat), "The value of keyframes must not be float."); + Assert.AreEqual(-1.0f, returnProgress, "The value of keyframes must be changed."); + + keyFrames.Add(0.0f, 2.0f); + keyFrames.Add(0.5f, 4.0f); + keyFrames.Add(1.0f, 7.0f); + + keyFrames.GetKeyFrame(0u, out returnProgress, returnValue); + Assert.AreEqual(true, returnValue.Get(out returnValueFloat), "The value of keyframes must be float."); + Assert.AreEqual(0.0f, returnProgress, "The value of keyframes must be matched."); + Assert.AreEqual(2.0f, returnValueFloat, "The value of keyframes must be matched."); + + keyFrames.GetKeyFrame(1u, out returnProgress, returnValue); + Assert.AreEqual(true, returnValue.Get(out returnValueFloat), "The value of keyframes must be float."); + Assert.AreEqual(0.5f, returnProgress, "The value of keyframes must be matched."); + Assert.AreEqual(4.0f, returnValueFloat, "The value of keyframes must be matched."); + + keyFrames.GetKeyFrame(2u, out returnProgress, returnValue); + Assert.AreEqual(true, returnValue.Get(out returnValueFloat), "The value of keyframes must be float."); + Assert.AreEqual(1.0f, returnProgress, "The value of keyframes must be matched."); + Assert.AreEqual(7.0f, returnValueFloat, "The value of keyframes must be matched."); + } + + [Test] + [Category("P1")] + [Description("Test SetKeyFrameValue. Check whether it setup the right value.")] + [Property("SPEC", "Tizen.NUI.KeyFrames.SetKeyFrameValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")] + public void SetKeyFrameValue_SET_VALUE() + { + /* TEST CODE */ + var keyFrames = new KeyFrames(); + float returnProgress = -1.0f; + PropertyValue returnValue = new PropertyValue(); + float returnValueFloat = -1.0f; + + keyFrames.SetKeyFrameValue(1u, new PropertyValue(3.0f)); + + keyFrames.Add(0.0f, 2.0f); + keyFrames.Add(0.5f, 4.0f); + keyFrames.Add(1.0f, 7.0f); + + keyFrames.GetKeyFrame(1u, out returnProgress, returnValue); + Assert.AreEqual(true, returnValue.Get(out returnValueFloat), "The value of keyframes must be float."); + Assert.AreEqual(0.5f, returnProgress, "The value of keyframes must be matched."); + Assert.AreEqual(4.0f, returnValueFloat, "The value of keyframes must be matched."); + + keyFrames.SetKeyFrameValue(1u, new PropertyValue(1.0f)); + + keyFrames.GetKeyFrame(1u, out returnProgress, returnValue); + Assert.AreEqual(true, returnValue.Get(out returnValueFloat), "The value of keyframes must be float."); + Assert.AreEqual(0.5f, returnProgress, "The value of keyframes must be matched."); + Assert.AreEqual(1.0f, returnValueFloat, "The value of keyframes must be matched."); + } + } +} -- 2.7.4