From 181a117ea67cadd4f64ebeacccfdb4f35ba3bfa8 Mon Sep 17 00:00:00 2001 From: "xb.teng" Date: Fri, 28 Apr 2017 17:50:53 +0800 Subject: [PATCH] Add NPatch properties for ImageView Change-Id: I882212496d32d832c37b2d626b12a4f0be4a0751 Signed-off-by: xb.teng --- .../src/public/BaseComponents/ImageView.cs | 88 ++++++++++++++++++++-- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index ccf5c9c..910f367 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -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(); } } + /// /// ImageView ImageMap, type PropertyMap : string if it is a url, map otherwise /// @@ -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)); + } } } + /// /// ImageView PreMultipliedAlpha, type Boolean.
/// Image must be initialized.
@@ -243,6 +254,7 @@ namespace Tizen.NUI.BaseComponents SetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue(value)); } } + /// /// ImageView PixelArea, type Vector4 (Animatable property).
/// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
@@ -261,6 +273,66 @@ namespace Tizen.NUI.BaseComponents } } + /// + /// The border of the image in the order: left, right, bottom, top.
+ /// If set, ImageMap will be ignored.
+ /// For N-Patch images only.
+ /// Optional. + ///
+ public Rectangle Border + { + get + { + return _border; + } + set + { + _border = value; + UpdateImage(); + } + } + + /// + /// Get or set whether to draws the borders only(If true).
+ /// If not specified, the default is false.
+ /// For N-Patch images only.
+ /// Optional. + ///
+ 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; + } } -- 2.7.4