From: xb.teng Date: Fri, 28 Apr 2017 09:50:53 +0000 (+0800) Subject: Add NPatch properties for ImageView X-Git-Tag: preview1-00180^2~289 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98668cf4dc2e8467ed9b0a6ca4edba528f4ca501;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Add NPatch properties for ImageView Change-Id: I882212496d32d832c37b2d626b12a4f0be4a0751 Signed-off-by: xb.teng --- 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; + } }