1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
19 using System.Runtime.InteropServices;
22 /// A class encapsulating the transform map of visual.
24 public class VisualMap
26 private Vector2 _visualSize = Vector2.Zero;
27 private Vector2 _visualOffset = Vector2.Zero;
28 private Vector2 _visualOffsetPolicy = new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute); // default absolute
29 private Vector2 _visualSizePolicy = new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute); // default absolute
30 private AlignType _visualOrigin = AlignType.TopBegin;
31 private AlignType _visualAnchorPoint = AlignType.TopBegin;
33 private PropertyMap _visualTransformMap = null;
35 private float _depthIndex = 0.0f;
36 protected PropertyMap _outputVisualMap = null;
43 /// Get or set size of the visual.
44 /// It can be either relative (percentage of the parent)
45 /// or absolute (in world units).
47 public Vector2 VisualSize
60 /// Get or set offset of the visual.
61 /// It can be either relative (percentage of the parent)
62 /// or absolute (in world units).
72 _visualOffset = value;
77 /// Get or set offset policy of the visual.
78 /// Indicates which components of the offset are relative
79 /// (percentage of the parent) or absolute (in world units).
80 /// 0 indicates the component is relative, and 1 absolute.
82 public Vector2 OffsetPolicy
86 return _visualOffsetPolicy;
90 _visualOffsetPolicy = value;
95 /// Get or set size policy of the visual.
96 /// Indicates which components of the size are relative
97 /// (percentage of the parent) or absolute (in world units).
98 /// 0 indicates the component is relative, and 1 absolute.
100 public Vector2 SizePolicy
104 return _visualSizePolicy;
108 _visualSizePolicy = value;
113 /// Get or set the origin of the visual within its control area.
115 public AlignType Origin
119 return _visualOrigin;
123 _visualOrigin = value;
128 /// Get or set the anchor-point of the visual.
130 public AlignType AnchorPoint
134 return _visualAnchorPoint;
138 _visualAnchorPoint = value;
143 /// Get or set the depth index of the visual.
145 public float DepthIndex
157 private void ComposingTransformMap()
159 if (_visualSize != Vector2.Zero)
161 _visualTransformMap = new PropertyMap();
162 _visualTransformMap.Add((int)VisualTransformPropertyType.Size, new PropertyValue(_visualSize));
163 _visualTransformMap.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(_visualOffset));
164 _visualTransformMap.Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(_visualOffsetPolicy));
165 _visualTransformMap.Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(_visualSizePolicy));
166 _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin));
167 _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint));
172 /// Get the transform map used by the visual.
174 public PropertyMap OutputTransformMap
178 ComposingTransformMap();
179 return _visualTransformMap;
183 protected virtual void ComposingPropertyMap()
185 _outputVisualMap = new PropertyMap();
189 /// Get the property map to create the visual.
191 public PropertyMap OutputVisualMap
195 ComposingPropertyMap();
196 return _outputVisualMap;
202 /// A class encapsulating the property map of a image visual.
204 public class ImageVisualMap : VisualMap
206 public ImageVisualMap() : base()
210 private string _url = "";
211 private FittingModeType _fittingMode = FittingModeType.ShrinkToFit;
212 private SamplingModeType _samplingMode = SamplingModeType.Box;
213 private int _desiredWidth = 0;
214 private int _desiredHeight = 0;
215 private bool _synchronousLoading = false;
216 private bool _borderOnly = false;
217 private Vector4 _pixelArea = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
218 private WrapModeType _wrapModeU = WrapModeType.ClampToEdge;
219 private WrapModeType _wrapModeV = WrapModeType.ClampToEdge;
222 /// Get or set the URL of the image.
237 /// Get or set fitting options, used when resizing images to fit desired dimensions.
238 /// If not supplied, default is FittingMode::SHRINK_TO_FIT.
239 /// For Normal Quad images only.
241 public FittingModeType FittingMode
249 _fittingMode = value;
254 /// Get or set filtering options, used when resizing images to sample original pixels.
255 /// If not supplied, default is SamplingMode::BOX.
256 /// For Normal Quad images only.
258 public SamplingModeType SamplingMode
262 return _samplingMode;
266 _samplingMode = value;
271 /// Get or set the desired image width.
272 /// If not specified, the actual image width is used.
273 /// For Normal Quad images only.
275 public int DesiredWidth
279 return _desiredWidth;
283 _desiredWidth = value;
288 /// Get or set the desired image height.
289 /// If not specified, the actual image height is used.
290 /// For Normal Quad images only.
292 public int DesiredHeight
296 return _desiredHeight;
300 _desiredHeight = value;
305 /// Get or set whether to load the image synchronously.
306 /// If not specified, the default is false, i.e. the image is loaded asynchronously.
307 /// For Normal Quad images only.
309 public bool SynchronousLoading
313 return _synchronousLoading;
317 _synchronousLoading = value;
322 /// Get or set whether to draws the borders only(If true).
323 /// If not specified, the default is false.
324 /// For N-Patch images only.
326 public bool BorderOnly
339 /// Get or set the image area to be displayed.
340 /// It is a rectangular area.
341 /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.
342 /// If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
343 /// For For Normal QUAD image only.
345 public Vector4 PixelArea
358 /// Get or set the wrap mode for u coordinate.
359 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.
360 /// If not specified, the default is CLAMP.
361 /// For Normal QUAD image only.
363 public WrapModeType WrapModeU
376 /// Get or set the wrap mode for v coordinate.
377 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.
378 /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.
379 /// If not specified, the default is CLAMP.
380 /// For Normal QUAD image only.
382 public WrapModeType WrapModeV
394 protected override void ComposingPropertyMap()
398 _outputVisualMap = new PropertyMap();
399 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
400 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
401 _outputVisualMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode));
402 _outputVisualMap.Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode));
404 if (_desiredWidth != 0)
406 _outputVisualMap.Add(ImageVisualProperty.DesiredWidth, new PropertyValue(_desiredWidth));
409 if (_desiredHeight != 0)
411 _outputVisualMap.Add(ImageVisualProperty.DesiredHeight, new PropertyValue(_desiredHeight));
414 _outputVisualMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronousLoading));
415 _outputVisualMap.Add(ImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly));
416 _outputVisualMap.Add(ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea));
417 _outputVisualMap.Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU));
418 _outputVisualMap.Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV));
424 /// A class encapsulating the property map of a text visual.
426 public class TextVisualMap : VisualMap
428 public TextVisualMap() : base()
432 private string _text = "";
433 private string _fontFamily = "";
434 private PropertyMap _fontStyle = null;
435 private float _pointSize = 0.0f;
436 private bool _multiLine = false;
437 private string _horizontalAlignment = "BEGIN";
438 private string _verticalAlignment = "TOP";
439 private Color _textColor = Color.Black;
440 private bool _enableMarkup = false;
443 /// Get or set the text to display in UTF-8 format.
458 /// Get or set the requested font family to use.
460 public string FontFamily
473 /// Get or set the requested font style to use.
475 public PropertyMap FontStyle
488 /// Get or set the size of font in points.
490 public float PointSize
503 /// Get or set the single-line or multi-line layout option.
505 public bool MultiLine
518 /// Get or set the line horizontal alignment.
519 /// If not specified, the default is BEGIN.
521 public string HorizontalAlignment
525 return _horizontalAlignment;
529 _horizontalAlignment = value;
534 /// Get or set the line vertical alignment.
535 /// If not specified, the default is TOP.
537 public string VerticalAlignment
541 return _verticalAlignment;
545 _verticalAlignment = value;
550 /// Get or set the color of the text.
552 public Color TextColor
565 /// Get or set whether the mark-up processing is enabled.
567 public bool EnableMarkup
571 return _enableMarkup;
575 _enableMarkup = value;
579 protected override void ComposingPropertyMap()
583 _outputVisualMap = new PropertyMap();
584 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
585 _outputVisualMap.Add(TextVisualProperty.Text, new PropertyValue(_text));
587 if (_fontFamily != "")
589 _outputVisualMap.Add(TextVisualProperty.FontFamily, new PropertyValue(_fontFamily));
592 if (_fontStyle != null)
594 _outputVisualMap.Add(TextVisualProperty.FontStyle, new PropertyValue(_fontStyle));
599 _outputVisualMap.Add(TextVisualProperty.PointSize, new PropertyValue(_pointSize));
602 _outputVisualMap.Add(TextVisualProperty.MultiLine, new PropertyValue(_multiLine));
603 _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment));
604 _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment));
605 _outputVisualMap.Add(TextVisualProperty.TextColor, new PropertyValue(_textColor));
606 _outputVisualMap.Add(TextVisualProperty.EnableMarkup, new PropertyValue(_enableMarkup));
612 /// A class encapsulating the property map of a border visual.
614 public class BorderVisualMap : VisualMap
616 public BorderVisualMap() : base()
620 private Color _color = Color.Black;
621 private float _size = 0.000001f;
622 private bool _antiAliasing = false;
625 /// Get or set the color of the border.
640 /// Get or set the width of the border (in pixels).
655 /// Get or set whether anti-aliasing of the border is required.
656 /// If not supplied, default is false.
658 public bool AntiAliasing
662 return _antiAliasing;
666 _antiAliasing = value;
670 protected override void ComposingPropertyMap()
672 if (_size > 0.000001f)
674 _outputVisualMap = new PropertyMap();
675 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
676 _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color));
677 _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue(_size));
678 _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue(_antiAliasing));
684 /// A class encapsulating the property map of a color visual.
686 public class ColorVisualMap : VisualMap
688 public ColorVisualMap() : base()
692 private Color _mixColor = Color.Black;
695 /// Get or set the solid color required.
697 public Color MixColor
709 protected override void ComposingPropertyMap()
711 _outputVisualMap = new PropertyMap();
712 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
713 _outputVisualMap.Add(ColorVisualProperty.MixColor, new PropertyValue(_mixColor));
718 /// A class encapsulating the property map of a gradient visual.
720 public class GradientVisualMap : VisualMap
722 public GradientVisualMap() : base()
726 private Vector2 _startPosition = Vector2.Zero;
727 private Vector2 _endPosition = Vector2.Zero;
728 private Vector2 _center = Vector2.Zero;
729 private float _radius = 0.000001f;
730 private PropertyArray _stopOffset = null; //0.0, 1.0
731 private PropertyArray _stopColor = null; // Color.Black, Color.Blue
732 private GradientVisualUnitsType _units = GradientVisualUnitsType.ObjectBoundingBox;
733 private GradientVisualSpreadMethodType _spreadMethod = GradientVisualSpreadMethodType.Pad;
736 /// Get or set the start position of a linear gradient.
737 /// Mandatory for Linear.
739 public Vector2 StartPosition
743 return _startPosition;
747 _startPosition = value;
752 /// Get or set the end position of a linear gradient.
753 /// Mandatory for Linear.
755 public Vector2 EndPosition
763 _endPosition = value;
768 /// Get or set the center point of a radial gradient.
769 /// Mandatory for Radial.
771 public Vector2 Center
784 /// Get or set the size of the radius of a radial gradient.
785 /// Mandatory for Radial.
800 /// Get or set all the stop offsets.
801 /// A PropertyArray of float.
802 /// If not supplied, default is 0.0f and 1.0f.
804 public PropertyArray StopOffset
817 /// Get or set the color at the stop offsets.
818 /// A PropertyArray of Color.
819 /// At least 2 values required to show a gradient.
821 public PropertyArray StopColor
834 /// Get or set defines the coordinate system for certain attributes of the points in a gradient.
835 /// If not supplied, default is GradientVisualUnitsType.OBJECT_BOUNDING_BOX.
837 public GradientVisualUnitsType Units
850 /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
851 /// If not supplied, default is GradientVisualSpreadMethodType.PAD.
853 public GradientVisualSpreadMethodType SpreadMethod
857 return _spreadMethod;
861 _spreadMethod = value;
865 protected override void ComposingPropertyMap()
867 if (_startPosition != Vector2.Zero && _endPosition != Vector2.Zero && _center != Vector2.Zero
868 && _radius > 0.000001f && _stopColor != null)
870 _outputVisualMap = new PropertyMap();
871 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
872 _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition));
873 _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition));
874 _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center));
875 _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue(_radius));
877 if (_stopOffset != null)
879 _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset));
882 _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
883 _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units));
884 _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod));
890 /// A class encapsulating the property map of a mesh visual.
892 public class MeshVisualMap : VisualMap
894 public MeshVisualMap() : base()
898 private string _objectURL = "";
899 private string _materialtURL = "";
900 private string _texturesPath = "";
901 private MeshVisualShadingModeValue _shadingMode = MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting;
902 private bool _useMipmapping = true;
903 private bool _useSoftNormals = true;
904 private Vector3 _lightPosition = null; //default center of screen
907 /// Get or set the location of the ".obj" file.
909 public string ObjectURL
922 /// Get or set the location of the ".mtl" file.
923 /// If not specified, then a textureless object is assumed.
925 public string MaterialtURL
929 return _materialtURL;
933 _materialtURL = value;
938 /// Get or set path to the directory the textures (including gloss and normal) are stored in.
939 /// Mandatory if using material.
941 public string TexturesPath
945 return _texturesPath;
949 _texturesPath = value;
954 /// Get or set the type of shading mode that the mesh will use.
955 /// If anything the specified shading mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.
956 /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING first).
958 public MeshVisualShadingModeValue ShadingMode
966 _shadingMode = value;
971 /// Get or set whether to use mipmaps for textures or not.
972 /// If not specified, the default is true.
974 public bool UseMipmapping
978 return _useMipmapping;
982 _useMipmapping = value;
987 /// Get or set whether to average normals at each point to smooth textures or not.
988 /// If not specified, the default is true.
990 public bool UseSoftNormals
994 return _useSoftNormals;
998 _useSoftNormals = value;
1003 /// Get or set the position, in stage space, of the point light that applies lighting to the model.
1004 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1005 /// and using all zeroes will place the light at the top left corner.
1006 /// If not specified, the default is an offset outwards from the center of the screen.
1008 public Vector3 LightPosition
1012 return _lightPosition;
1016 _lightPosition = value;
1020 protected override void ComposingPropertyMap()
1022 if (_objectURL != "")
1024 _outputVisualMap = new PropertyMap();
1025 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
1026 _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
1028 if (_materialtURL != "" && _texturesPath != "")
1030 _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL));
1031 _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath));
1034 _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode));
1035 _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue(_useMipmapping));
1036 _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue(_useSoftNormals));
1038 if (_lightPosition != null)
1040 _outputVisualMap.Add(MeshVisualProperty.LightPosition, new PropertyValue(_lightPosition));
1047 /// A class encapsulating the property map of a primetive visual.
1049 public class PrimitiveVisualMap : VisualMap
1051 public PrimitiveVisualMap() : base()
1055 private PrimitiveVisualShapeType _shape = PrimitiveVisualShapeType.Sphere;
1056 private Color _mixColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
1057 private int _slices = 128;
1058 private int _stacks = 128;
1059 private float _scaleTopRadius = 1.0f;
1060 private float _scaleBottomRadius = 1.5f;
1061 private float _scaleHeight = 3.0f;
1062 private float _scaleRadius = 1.0f;
1063 private Vector3 _scaleDimensions = Vector3.One;
1064 private float _bevelPercentage = 0.0f;
1065 private float _bevelSmoothness = 0.0f;
1066 private Vector3 _lightPosition = null; // default ?? center of screen
1069 /// Get or set the specific shape to render.
1070 /// If not specified, the default is PrimitiveVisualShapeType.SPHERE.
1072 public PrimitiveVisualShapeType Shape
1085 /// Get or set the color of the shape.
1086 /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).
1087 /// Applies to ALL shapes.
1089 public Color MixColor
1102 /// Get or set the number of slices as you go around the shape.
1103 /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.
1104 /// If not specified, the default is 128.
1105 /// The range is from 1 to 255.
1120 /// Get or set the number of stacks as you go down the shape.
1121 /// For spheres, 'stacks' determines how many layers there are as you go down the object.
1122 /// If not specified, the default is 128.
1123 /// The range is from 1 to 255.
1138 /// Get or set the scale of the radius of the top circle of a conical frustrum.
1139 /// If not specified, the default is 1.0f.
1140 /// Applies to: - PrimitiveVisualShapeType.CONICAL_FRUSTRUM
1141 /// Only values greater than or equal to 0.0f are accepted.
1143 public float ScaleTopRadius
1147 return _scaleTopRadius;
1151 _scaleTopRadius = value;
1156 /// Get or set the scale of the radius of the bottom circle of a conical frustrum.
1157 /// If not specified, the default is 1.5f.
1158 /// Applies to: - PrimitiveVisualShapeType.CONICAL_FRUSTRUM
1159 /// - PrimitiveVisualShapeType.CONE
1160 /// Only values greater than or equal to 0.0f are accepted.
1162 public float ScaleBottomRadius
1166 return _scaleBottomRadius;
1170 _scaleBottomRadius = value;
1175 /// Get or set the scale of the height of a conic.
1176 /// If not specified, the default is 3.0f.
1178 /// - Shape::CONICAL_FRUSTRUM
1180 /// - Shape::CYLINDER
1181 /// Only values greater than or equal to 0.0f are accepted.
1183 public float ScaleHeight
1187 return _scaleHeight;
1191 _scaleHeight = value;
1196 /// Get or set the scale of the radius of a cylinder.
1197 /// If not specified, the default is 1.0f.
1199 /// - Shape::CYLINDER
1200 /// Only values greater than or equal to 0.0f are accepted.
1202 public float ScaleRadius
1206 return _scaleRadius;
1210 _scaleRadius = value;
1215 /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.
1216 /// If not specified, the default is Vector3.One.
1219 /// - Shape::OCTAHEDRON
1220 /// - Shape::BEVELLED_CUBE
1221 /// Each vector3 parameter should be greater than or equal to 0.0f.
1223 public Vector3 ScaleDimensions
1227 return _scaleDimensions;
1231 _scaleDimensions = value;
1236 /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.
1237 /// Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube.
1238 /// If not specified, the default is 0.0f (no bevel).
1240 /// - Shape::BEVELLED_CUBE
1241 /// The range is from 0.0f to 1.0f.
1243 public float BevelPercentage
1247 return _bevelPercentage;
1251 _bevelPercentage = value;
1256 /// Get or set defines how smooth the bevelled edges should be.
1257 /// If not specified, the default is 0.0f (sharp edges).
1259 /// - Shape::BEVELLED_CUBE
1260 /// The range is from 0.0f to 1.0f.
1262 public float BevelSmoothness
1266 return _bevelSmoothness;
1270 _bevelSmoothness = value;
1275 /// Get or set the position, in stage space, of the point light that applies lighting to the model.
1276 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1277 /// and using all zeroes will place the light at the top left corner.
1278 /// If not specified, the default is an offset outwards from the center of the screen.
1279 /// Applies to ALL shapes.
1281 public Vector3 LightPosition
1285 return _lightPosition;
1289 _lightPosition = value;
1293 protected override void ComposingPropertyMap()
1295 _outputVisualMap = new PropertyMap(); ;
1296 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
1297 _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape));
1298 _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColor));
1299 _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue(_slices));
1300 _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue(_stacks));
1301 _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue(_scaleTopRadius));
1302 _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue(_scaleBottomRadius));
1303 _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue(_scaleHeight));
1304 _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue(_scaleRadius));
1305 _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions));
1306 _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue(_bevelPercentage));
1307 _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue(_bevelSmoothness));
1309 if (_lightPosition != null)
1311 _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition));
1317 /// A class encapsulating the property map of a n-patch image visual.
1319 public class NPatchVisualMap : VisualMap
1321 public NPatchVisualMap() : base()
1325 private string _url = "";
1326 private bool _borderOnly = false;
1327 private Rectangle _border = new Rectangle(0, 0, 0, 0);
1330 /// Get or set the URL of the image.
1345 /// Get or set whether to draws the borders only(If true).
1346 /// If not specified, the default is false.
1347 /// For N-Patch images only.
1349 public bool BorderOnly
1357 _borderOnly = value;
1362 /// The border of the image in the order: left, right, bottom, top.
1364 public Rectangle Border
1376 protected override void ComposingPropertyMap()
1380 _outputVisualMap = new PropertyMap();
1381 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1382 _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
1383 _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly));
1384 _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
1391 public enum WrapModeType
1399 public enum GradientVisualUnitsType
1405 public enum GradientVisualSpreadMethodType
1412 public enum MeshVisualShadingModeValue
1414 TexturelessWithDiffuseLighting,
1415 TexturedWithSpecularLighting,
1416 TexturedWithDetailedSpecularLighting
1419 public enum PrimitiveVisualShapeType
1430 public enum FittingModeType
1438 public enum SamplingModeType
1449 public enum VisualTransformPolicyType
1455 public enum AlignType
1468 public enum VisualTransformPropertyType
1478 public struct Visual
1493 public struct Property
1495 public static readonly int Type = NDalic.VISUAL_PROPERTY_TYPE;
1496 public static readonly int Shader = NDalic.VISUAL_PROPERTY_SHADER;
1497 public static readonly int Transform = NDalic.VISUAL_PROPERTY_TRANSFORM;
1498 public static readonly int PremultipliedAlpha = NDalic.VISUAL_PROPERTY_PREMULTIPLIED_ALPHA;
1499 public static readonly int MixColor = NDalic.VISUAL_PROPERTY_MIX_COLOR;
1502 public struct ShaderProperty
1504 public static readonly int VertexShader = NDalic.VISUAL_SHADER_VERTEX;
1505 public static readonly int FragmentShader = NDalic.VISUAL_SHADER_FRAGMENT;
1506 public static readonly int ShaderSubdivideGridX = NDalic.VISUAL_SHADER_SUBDIVIDE_GRID_X;
1507 public static readonly int ShaderSubdivideGridY = NDalic.VISUAL_SHADER_SUBDIVIDE_GRID_Y;
1508 public static readonly int ShaderHints = NDalic.VISUAL_SHADER_HINTS;
1512 public struct BorderVisualProperty
1514 public static readonly int Color = NDalic.BORDER_VISUAL_COLOR;
1515 public static readonly int Size = NDalic.BORDER_VISUAL_SIZE;
1516 public static readonly int AntiAliasing = NDalic.BORDER_VISUAL_ANTI_ALIASING;
1519 public struct ColorVisualProperty
1521 public static readonly int MixColor = NDalic.COLOR_VISUAL_MIX_COLOR;
1524 public struct GradientVisualProperty
1526 public static readonly int StartPosition = NDalic.GRADIENT_VISUAL_START_POSITION;
1527 public static readonly int EndPosition = NDalic.GRADIENT_VISUAL_END_POSITION;
1528 public static readonly int Center = NDalic.GRADIENT_VISUAL_CENTER;
1529 public static readonly int Radius = NDalic.GRADIENT_VISUAL_RADIUS;
1530 public static readonly int StopOffset = NDalic.GRADIENT_VISUAL_STOP_OFFSET;
1531 public static readonly int StopColor = NDalic.GRADIENT_VISUAL_STOP_COLOR;
1532 public static readonly int Units = NDalic.GRADIENT_VISUAL_UNITS;
1533 public static readonly int SpreadMethod = NDalic.GRADIENT_VISUAL_SPREAD_METHOD;
1536 public struct ImageVisualProperty
1538 public static readonly int URL = NDalic.IMAGE_VISUAL_URL;
1539 public static readonly int FittingMode = NDalic.IMAGE_VISUAL_FITTING_MODE;
1540 public static readonly int SamplingMode = NDalic.IMAGE_VISUAL_SAMPLING_MODE;
1541 public static readonly int DesiredWidth = NDalic.IMAGE_VISUAL_DESIRED_WIDTH;
1542 public static readonly int DesiredHeight = NDalic.IMAGE_VISUAL_DESIRED_HEIGHT;
1543 public static readonly int SynchronousLoading = NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING;
1544 public static readonly int BorderOnly = NDalic.IMAGE_VISUAL_BORDER_ONLY;
1545 public static readonly int PixelArea = NDalic.IMAGE_VISUAL_PIXEL_AREA;
1546 public static readonly int WrapModeU = NDalic.IMAGE_VISUAL_WRAP_MODE_U;
1547 public static readonly int WrapModeV = NDalic.IMAGE_VISUAL_WRAP_MODE_V;
1550 public struct MeshVisualProperty
1552 public static readonly int ObjectURL = NDalic.MESH_VISUAL_OBJECT_URL;
1553 public static readonly int MaterialtURL = NDalic.MESH_VISUAL_MATERIAL_URL;
1554 public static readonly int TexturesPath = NDalic.MESH_VISUAL_TEXTURES_PATH;
1555 public static readonly int ShadingMode = NDalic.MESH_VISUAL_SHADING_MODE;
1556 public static readonly int UseMipmapping = NDalic.MESH_VISUAL_USE_MIPMAPPING;
1557 public static readonly int UseSoftNormals = NDalic.MESH_VISUAL_USE_SOFT_NORMALS;
1558 public static readonly int LightPosition = NDalic.MESH_VISUAL_LIGHT_POSITION;
1561 public struct PrimitiveVisualProperty
1563 public static readonly int Shape = NDalic.PRIMITIVE_VISUAL_SHAPE;
1564 public static readonly int MixColor = NDalic.PRIMITIVE_VISUAL_MIX_COLOR;
1565 public static readonly int Slices = NDalic.PRIMITIVE_VISUAL_SLICES;
1566 public static readonly int Stacks = NDalic.PRIMITIVE_VISUAL_STACKS;
1567 public static readonly int ScaleTopRadius = NDalic.PRIMITIVE_VISUAL_SCALE_TOP_RADIUS;
1568 public static readonly int ScaleBottomRadius = NDalic.PRIMITIVE_VISUAL_SCALE_BOTTOM_RADIUS;
1569 public static readonly int ScaleHeight = NDalic.PRIMITIVE_VISUAL_SCALE_HEIGHT;
1570 public static readonly int ScaleRadius = NDalic.PRIMITIVE_VISUAL_SCALE_RADIUS;
1571 public static readonly int ScaleDimensions = NDalic.PRIMITIVE_VISUAL_SCALE_DIMENSIONS;
1572 public static readonly int BevelPercentage = NDalic.PRIMITIVE_VISUAL_BEVEL_PERCENTAGE;
1573 public static readonly int BevelSmoothness = NDalic.PRIMITIVE_VISUAL_BEVEL_SMOOTHNESS;
1574 public static readonly int LightPosition = NDalic.PRIMITIVE_VISUAL_LIGHT_POSITION;
1577 public struct TextVisualProperty
1579 public static readonly int Text = NDalic.TEXT_VISUAL_TEXT;
1580 public static readonly int FontFamily = NDalic.TEXT_VISUAL_FONT_FAMILY;
1581 public static readonly int FontStyle = NDalic.TEXT_VISUAL_FONT_STYLE;
1582 public static readonly int PointSize = NDalic.TEXT_VISUAL_POINT_SIZE;
1583 public static readonly int MultiLine = NDalic.TEXT_VISUAL_MULTI_LINE;
1584 public static readonly int HorizontalAlignment = NDalic.TEXT_VISUAL_HORIZONTAL_ALIGNMENT;
1585 public static readonly int VerticalAlignment = NDalic.TEXT_VISUAL_VERTICAL_ALIGNMENT;
1586 public static readonly int TextColor = NDalic.TEXT_VISUAL_TEXT_COLOR;
1587 public static readonly int EnableMarkup = NDalic.TEXT_VISUAL_ENABLE_MARKUP;
1589 public struct NpatchImageVisualProperty
1591 public static readonly int URL = NDalic.IMAGE_VISUAL_URL;
1592 public static readonly int FittingMode = NDalic.IMAGE_VISUAL_FITTING_MODE;
1593 public static readonly int SamplingMode = NDalic.IMAGE_VISUAL_SAMPLING_MODE;
1594 public static readonly int DesiredWidth = NDalic.IMAGE_VISUAL_DESIRED_WIDTH;
1595 public static readonly int DesiredHeight = NDalic.IMAGE_VISUAL_DESIRED_HEIGHT;
1596 public static readonly int SynchronousLoading = NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING;
1597 public static readonly int BorderOnly = NDalic.IMAGE_VISUAL_BORDER_ONLY;
1598 public static readonly int PixelArea = NDalic.IMAGE_VISUAL_PIXEL_AREA;
1599 public static readonly int WrapModeU = NDalic.IMAGE_VISUAL_WRAP_MODE_U;
1600 public static readonly int WrapModeV = NDalic.IMAGE_VISUAL_WRAP_MODE_V;
1601 public static readonly int Border = NDalic.IMAGE_VISUAL_WRAP_MODE_V + 1;