[NUI] Update Shadow property : add Clone method (#1270)
authorJiyun Yang <ji.yang@samsung.com>
Fri, 3 Jan 2020 08:50:00 +0000 (17:50 +0900)
committerGitHub <noreply@github.com>
Fri, 3 Jan 2020 08:50:00 +0000 (17:50 +0900)
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/Color.cs
src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs
src/Tizen.NUI/src/public/ViewProperty/Shadow.cs
src/Tizen.NUI/src/public/ViewProperty/TransformablePropertyMap.cs

index 4314090..d7ad7b0 100755 (executable)
@@ -128,6 +128,10 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        internal Color(ColorChangedCallback cb, Color other) : this(cb, other.R, other.G, other.B, other.A)
+        {
+        }
+
         internal delegate void ColorChangedCallback(float r, float g, float b, float a);
         private ColorChangedCallback callback = null;
 
index 21edf54..5bf2d85 100644 (file)
@@ -38,6 +38,20 @@ namespace Tizen.NUI
         {
         }
 
+        /// <summary>
+        /// Deep copy method
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        override public object Clone()
+        {
+            return new ImageShadow() {
+                Offset = offset,
+                Scale = scale,
+                Url = url,
+                Border = border
+            };
+        }
+
         private void OnBorderChanged(int x, int y, int width, int height)
         {
             UpdateBorder();
index 44ee106..18b6fe7 100644 (file)
@@ -56,6 +56,20 @@ namespace Tizen.NUI
             return shadow;
         }
 
+        /// <summary>
+        /// Deep copy method
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        override public object Clone()
+        {
+            return new Shadow() {
+                Offset = offset,
+                Scale = scale,
+                Color = color,
+                BlurRadius = blurRadius
+            };
+        }
+
         private void OnColorChanged(float r, float g, float b, float a)
         {
             UpdateColor();
@@ -85,7 +99,7 @@ namespace Tizen.NUI
             }
             set
             {
-                color = value;
+                color = value == null? null : new Color(OnColorChanged, value);
                 UpdateColor();
             }
         }
index d2d2927..b5e46d2 100644 (file)
@@ -43,12 +43,12 @@ namespace Tizen.NUI
         /// <summary>
         /// The offset value that tansform should have in common
         /// </summary>
-        protected internal Vector2 offset = defaultOffset;
+        protected internal Vector2 offset;
 
         /// <summary>
         /// The size value in scale that tansform should have in common
         /// </summary>
-        protected internal Vector2 scale = noScale;
+        protected internal Vector2 scale;
 
         /// <summary>
         /// The output property map
@@ -64,15 +64,29 @@ namespace Tizen.NUI
         /// Constructor
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public TransformablePropertyMap()
+        public TransformablePropertyMap() : this(defaultOffset, noScale)
+        {
+        }
+
+        /// <summary>
+        /// Copy Constructor
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public TransformablePropertyMap(TransformablePropertyMap other) : this(other.offset, other.scale)
+        {
+        }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        protected internal TransformablePropertyMap(Vector2 offset, Vector2 scale)
         {
-            // Initialize maps
             propertyMap = new PropertyMap();
             transformMap = new PropertyMap();
-
-            // Offet has default value, so need to update map
             transformMap[(int)VisualTransformPropertyType.OffsetPolicy] = new PropertyValue(defaultOffsetPolicy);
-            transformMap[(int)VisualTransformPropertyType.Offset] = PropertyValue.CreateWithGuard(offset);
+
+            Offset = offset;
+            Scale = scale;
             propertyMap[Visual.Property.Transform] = new PropertyValue(transformMap);
         }
 
@@ -154,6 +168,7 @@ namespace Tizen.NUI
         /// The value indicates percentage of the container size. <br />
         /// e.g. (0.5f, 1.0f) means 50% of the container's width and 100% of container's height.
         /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public Vector2 Scale
         {
             get
@@ -171,6 +186,12 @@ namespace Tizen.NUI
 
         abstract internal bool IsValid();
 
+        /// <summary>
+        /// Deep copy method
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        abstract public object Clone();
+
         static internal PropertyValue ToPropertyValue(TransformablePropertyMap instance)
         {
             return (instance != null && instance.IsValid()) ? new PropertyValue(instance.propertyMap) : new PropertyValue();