[NUI] Implement LowerFirstLetter as Native side
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 28 Apr 2025 01:55:50 +0000 (10:55 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 29 Apr 2025 08:55:44 +0000 (17:55 +0900)
Relative dali patches:
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/323372

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

index 2084d6f882272c56fa967a8dc9085b866f21b23c..f5a23b5bbe3907916690176b097bd94819b313d5 100755 (executable)
@@ -54,6 +54,32 @@ namespace Tizen.NUI
             { "shadow.CornerRadius",        new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
             { "shadow.CornerSquareness",    new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerSquareness, ObjectIntToFloat) },
         };
+        private static readonly Dictionary<string, VisualPropertyData> visualPropertyUpperCaseTable = new Dictionary<string, VisualPropertyData>()
+        {
+            { "BackgroundColor",            new VisualPropertyData(View.Property.BACKGROUND, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) },
+            { "BackgroundOpacity",          new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.Opacity, ObjectIntToFloat) },
+            { "BoxShadow.BlurRadius",       new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.BlurRadius) },
+            { "BoxShadow.Color",            new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) },
+            { "BoxShadow.CornerRadius",     new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
+            { "BoxShadow.CornerSquareness", new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerSquareness, ObjectIntToFloat) },
+            { "BoxShadow.Offset",           new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) },
+            { "BoxShadow.Opacity",          new VisualPropertyData(View.Property.SHADOW, Visual.Property.Opacity, ObjectIntToFloat) },
+            { "CornerRadius",               new VisualPropertyData(ImageView.Property.IMAGE, Visual.Property.CornerRadius, null, null,
+                                            new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, null, null,
+                                            new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.CornerRadius, null, null))) },
+            { "CornerSquareness",           new VisualPropertyData(ImageView.Property.IMAGE, Visual.Property.CornerSquareness, null, null,
+                                            new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerSquareness, null, null,
+                                            new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.CornerSquareness, null, null))) },
+            { "BorderlineWidth",            new VisualPropertyData(ImageView.Property.IMAGE, Visual.Property.BorderlineWidth, ObjectIntToFloat, null,
+                                            new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.BorderlineWidth, ObjectIntToFloat, null)) },
+            { "BorderlineColor",            new VisualPropertyData(ImageView.Property.IMAGE, Visual.Property.BorderlineColor, null, null,
+                                            new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.BorderlineColor, null, null)) },
+            { "BorderlineOffset",           new VisualPropertyData(ImageView.Property.IMAGE, Visual.Property.BorderlineOffset, null, null,
+                                            new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.BorderlineOffset, null, null)) },
+            { "ImageShadow.Offset",         new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) },
+            { "Shadow.CornerRadius",        new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
+            { "Shadow.CornerSquareness",    new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerSquareness, ObjectIntToFloat) },
+        };
 
         static PropertyHelper() { }
 
@@ -62,7 +88,7 @@ namespace Tizen.NUI
         ///</summary>
         internal static Property GetPropertyFromString(Animatable handle, string stringProperty)
         {
-            Property property = new Property(handle, LowerFirstLetter(stringProperty));
+            Property property = new Property(handle, stringProperty);
             if (property.PropertyIndex == Property.InvalidIndex)
             {
                 throw new System.ArgumentException("string property is invalid");
@@ -76,19 +102,17 @@ namespace Tizen.NUI
         ///</summary>
         internal static SearchResult Search(Animatable animatable, string stringProperty)
         {
-            var propertyName = LowerFirstLetter(stringProperty);
-
             if(animatable is View)
             {
                 View view = animatable as View;
-                return SearchProperty(view, propertyName) ?? SearchVisualProperty(view, propertyName);
+                return SearchProperty(view, stringProperty) ?? SearchVisualProperty(view, stringProperty);
             }
-            return SearchProperty(animatable, propertyName);
+            return SearchProperty(animatable, stringProperty);
         }
 
-        private static SearchResult SearchProperty(Animatable animatable, string lowercasePropertyString)
+        private static SearchResult SearchProperty(Animatable animatable, string propertyName)
         {
-            Property property = new Property(animatable, lowercasePropertyString);
+            Property property = new Property(animatable, propertyName);
 
             if (property.PropertyIndex == Property.InvalidIndex)
             {
@@ -105,12 +129,16 @@ namespace Tizen.NUI
             return new SearchResult(property, converter);
         }
 
-        private static SearchResult SearchVisualProperty(View view, string lowercasePropertyString)
+        private static SearchResult SearchVisualProperty(View view, string propertyName)
         {
-            if (visualPropertyTable.TryGetValue(lowercasePropertyString, out var found))
+            if (visualPropertyTable.TryGetValue(propertyName, out var found))
             {
                 return GenerateVisualPropertySearchResult(view, found);
             }
+            else if (visualPropertyUpperCaseTable.TryGetValue(propertyName, out var foundAtUpperCase))
+            {
+                return GenerateVisualPropertySearchResult(view, foundAtUpperCase);
+            }
 
             return null;
         }
@@ -137,13 +165,6 @@ namespace Tizen.NUI
             return result;
         }
 
-        private static string LowerFirstLetter(string original)
-        {
-            StringBuilder sb = new StringBuilder(original);
-            sb[0] = (char)(sb[0] | 0x20);
-            return sb.ToString();
-        }
-
         private static object ObjectColorToVector4(object value)
         {
             if (value is Vector4)
index 22baae2ed84bc752453f8cce2633c4efbc25aae8..4c8986fe248c06333a78e70e79b3b7412483484a 100755 (executable)
@@ -125,7 +125,7 @@ namespace Tizen.NUI
         public int GetPropertyIndex(string name)
         {
             // Convert property string to be lowercase
-            int ret = Interop.Handle.GetPropertyIndex(SwigCPtr, LowerFirstLetter(name));
+            int ret = Interop.Handle.GetPropertyIndex(SwigCPtr, name);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -202,8 +202,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void SetProperty(string name, PropertyValue propertyValue)
         {
-            var propertyName = LowerFirstLetter(name);
-            Property property = new Property(this, propertyName);
+            Property property = new Property(this, name);
             if (property.PropertyIndex == Property.InvalidIndex)
             {
                 Tizen.Log.Error("NUI", "Invalid property name\n");
@@ -331,13 +330,6 @@ 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)