[NUI] Support SetProperty by using string name for Animatable
authorseungho baek <sbsh.baek@samsung.com>
Tue, 20 Dec 2022 13:23:58 +0000 (22:23 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 27 Dec 2022 05:50:29 +0000 (14:50 +0900)
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
src/Tizen.NUI/src/public/Animation/Animatable.cs

index 5bf0365..4d83bbc 100755 (executable)
@@ -137,6 +137,28 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the value of an existing property.
+        /// </summary>
+        /// <param name="name">The index of the property.</param>
+        /// <param name="propertyValue">The new value of the property.</param>
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetProperty(string name, PropertyValue propertyValue)
+        {
+            var propertyName = LowerFirstLetter(name);
+            Property property = new Property(this, propertyName);
+            if (property.propertyIndex == Property.InvalidIndex)
+            {
+                Tizen.Log.Error("NUI", "Invalid property name\n");
+            }
+            else
+            {
+                Tizen.NUI.Object.SetProperty(SwigCPtr, property.propertyIndex, propertyValue);
+            }
+            property.Dispose();
+        }
+
+        /// <summary>
         /// Registers a new animatable property.
         /// </summary>
         /// <param name="name">The name of the property.</param>
@@ -240,6 +262,13 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        private static string LowerFirstLetter(string original)
+        {
+            StringBuilder sb = new StringBuilder(original);
+            sb[0] = (char)(sb[0] | 0x20);
+            return sb.ToString();
+        }
+
         /// This will not be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)