From: Eunki, Hong Date: Mon, 28 Apr 2025 01:55:50 +0000 (+0900) Subject: [NUI] Implement LowerFirstLetter as Native side X-Git-Tag: submit/tizen/20250429.085946~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b1efabc346b2a2a99288ec3e1c49c8f435e9690;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Implement LowerFirstLetter as Native side Relative dali patches: https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/323372 Signed-off-by: Eunki, Hong --- diff --git a/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs b/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs index 2084d6f88..f5a23b5bb 100755 --- a/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs +++ b/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs @@ -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 visualPropertyUpperCaseTable = new Dictionary() + { + { "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 /// 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 /// 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) diff --git a/src/Tizen.NUI/src/public/Animation/Animatable.cs b/src/Tizen.NUI/src/public/Animation/Animatable.cs index 22baae2ed..4c8986fe2 100755 --- a/src/Tizen.NUI/src/public/Animation/Animatable.cs +++ b/src/Tizen.NUI/src/public/Animation/Animatable.cs @@ -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)