[NUI] Apply Vector4 corner radius internally.
authorJiyun Yang <ji.yang@samsung.com>
Tue, 13 Apr 2021 01:54:57 +0000 (10:54 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 28 Apr 2021 03:36:30 +0000 (12:36 +0900)
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/internal/Common/PropertyHelper.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs
src/Tizen.NUI/src/public/Visuals/VisualMaps.cs

index a806646..2f5bf71 100755 (executable)
@@ -39,8 +39,9 @@ namespace Tizen.NUI
             { "boxShadow.CornerRadius", new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, 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(View.Property.BACKGROUND, Visual.Property.CornerRadius, ObjectVector4ToFloat, null,
-                                        new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectVector4ToFloat)) },
+            { "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))) },
             { "imageShadow.Offset",     new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) },
             { "shadow.CornerRadius",    new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
         };
@@ -109,15 +110,14 @@ namespace Tizen.NUI
             if (property.propertyIndex == Property.InvalidIndex)
             {
                 property.Dispose();
-                return null;
+                return data.RelatedData == null ? null : GenerateVisualPropertySearchResult(view, data.RelatedData);
             }
 
             SearchResult result = new SearchResult(property, data.ObjectConverter, data.PropertyValueConverter);
 
-            while (data.RelatedData != null)
+            if (data.RelatedData != null)
             {
                 result.NextResult = GenerateVisualPropertySearchResult(view, data.RelatedData);
-                data = data.RelatedData;
             }
 
             return result;
index 560a29c..06a6cfe 100755 (executable)
@@ -1257,9 +1257,7 @@ namespace Tizen.NUI.BaseComponents
 
             if (backgroundExtraData != null && backgroundExtraData.CornerRadius != null)
             {
-                // TODO Fix to support Vector4 for corner radius after dali support it.
-                //      Current code only gets first argument of Vector4.
-                using (var cornerRadius = new PropertyValue(backgroundExtraData.CornerRadius.X))
+                using (var cornerRadius = new PropertyValue(backgroundExtraData.CornerRadius))
                 using (var cornerRadiusPolicy = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy))
                 {
                     imageMap.Insert(Visual.Property.CornerRadius, cornerRadius);
index f94516c..93aad5b 100755 (executable)
@@ -1578,10 +1578,7 @@ namespace Tizen.NUI.BaseComponents
             var view = (View)bindable;
             (view.backgroundExtraData ?? (view.backgroundExtraData = new BackgroundExtraData())).CornerRadiusPolicy = (VisualTransformPolicyType)newValue;
 
-            // TODO Fix to support Vector4 for corner radius after dali support it.
-            //      Current code only gets first argument of Vector4.
-            float cornerRadius = view.backgroundExtraData.CornerRadius?.X ?? 0.0f;
-            if (cornerRadius != 0)
+            if (view.backgroundExtraData.CornerRadius != null)
             {
                 view.ApplyCornerRadius();
             }
@@ -1794,12 +1791,8 @@ namespace Tizen.NUI.BaseComponents
 
             PropertyMap map = new PropertyMap();
 
-            // TODO Fix to support Vector4 for corner radius after dali support it.
-            //      Current code only gets first argument of Vector4.
-            float cornerRadius = backgroundExtraData.CornerRadius?.X ?? 0.0f;
-
             map.Add(ImageVisualProperty.URL, new PropertyValue(value))
-               .Add(Visual.Property.CornerRadius, new PropertyValue(cornerRadius))
+               .Add(Visual.Property.CornerRadius, new PropertyValue(backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius)))
                .Add(Visual.Property.CornerRadiusPolicy, new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy)))
                .Add(ImageVisualProperty.SynchronousLoading, new PropertyValue(backgroundImageSynchronosLoading));
 
@@ -1865,13 +1858,9 @@ namespace Tizen.NUI.BaseComponents
 
             PropertyMap map = new PropertyMap();
 
-            // TODO Fix to support Vector4 for corner radius after dali support it.
-            //      Current code only gets first argument of Vector4.
-            float cornerRadius = backgroundExtraData.CornerRadius?.X ?? 0.0f;
-
             map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color))
                 .Add(ColorVisualProperty.MixColor, new PropertyValue(value))
-                .Add(Visual.Property.CornerRadius, new PropertyValue(cornerRadius))
+                .Add(Visual.Property.CornerRadius, new PropertyValue(new PropertyValue(backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius))))
                 .Add(Visual.Property.CornerRadiusPolicy, new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy)));
 
             Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)SwigCPtr, View.Property.BACKGROUND, new PropertyValue(map));
index 431860e..53acc0e 100755 (executable)
@@ -1045,16 +1045,14 @@ namespace Tizen.NUI.BaseComponents
         {
             if (backgroundExtraData == null) return;
 
-            // TODO Fix to support Vector4 for corner radius after dali support it.
-            //      Current code only gets first argument of Vector4.
-            float cornerRadius = backgroundExtraData.CornerRadius?.X ?? 0.0f;
+            var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
 
             // Apply to the background visual
             PropertyMap backgroundMap = new PropertyMap();
             PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
             if (background.Get(backgroundMap) && !backgroundMap.Empty())
             {
-                backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(cornerRadius);
+                backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
                 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
                 var temp = new PropertyValue(backgroundMap);
                 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
@@ -1062,13 +1060,14 @@ namespace Tizen.NUI.BaseComponents
             }
             backgroundMap.Dispose();
             background.Dispose();
+            cornerRadius.Dispose();
 
             // Apply to the shadow visual
             PropertyMap shadowMap = new PropertyMap();
             PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
             if (shadow.Get(shadowMap) && !shadowMap.Empty())
             {
-                shadowMap[Visual.Property.CornerRadius] = new PropertyValue(cornerRadius);
+                shadowMap[Visual.Property.CornerRadius] = cornerRadius;
                 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
                 var temp = new PropertyValue(shadowMap);
                 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
index 89bee67..9ec0eb3 100755 (executable)
@@ -162,13 +162,9 @@ namespace Tizen.NUI
 
             var map = GetPropertyMap();
 
-            // TODO Fix to support Vector4 for corner radius after dali support it.
-            //      Current code only gets first argument of Vector4.
-            float cornerRadius = attachedView.CornerRadius?.X ?? 0.0f;
-
-            if (cornerRadius > 0)
+            if (attachedView.CornerRadius != null)
             {
-                map[Visual.Property.CornerRadius] = new PropertyValue(cornerRadius);
+                map[Visual.Property.CornerRadius] = attachedView.CornerRadius == null ? new PropertyValue() : new PropertyValue(attachedView.CornerRadius);
                 map[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)attachedView.CornerRadiusPolicy);
             }
 
index 0208551..8139059 100755 (executable)
@@ -80,7 +80,7 @@ namespace Tizen.NUI
         /// The corner radius value of the visual.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        private float? cornerRadius = null;
+        private Vector4 cornerRadius = null;
 
         /// <summary>
         /// The map for visual.
@@ -613,11 +613,11 @@ namespace Tizen.NUI
         /// The corner radius of the visual.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public float CornerRadius
+        public Vector4 CornerRadius
         {
-            protected get
+            get
             {
-                return cornerRadius ?? (0.0f);
+                return cornerRadius;
             }
             set
             {
@@ -706,7 +706,7 @@ namespace Tizen.NUI
             }
             if (cornerRadius != null)
             {
-                PropertyValue temp = new PropertyValue((int)cornerRadius);
+                PropertyValue temp = new PropertyValue(cornerRadius);
                 _outputVisualMap.Add(Visual.Property.CornerRadius, temp);
                 temp.Dispose();
             }
@@ -771,6 +771,7 @@ namespace Tizen.NUI
                 visualSize?.Dispose();
                 visualSizePolicy?.Dispose();
                 visualTransformMap?.Dispose();
+                cornerRadius?.Dispose();
             }
             disposed = true;
         }