[NUI] Use ActionUpdateProperty for CornerRadius and Borderline
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewInternal.cs
index 2db7853..d154a4b 100755 (executable)
@@ -1023,37 +1023,23 @@ namespace Tizen.NUI.BaseComponents
         {
             if (backgroundExtraData == null) return;
 
-            var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
+            var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
+            var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
 
-            // Apply to the background visual
-            PropertyMap backgroundMap = new PropertyMap();
-            PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
+            // Make current propertyMap
+            PropertyMap currentPropertyMap = new PropertyMap();
+            currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
+            currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
+            var temp = new PropertyValue(currentPropertyMap);
 
-            if (background.Get(backgroundMap) && !backgroundMap.Empty())
-            {
-                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);
-                temp.Dispose();
-            }
-            backgroundMap.Dispose();
-            background.Dispose();
+            // Update corner radius properties to background and shadow by ActionUpdateProperty
+            DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
+            DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
 
-            // 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] = cornerRadius;
-                shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
-                var temp = new PropertyValue(shadowMap);
-                Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
-                temp.Dispose();
-            }
-            shadowMap.Dispose();
-            shadow.Dispose();
-            cornerRadius.Dispose();
+            temp.Dispose();
+            currentPropertyMap.Dispose();
+            cornerRadiusValue.Dispose();
+            cornerRadiusPolicyValue.Dispose();
         }
 
         /// TODO open as a protected level
@@ -1061,23 +1047,25 @@ namespace Tizen.NUI.BaseComponents
         {
             if (backgroundExtraData == null) return;
 
-            var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
-
-            // 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.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
-                backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
-                backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
-                var temp = new PropertyValue(backgroundMap);
-                Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
-                temp.Dispose();
-            }
-            backgroundMap.Dispose();
-            background.Dispose();
-            borderlineColor.Dispose();
+            var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
+            var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
+            var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
+
+            // Make current propertyMap
+            PropertyMap currentPropertyMap = new PropertyMap();
+            currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
+            currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
+            currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
+            var temp = new PropertyValue(currentPropertyMap);
+
+            // Update borderline properties to background  by ActionUpdateProperty
+            DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
+
+            temp.Dispose();
+            currentPropertyMap.Dispose();
+            borderlineWidthValue.Dispose();
+            borderlineColorValue.Dispose();
+            borderlineOffsetValue.Dispose();
         }
 
         /// <summary>