Add NPatch properties for ImageView 04/127704/2
authorxb.teng <xb.teng@samsung.com>
Fri, 28 Apr 2017 09:50:53 +0000 (17:50 +0800)
committerxb.teng <xb.teng@samsung.com>
Fri, 28 Apr 2017 10:56:23 +0000 (18:56 +0800)
Change-Id: I882212496d32d832c37b2d626b12a4f0be4a0751
Signed-off-by: xb.teng <xb.teng@samsung.com>
Tizen.NUI/src/public/BaseComponents/ImageView.cs

index ccf5c9c..910f367 100755 (executable)
@@ -201,15 +201,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                string temp;
-                GetProperty(ImageView.Property.RESOURCE_URL).Get(out temp);
-                return temp;
+                return _url;
             }
             set
             {
-                SetProperty(ImageView.Property.RESOURCE_URL, new Tizen.NUI.PropertyValue(value));
+                _url = value;
+                UpdateImage();
             }
         }
+
         /// <summary>
         /// ImageView ImageMap, type PropertyMap : string if it is a url, map otherwise
         /// </summary>
@@ -217,15 +217,26 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                PropertyMap temp = new PropertyMap();
-                GetProperty(ImageView.Property.IMAGE).Get(temp);
-                return temp;
+                if (_border == null)
+                {
+                    PropertyMap temp = new PropertyMap();
+                    GetProperty(ImageView.Property.IMAGE).Get(temp);
+                    return temp;
+                }
+                else
+                {
+                    return null;
+                }
             }
             set
             {
-                SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+                if (_border == null)
+                {
+                    SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+                }
             }
         }
+
         /// <summary>
         /// ImageView PreMultipliedAlpha, type Boolean.<br>
         /// Image must be initialized.<br>
@@ -243,6 +254,7 @@ namespace Tizen.NUI.BaseComponents
                 SetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue(value));
             }
         }
+
         /// <summary>
         /// ImageView PixelArea, type Vector4 (Animatable property).<br>
         /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br>
@@ -261,6 +273,66 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// The border of the image in the order: left, right, bottom, top.<br>
+        /// If set, ImageMap will be ignored.<br>
+        /// For N-Patch images only.<br>
+        /// Optional.
+        /// </summary>
+        public Rectangle Border
+        {
+            get
+            {
+                return _border;
+            }
+            set
+            {
+                _border = value;
+                UpdateImage();
+            }
+        }
+
+        /// <summary>
+        /// Get or set whether to draws the borders only(If true).<br>
+        /// If not specified, the default is false.<br>
+        /// For N-Patch images only.<br>
+        /// Optional.
+        /// </summary>
+        public bool BorderOnly
+        {
+            get
+            {
+                return _borderOnly;
+            }
+            set
+            {
+                _borderOnly = value;
+                UpdateImage();
+            }
+        }
+
+        private void UpdateImage()
+        {
+            if (_border != null && _url != null)
+            {
+                _nPatchMap = new PropertyMap();
+                _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
+                _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
+                _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
+                if (_borderOnly) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly)); }
+                SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
+            }
+            else
+            {
+                if (_url != null) { SetProperty(ImageView.Property.RESOURCE_URL, new PropertyValue(_url)); }
+            }
+        }
+
+        private Rectangle _border = null;
+        private bool _borderOnly = false;
+        private string _url = null;
+        private PropertyMap _nPatchMap = null;
+
     }
 
 }