From 8a286f93b285fa7f82b367e9a0de940e133aff30 Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Thu, 30 Mar 2017 15:59:03 +0900 Subject: [PATCH] N-Patch image visual high level class Change-Id: I02a778954c973fc5a75c1c961a825b27708cf7e7 Signed-off-by: dongsug.song --- .../examples/visual-view-test.cs | 17 +- src/Tizen.NUI/src/public/VisualMaps.cs | 255 ++++++++++++++++++++- 2 files changed, 268 insertions(+), 4 deletions(-) diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test.cs index 00fa306..1e2c633 100755 --- a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test.cs +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test.cs @@ -234,13 +234,26 @@ namespace VisualViewTest meshVisualMap1.TexturesPath = resources + "/images/"; meshVisualMap1.ShadingMode = MeshVisualShadingModeValue.TexturedWithSpecularLighting; - meshVisualMap1.VisualSize = new Vector2(200.0f, 200.0f); - meshVisualMap1.Offset = new Vector2(10.0f, 600.0f); + meshVisualMap1.VisualSize = new Size2D(400, 400); + meshVisualMap1.Offset = new Position2D(-50, 600); meshVisualMap1.OffsetPolicy = new Vector2(1, 1); meshVisualMap1.SizePolicy = new Vector2(1, 1); meshVisualMap1.Origin = AlignType.TopBegin; meshVisualMap1.AnchorPoint = AlignType.TopBegin; _visualView.AddVisual("meshVisual1", meshVisualMap1); + + /* n-patch image visual 1. */ + NpatchImageVisualMap npatchImageVisualMap1 = new NpatchImageVisualMap(); + npatchImageVisualMap1.URL = resources + "/images/gallery-4.jpg"; + npatchImageVisualMap1.VisualSize = new Size2D(400, 400); + npatchImageVisualMap1.Offset = new Position2D(300, 600); + npatchImageVisualMap1.OffsetPolicy = new Vector2(1, 1); + npatchImageVisualMap1.SizePolicy = new Vector2(1, 1); + npatchImageVisualMap1.Origin = AlignType.TopBegin; + npatchImageVisualMap1.AnchorPoint = AlignType.TopBegin; + npatchImageVisualMap1.Border = new Rectangle(100, 100, 100, 100); + _visualView.AddVisual("npatchImageVisual1", npatchImageVisualMap1); + } [STAThread] diff --git a/src/Tizen.NUI/src/public/VisualMaps.cs b/src/Tizen.NUI/src/public/VisualMaps.cs index 2a1b65d..d0f1132 100755 --- a/src/Tizen.NUI/src/public/VisualMaps.cs +++ b/src/Tizen.NUI/src/public/VisualMaps.cs @@ -1313,6 +1313,243 @@ namespace Tizen.NUI } } + /// + /// A class encapsulating the property map of a n-patch image visual. + /// + public class NpatchImageVisualMap : VisualMap + { + public NpatchImageVisualMap() : base() + { + } + + private string _url = ""; + private FittingModeType _fittingMode = FittingModeType.ShrinkToFit; + private SamplingModeType _samplingMode = SamplingModeType.Box; + private int _desiredWidth = 0; + private int _desiredHeight = 0; + private bool _synchronousLoading = false; + private bool _borderOnly = false; + private Vector4 _pixelArea = new Vector4(0.0f, 0.0f, 1.0f, 1.0f); + private WrapModeType _wrapModeU = WrapModeType.ClampToEdge; + private WrapModeType _wrapModeV = WrapModeType.ClampToEdge; + private Rectangle _border = new Rectangle(0, 0, 0, 0); + + /// + /// Get or set the URL of the image. + /// + public string URL + { + get + { + return _url; + } + set + { + _url = value; + } + } + + /// + /// Get or set fitting options, used when resizing images to fit desired dimensions. + /// If not supplied, default is FittingMode::SHRINK_TO_FIT. + /// For Normal Quad images only. + /// + public FittingModeType FittingMode + { + get + { + return _fittingMode; + } + set + { + _fittingMode = value; + } + } + + /// + /// Get or set filtering options, used when resizing images to sample original pixels. + /// If not supplied, default is SamplingMode::BOX. + /// For Normal Quad images only. + /// + public SamplingModeType SamplingMode + { + get + { + return _samplingMode; + } + set + { + _samplingMode = value; + } + } + + /// + /// Get or set the desired image width. + /// If not specified, the actual image width is used. + /// For Normal Quad images only. + /// + public int DesiredWidth + { + get + { + return _desiredWidth; + } + set + { + _desiredWidth = value; + } + } + + /// + /// Get or set the desired image height. + /// If not specified, the actual image height is used. + /// For Normal Quad images only. + /// + public int DesiredHeight + { + get + { + return _desiredHeight; + } + set + { + _desiredHeight = value; + } + } + + /// + /// Get or set whether to load the image synchronously. + /// If not specified, the default is false, i.e. the image is loaded asynchronously. + /// For Normal Quad images only. + /// + public bool SynchronousLoading + { + get + { + return _synchronousLoading; + } + set + { + _synchronousLoading = value; + } + } + + /// + /// Get or set whether to draws the borders only(If true). + /// If not specified, the default is false. + /// For N-Patch images only. + /// + public bool BorderOnly + { + get + { + return _borderOnly; + } + set + { + _borderOnly = value; + } + } + + /// + /// Get or set the image area to be displayed. + /// It is a rectangular area. + /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively. + /// If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image. + /// For For Normal QUAD image only. + /// + public Vector4 PixelArea + { + get + { + return _pixelArea; + } + set + { + _pixelArea = value; + } + } + + /// + /// Get or set the wrap mode for u coordinate. + /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0. + /// If not specified, the default is CLAMP. + /// For Normal QUAD image only. + /// + public WrapModeType WrapModeU + { + get + { + return _wrapModeU; + } + set + { + _wrapModeU = value; + } + } + + /// + /// Get or set the wrap mode for v coordinate. + /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0. + /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively. + /// If not specified, the default is CLAMP. + /// For Normal QUAD image only. + /// + public WrapModeType WrapModeV + { + get + { + return _wrapModeV; + } + set + { + _wrapModeV = value; + } + } + + public Rectangle Border + { + get + { + return _border; + } + set + { + _border = value; + } + } + + protected override void ComposingPropertyMap() + { + if (_url != "") + { + _outputVisualMap = new PropertyMap(); + _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Npatch)); + _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url)); + _outputVisualMap.Add(NpatchImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode)); + _outputVisualMap.Add(NpatchImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode)); + + if (_desiredWidth != 0) + { + _outputVisualMap.Add(NpatchImageVisualProperty.DesiredWidth, new PropertyValue(_desiredWidth)); + } + + if (_desiredHeight != 0) + { + _outputVisualMap.Add(NpatchImageVisualProperty.DesiredHeight, new PropertyValue(_desiredHeight)); + } + + _outputVisualMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronousLoading)); + _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly)); + _outputVisualMap.Add(NpatchImageVisualProperty.PixelArea, new PropertyValue(_pixelArea)); + _outputVisualMap.Add(NpatchImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU)); + _outputVisualMap.Add(NpatchImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV)); + _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); + } + } + } + + public enum WrapModeType { @@ -1412,7 +1649,8 @@ namespace Tizen.NUI Mesh, Primitive, Wireframe, - Text + Text, + Npatch } public struct Property @@ -1511,6 +1749,19 @@ namespace Tizen.NUI public static readonly int TextColor = NDalic.TEXT_VISUAL_TEXT_COLOR; public static readonly int EnableMarkup = NDalic.TEXT_VISUAL_ENABLE_MARKUP; } - + public struct NpatchImageVisualProperty + { + public static readonly int URL = NDalic.IMAGE_VISUAL_URL; + public static readonly int FittingMode = NDalic.IMAGE_VISUAL_FITTING_MODE; + public static readonly int SamplingMode = NDalic.IMAGE_VISUAL_SAMPLING_MODE; + public static readonly int DesiredWidth = NDalic.IMAGE_VISUAL_DESIRED_WIDTH; + public static readonly int DesiredHeight = NDalic.IMAGE_VISUAL_DESIRED_HEIGHT; + public static readonly int SynchronousLoading = NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING; + public static readonly int BorderOnly = NDalic.IMAGE_VISUAL_BORDER_ONLY; + public static readonly int PixelArea = NDalic.IMAGE_VISUAL_PIXEL_AREA; + public static readonly int WrapModeU = NDalic.IMAGE_VISUAL_WRAP_MODE_U; + public static readonly int WrapModeV = NDalic.IMAGE_VISUAL_WRAP_MODE_V; + public static readonly int Border = NDalic.IMAGE_VISUAL_WRAP_MODE_V + 1; + } } -- 2.7.4