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 = null;
27 private Vector2 _visualOffset = null;
28 private Vector2 _visualOffsetPolicy = null;
29 private Vector2 _visualSizePolicy = null;
30 private Visual.AlignType? _visualOrigin = null;
31 private Visual.AlignType? _visualAnchorPoint = null;
33 private PropertyMap _visualTransformMap = null;
35 private float _depthIndex = 0.0f;
36 protected PropertyMap _outputVisualMap = null;
43 public int VisualIndex
48 public VisualView Parent
59 /// Get or set size of the visual.<br>
60 /// It can be either relative (percentage of the parent)
61 /// or absolute (in world units).<br>
77 /// Get or set offset of the visual.<br>
78 /// It can be either relative (percentage of the parent)
79 /// or absolute (in world units).<br>
81 public Vector2 Position
89 _visualOffset = value;
95 /// Get or set offset policy of the visual.<br>
96 /// Indicates which components of the offset are relative
97 /// (percentage of the parent) or absolute (in world units).<br>
98 /// 0 indicates the component is relative, and 1 absolute.<br>
100 public Vector2 PositionPolicy
104 return _visualOffsetPolicy;
108 _visualOffsetPolicy = value;
114 /// Get or set size policy of the visual.<br>
115 /// Indicates which components of the size are relative
116 /// (percentage of the parent) or absolute (in world units).<br>
117 /// 0 indicates the component is relative, and 1 absolute.<br>
119 public Vector2 SizePolicy
123 return _visualSizePolicy;
127 _visualSizePolicy = value;
133 /// Get or set the origin of the visual within its control area.
135 public Visual.AlignType Origin
139 return _visualOrigin ?? (Visual.AlignType)(-1);
143 _visualOrigin = value;
149 /// Get or set the anchor-point of the visual.
151 public Visual.AlignType AnchorPoint
155 return _visualAnchorPoint ?? (Visual.AlignType)(-1);
159 _visualAnchorPoint = value;
165 /// Get or set the depth index of the visual.
167 public float DepthIndex
179 private void ComposingTransformMap()
181 _visualTransformMap = new PropertyMap();
182 if (_visualSize != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Size, new PropertyValue(_visualSize)); }
183 if (_visualOffset != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(_visualOffset)); }
184 if (_visualOffsetPolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(_visualOffsetPolicy)); }
185 if (_visualSizePolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(_visualSizePolicy)); }
186 if (_visualOrigin != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin)); }
187 if (_visualAnchorPoint != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint)); }
191 /// Get the transform map used by the visual.
193 public PropertyMap OutputTransformMap
197 ComposingTransformMap();
198 return _visualTransformMap;
202 protected virtual void ComposingPropertyMap()
204 _outputVisualMap = new PropertyMap();
208 /// Get the property map to create the visual.
210 public PropertyMap OutputVisualMap
214 ComposingPropertyMap();
215 return _outputVisualMap;
219 public void UpdateVisual()
223 Tizen.Log.Debug("NUI", "UpdateVisual()! VisualIndex=" + VisualIndex);
224 Parent.UpdateVisual(VisualIndex, Name, this);
228 Tizen.Log.Debug("NUI", "VisualIndex was not set");
235 /// A class encapsulating the property map of a image visual.
237 public class ImageVisual : VisualMap
239 public ImageVisual() : base()
243 private string _url = null;
244 private FittingModeType? _fittingMode = null;
245 private SamplingModeType? _samplingMode = null;
246 private int? _desiredWidth = null;
247 private int? _desiredHeight = null;
248 private bool? _synchronousLoading = false;
249 private bool? _borderOnly = null;
250 private Vector4 _pixelArea = null;
251 private WrapModeType? _wrapModeU = null;
252 private WrapModeType? _wrapModeV = null;
255 /// Get or set the URL of the image.
271 /// Get or set fitting options, used when resizing images to fit desired dimensions.<br>
272 /// If not supplied, default is FittingMode::SHRINK_TO_FIT.<br>
273 /// For Normal Quad images only.<br>
275 public FittingModeType FittingMode
279 return _fittingMode ?? (FittingModeType)(-1);
283 _fittingMode = value;
289 /// Get or set filtering options, used when resizing images to sample original pixels.<br>
290 /// If not supplied, default is SamplingMode::BOX.<br>
291 /// For Normal Quad images only.<br>
293 public SamplingModeType SamplingMode
297 return _samplingMode ?? (SamplingModeType)(-1);
301 _samplingMode = value;
307 /// Get or set the desired image width.<br>
308 /// If not specified, the actual image width is used.<br>
309 /// For Normal Quad images only.<br>
311 public int DesiredWidth
315 return _desiredWidth ?? (-1);
319 _desiredWidth = value;
325 /// Get or set the desired image height.<br>
326 /// If not specified, the actual image height is used.<br>
327 /// For Normal Quad images only.<br>
329 public int DesiredHeight
333 return _desiredHeight ?? (-1);
337 _desiredHeight = value;
343 /// Get or set whether to load the image synchronously.<br>
344 /// If not specified, the default is false, i.e. the image is loaded asynchronously.<br>
345 /// For Normal Quad images only.<br>
347 public bool SynchronousLoading
351 return _synchronousLoading ?? false;
355 _synchronousLoading = value;
361 /// Get or set whether to draws the borders only(If true).<br>
362 /// If not specified, the default is false.<br>
363 /// For N-Patch images only.<br>
365 public bool BorderOnly
369 return _borderOnly ?? false;
379 /// Get or set the image area to be displayed.<br>
380 /// It is a rectangular area.<br>
381 /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.<br>
382 /// If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.<br>
383 /// For For Normal QUAD image only.<br>
385 public Vector4 PixelArea
399 /// Get or set the wrap mode for u coordinate.<br>
400 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br>
401 /// If not specified, the default is CLAMP.<br>
402 /// For Normal QUAD image only.<br>
404 public WrapModeType WrapModeU
408 return _wrapModeU ?? (WrapModeType)(-1);
418 /// Get or set the wrap mode for v coordinate.<br>
419 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br>
420 /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.<br>
421 /// If not specified, the default is CLAMP.<br>
422 /// For Normal QUAD image only.
424 public WrapModeType WrapModeV
428 return _wrapModeV ?? (WrapModeType)(-1);
437 protected override void ComposingPropertyMap()
439 _outputVisualMap = new PropertyMap();
440 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
441 if (_url != null) { _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url)); }
442 if (_fittingMode != null) { _outputVisualMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode)); }
443 if (_samplingMode != null) { _outputVisualMap.Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode)); }
444 if (_desiredWidth != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredWidth, new PropertyValue((int)_desiredWidth)); }
445 if (_desiredHeight != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredHeight, new PropertyValue((int)_desiredHeight)); }
446 if (_synchronousLoading != null) { _outputVisualMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
447 if (_borderOnly != null) { _outputVisualMap.Add(ImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
448 if (_pixelArea != null) { _outputVisualMap.Add(ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea)); }
449 if (_wrapModeU != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU)); }
450 if (_wrapModeV != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV)); }
456 /// A class encapsulating the property map of a text visual.
458 public class TextVisual : VisualMap
460 public TextVisual() : base()
464 private string _text = null;
465 private string _fontFamily = null;
466 private PropertyMap _fontStyle = null;
467 private float? _pointSize = null;
468 private bool? _multiLine = null;
469 private string _horizontalAlignment = null;
470 private string _verticalAlignment = null;
471 private Color _textColor = null;
472 private bool? _enableMarkup = null;
475 /// Get or set the text to display in UTF-8 format.
491 /// Get or set the requested font family to use.
493 public string FontFamily
507 /// Get or set the requested font style to use.
509 public PropertyMap FontStyle
523 /// Get or set the size of font in points.
525 public float PointSize
529 return _pointSize ?? (-1.0f);
539 /// Get or set the single-line or multi-line layout option.
541 public bool MultiLine
545 return _multiLine ?? false;
555 /// Get or set the line horizontal alignment.<br>
556 /// If not specified, the default is BEGIN.<br>
558 public string HorizontalAlignment
562 return _horizontalAlignment;
566 _horizontalAlignment = value;
572 /// Get or set the line vertical alignment.<br>
573 /// If not specified, the default is TOP.<br>
575 public string VerticalAlignment
579 return _verticalAlignment;
583 _verticalAlignment = value;
589 /// Get or set the color of the text.
591 public Color TextColor
605 /// Get or set whether the mark-up processing is enabled.
607 public bool EnableMarkup
611 return _enableMarkup ?? false;
615 _enableMarkup = value;
620 protected override void ComposingPropertyMap()
622 _outputVisualMap = new PropertyMap();
623 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
624 if (_text != null) { _outputVisualMap.Add(TextVisualProperty.Text, new PropertyValue(_text)); }
625 if (_fontFamily != null) { _outputVisualMap.Add(TextVisualProperty.FontFamily, new PropertyValue(_fontFamily)); }
626 if (_fontStyle != null) { _outputVisualMap.Add(TextVisualProperty.FontStyle, new PropertyValue(_fontStyle)); }
627 if (_pointSize != null) { _outputVisualMap.Add(TextVisualProperty.PointSize, new PropertyValue((float)_pointSize)); }
628 if (_multiLine != null) { _outputVisualMap.Add(TextVisualProperty.MultiLine, new PropertyValue((bool)_multiLine)); }
629 if (_horizontalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment)); }
630 if (_verticalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment)); }
631 if (_textColor != null) { _outputVisualMap.Add(TextVisualProperty.TextColor, new PropertyValue(_textColor)); }
632 if (_enableMarkup != null) { _outputVisualMap.Add(TextVisualProperty.EnableMarkup, new PropertyValue((bool)_enableMarkup)); }
637 /// A class encapsulating the property map of a border visual.
639 public class BorderVisual : VisualMap
641 public BorderVisual() : base()
645 private Color _color = null;
646 private float? _size = null;
647 private bool? _antiAliasing = null;
650 /// Get or set the color of the border.
666 /// Get or set the width of the border (in pixels).
668 public float BorderSize
672 return _size ?? (-1.0f);
682 /// Get or set whether anti-aliasing of the border is required.<br>
683 /// If not supplied, default is false.<br>
685 public bool AntiAliasing
689 return _antiAliasing ?? false;
693 _antiAliasing = value;
698 protected override void ComposingPropertyMap()
700 _outputVisualMap = new PropertyMap();
701 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
702 if (_color != null) { _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color)); }
703 if (_size != null) { _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue((float)_size)); }
704 if (_antiAliasing != null) { _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue((bool)_antiAliasing)); }
709 /// A class encapsulating the property map of a color visual.
711 public class ColorVisual : VisualMap
713 public ColorVisual() : base()
717 private Color _mixColor = null;
720 /// Get or set the solid color required.
722 public Color MixColor
735 protected override void ComposingPropertyMap()
737 _outputVisualMap = new PropertyMap();
738 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
739 if (_mixColor != null) { _outputVisualMap.Add(ColorVisualProperty.MixColor, new PropertyValue(_mixColor)); }
744 /// A class encapsulating the property map of a gradient visual.
746 public class GradientVisual : VisualMap
748 public GradientVisual() : base()
752 private Vector2 _startPosition = null;
753 private Vector2 _endPosition = null;
754 private Vector2 _center = null;
755 private float? _radius = null;
756 private PropertyArray _stopOffset = null;
757 private PropertyArray _stopColor = null;
758 private GradientVisualUnitsType? _units = null;
759 private GradientVisualSpreadMethodType? _spreadMethod = null;
762 /// Get or set the start position of a linear gradient.<br>
763 /// Mandatory for Linear.<br>
765 public Vector2 StartPosition
769 return _startPosition;
773 _startPosition = value;
779 /// Get or set the end position of a linear gradient.<br>
780 /// Mandatory for Linear.<br>
782 public Vector2 EndPosition
790 _endPosition = value;
796 /// Get or set the center point of a radial gradient.<br>
797 /// Mandatory for Radial.<br>
799 public Vector2 Center
813 /// Get or set the size of the radius of a radial gradient.<br>
814 /// Mandatory for Radial.<br>
820 return _radius ?? (-1.0f);
830 /// Get or set all the stop offsets.<br>
831 /// A PropertyArray of float.<br>
832 /// If not supplied, default is 0.0f and 1.0f.<br>
834 public PropertyArray StopOffset
848 /// Get or set the color at the stop offsets.<br>
849 /// A PropertyArray of Color.<br>
850 /// At least 2 values required to show a gradient.<br>
852 public PropertyArray StopColor
866 /// Get or set defines the coordinate system for certain attributes of the points in a gradient.<br>
867 /// If not supplied, default is GradientVisualUnitsType.OBJECT_BOUNDING_BOX.<br>
869 public GradientVisualUnitsType Units
873 return _units ?? (GradientVisualUnitsType)(-1);
883 /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.<br>
884 /// If not supplied, default is GradientVisualSpreadMethodType.PAD.<br>
886 public GradientVisualSpreadMethodType SpreadMethod
890 return _spreadMethod ?? (GradientVisualSpreadMethodType)(-1);
894 _spreadMethod = value;
899 protected override void ComposingPropertyMap()
901 _outputVisualMap = new PropertyMap();
902 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
903 if (_startPosition != null) { _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition)); }
904 if (_endPosition != null) { _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition)); }
905 if (_center != null) { _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center)); }
906 if (_radius != null) { _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue((float)_radius)); }
907 if (_stopOffset != null) { _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset)); }
908 if (_stopColor != null) { _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor)); }
909 if (_units != null) { _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units)); }
910 if (_spreadMethod != null) { _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod)); }
915 /// A class encapsulating the property map of a mesh visual.
917 public class MeshVisual : VisualMap
919 public MeshVisual() : base()
923 private string _objectURL = null;
924 private string _materialtURL = null;
925 private string _texturesPath = null;
926 private MeshVisualShadingModeValue? _shadingMode = null;
927 private bool? _useMipmapping = null;
928 private bool? _useSoftNormals = null;
929 private Vector3 _lightPosition = null;
932 /// Get or set the location of the ".obj" file.
934 public string ObjectURL
948 /// Get or set the location of the ".mtl" file.<br>
949 /// If not specified, then a textureless object is assumed.<br>
951 public string MaterialtURL
955 return _materialtURL;
959 _materialtURL = value;
965 /// Get or set path to the directory the textures (including gloss and normal) are stored in.<br>
966 /// Mandatory if using material.<br>
968 public string TexturesPath
972 return _texturesPath;
976 _texturesPath = value;
982 /// Get or set the type of shading mode that the mesh will use.<br>
983 /// 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.<br>
984 /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING first).<br>
986 public MeshVisualShadingModeValue ShadingMode
990 return _shadingMode??(MeshVisualShadingModeValue)(-1);
994 _shadingMode = value;
1000 /// Get or set whether to use mipmaps for textures or not.<br>
1001 /// If not specified, the default is true.<br>
1003 public bool UseMipmapping
1007 return _useMipmapping??false;
1011 _useMipmapping = value;
1017 /// Get or set whether to average normals at each point to smooth textures or not.<br>
1018 /// If not specified, the default is true.<br>
1020 public bool UseSoftNormals
1024 return _useSoftNormals??false;
1028 _useSoftNormals = value;
1034 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1035 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1036 /// and using all zeroes will place the light at the top left corner.<br>
1037 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1039 public Vector3 LightPosition
1043 return _lightPosition;
1047 _lightPosition = value;
1052 protected override void ComposingPropertyMap()
1054 _outputVisualMap = new PropertyMap();
1055 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
1056 if (_objectURL != null) { _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL)); }
1057 if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
1058 if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
1059 if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
1060 if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
1061 if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
1066 /// A class encapsulating the property map of a primetive visual.
1068 public class PrimitiveVisual : VisualMap
1070 public PrimitiveVisual() : base()
1074 private PrimitiveVisualShapeType? _shape = null;
1075 private Color _mixColor = null;
1076 private int? _slices = null;
1077 private int? _stacks = null;
1078 private float? _scaleTopRadius = null;
1079 private float? _scaleBottomRadius = null;
1080 private float? _scaleHeight = null;
1081 private float? _scaleRadius = null;
1082 private Vector3 _scaleDimensions = null;
1083 private float? _bevelPercentage = null;
1084 private float? _bevelSmoothness = null;
1085 private Vector3 _lightPosition = null;
1088 /// Get or set the specific shape to render.<br>
1089 /// If not specified, the default is PrimitiveVisualShapeType.SPHERE.<br>
1091 public PrimitiveVisualShapeType Shape
1095 return _shape??(PrimitiveVisualShapeType)(-1);
1105 /// Get or set the color of the shape.<br>
1106 /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).<br>
1107 /// Applies to ALL shapes.<br>
1109 public Color MixColor
1123 /// Get or set the number of slices as you go around the shape.<br>
1124 /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.<br>
1125 /// If not specified, the default is 128.<br>
1126 /// The range is from 1 to 255.<br>
1132 return _slices??(-1);
1142 /// Get or set the number of stacks as you go down the shape.<br>
1143 /// For spheres, 'stacks' determines how many layers there are as you go down the object.<br>
1144 /// If not specified, the default is 128.<br>
1145 /// The range is from 1 to 255.<br>
1151 return _stacks??(-1);
1161 /// Get or set the scale of the radius of the top circle of a conical frustrum.<br>
1162 /// If not specified, the default is 1.0f.<br>
1163 /// Applies to: - PrimitiveVisualShapeType.CONICAL_FRUSTRUM<br>
1164 /// Only values greater than or equal to 0.0f are accepted.<br>
1166 public float ScaleTopRadius
1170 return _scaleTopRadius ?? (-1.0f);
1174 _scaleTopRadius = value;
1180 /// Get or set the scale of the radius of the bottom circle of a conical frustrum.<br>
1181 /// If not specified, the default is 1.5f.<br>
1182 /// Applies to: - PrimitiveVisualShapeType.CONICAL_FRUSTRUM<br>
1183 /// - PrimitiveVisualShapeType.CONE<br>
1184 /// Only values greater than or equal to 0.0f are accepted.<br>
1186 public float ScaleBottomRadius
1190 return _scaleBottomRadius ?? (-1.0f);
1194 _scaleBottomRadius = value;
1200 /// Get or set the scale of the height of a conic.<br>
1201 /// If not specified, the default is 3.0f.<br>
1203 /// - Shape::CONICAL_FRUSTRUM<br>
1204 /// - Shape::CONE<br>
1205 /// - Shape::CYLINDER<br>
1206 /// Only values greater than or equal to 0.0f are accepted.<br>
1208 public float ScaleHeight
1212 return _scaleHeight??(-1.0f);
1216 _scaleHeight = value;
1222 /// Get or set the scale of the radius of a cylinder.<br>
1223 /// If not specified, the default is 1.0f.<br>
1225 /// - Shape::CYLINDER<br>
1226 /// Only values greater than or equal to 0.0f are accepted.<br>
1228 public float ScaleRadius
1232 return _scaleRadius ?? (-1.0f);
1236 _scaleRadius = value;
1242 /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.<br>
1243 /// If not specified, the default is Vector3.One.<br>
1245 /// - Shape::CUBE<br>
1246 /// - Shape::OCTAHEDRON<br>
1247 /// - Shape::BEVELLED_CUBE<br>
1248 /// Each vector3 parameter should be greater than or equal to 0.0f.<br>
1250 public Vector3 ScaleDimensions
1254 return _scaleDimensions;
1258 _scaleDimensions = value;
1264 /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.<br>
1265 /// 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.<br>
1266 /// If not specified, the default is 0.0f (no bevel).<br>
1268 /// - Shape::BEVELLED_CUBE<br>
1269 /// The range is from 0.0f to 1.0f.<br>
1271 public float BevelPercentage
1275 return _bevelPercentage ?? (-1.0f);
1279 _bevelPercentage = value;
1285 /// Get or set defines how smooth the bevelled edges should be.<br>
1286 /// If not specified, the default is 0.0f (sharp edges).<br>
1288 /// - Shape::BEVELLED_CUBE<br>
1289 /// The range is from 0.0f to 1.0f.<br>
1291 public float BevelSmoothness
1295 return _bevelSmoothness ?? (-1.0f);
1299 _bevelSmoothness = value;
1305 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1306 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1307 /// and using all zeroes will place the light at the top left corner.<br>
1308 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1309 /// Applies to ALL shapes.
1311 public Vector3 LightPosition
1315 return _lightPosition;
1319 _lightPosition = value;
1324 protected override void ComposingPropertyMap()
1326 _outputVisualMap = new PropertyMap(); ;
1327 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
1328 if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
1329 if (_mixColor != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColor)); }
1330 if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
1331 if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
1332 if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
1333 if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
1334 if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
1335 if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
1336 if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
1337 if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
1338 if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
1339 if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
1344 /// A class encapsulating the property map of a n-patch image visual.
1346 public class NPatchVisual : VisualMap
1348 public NPatchVisual() : base()
1352 private string _url = null;
1353 private bool? _borderOnly = null;
1354 private Rectangle _border = null;
1357 /// Get or set the URL of the image.
1373 /// Get or set whether to draws the borders only(If true).<br>
1374 /// If not specified, the default is false.<br>
1375 /// For N-Patch images only.<br>
1377 public bool BorderOnly
1381 return _borderOnly ?? false;
1385 _borderOnly = value;
1391 /// The border of the image in the order: left, right, bottom, top.
1393 public Rectangle Border
1406 protected override void ComposingPropertyMap()
1408 _outputVisualMap = new PropertyMap();
1409 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1410 if (_url != null) { _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url)); }
1411 if (_borderOnly != null) { _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
1412 if (_border != null) { _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); }
1418 /// This specifies wrap mode types
1420 public enum WrapModeType
1429 /// This specifies all kind os types of coordinate system for certain attributes of the points in a gradient.
1431 public enum GradientVisualUnitsType
1438 /// This specifies SpreadMethod types.<br>
1439 /// SpreadMethod defines what happens if the gradient starts or ends inside the bounds of the target rectangle.<br>
1441 public enum GradientVisualSpreadMethodType
1449 /// This specifies shading mode types.
1451 public enum MeshVisualShadingModeValue
1453 TexturelessWithDiffuseLighting,
1454 TexturedWithSpecularLighting,
1455 TexturedWithDetailedSpecularLighting
1459 /// This specifies shape types.
1461 public enum PrimitiveVisualShapeType
1473 /// This specifies fitting mode types. Fitting options, used when resizing images to fit desired dimensions.<br>
1474 /// A fitting mode controls the region of a loaded image to be mapped to the desired image rectangle.<br>
1475 /// All fitting modes preserve the aspect ratio of the image contents.<br>
1477 public enum FittingModeType
1486 /// This specifies sampling mode types. Filtering options, used when resizing images to sample original pixels.<br>
1487 /// A SamplingMode controls how pixels in an input image are sampled and combined to generate each pixel of a destination image during a scaling.<br>
1488 /// NoFilter and Box modes do not guarantee that the output pixel array exactly matches the rectangle specified by the desired dimensions and FittingMode,
1489 /// but all other filter modes do if the desired dimensions are `<=` the raw dimensions of the input image file.<br>
1491 public enum SamplingModeType
1503 /// This specifies policy types that could be used by the transform for the offset or size.
1505 public enum VisualTransformPolicyType
1512 /// This specifies all the transform property types.
1514 public enum VisualTransformPropertyType
1525 /// This specifies visual types.
1527 public struct Visual
1545 /// This specifies visual properties.
1547 public struct Property
1549 public static readonly int Type = NDalic.VISUAL_PROPERTY_TYPE;
1550 public static readonly int Shader = NDalic.VISUAL_PROPERTY_SHADER;
1551 public static readonly int Transform = NDalic.VISUAL_PROPERTY_TRANSFORM;
1552 public static readonly int PremultipliedAlpha = NDalic.VISUAL_PROPERTY_PREMULTIPLIED_ALPHA;
1553 public static readonly int MixColor = NDalic.VISUAL_PROPERTY_MIX_COLOR;
1557 /// This specifies shader properties.
1559 public struct ShaderProperty
1561 public static readonly int VertexShader = NDalic.VISUAL_SHADER_VERTEX;
1562 public static readonly int FragmentShader = NDalic.VISUAL_SHADER_FRAGMENT;
1563 public static readonly int ShaderSubdivideGridX = NDalic.VISUAL_SHADER_SUBDIVIDE_GRID_X;
1564 public static readonly int ShaderSubdivideGridY = NDalic.VISUAL_SHADER_SUBDIVIDE_GRID_Y;
1565 public static readonly int ShaderHints = NDalic.VISUAL_SHADER_HINTS;
1569 /// This specifies Visaul align types.
1571 public enum AlignType
1586 /// This specifies properties of BorderVisual.
1588 public struct BorderVisualProperty
1590 public static readonly int Color = NDalic.BORDER_VISUAL_COLOR;
1591 public static readonly int Size = NDalic.BORDER_VISUAL_SIZE;
1592 public static readonly int AntiAliasing = NDalic.BORDER_VISUAL_ANTI_ALIASING;
1596 /// This specifies properties of ColorVisual.
1598 public struct ColorVisualProperty
1600 public static readonly int MixColor = NDalic.COLOR_VISUAL_MIX_COLOR;
1604 /// This specifies properties of GradientVisual.
1606 public struct GradientVisualProperty
1608 public static readonly int StartPosition = NDalic.GRADIENT_VISUAL_START_POSITION;
1609 public static readonly int EndPosition = NDalic.GRADIENT_VISUAL_END_POSITION;
1610 public static readonly int Center = NDalic.GRADIENT_VISUAL_CENTER;
1611 public static readonly int Radius = NDalic.GRADIENT_VISUAL_RADIUS;
1612 public static readonly int StopOffset = NDalic.GRADIENT_VISUAL_STOP_OFFSET;
1613 public static readonly int StopColor = NDalic.GRADIENT_VISUAL_STOP_COLOR;
1614 public static readonly int Units = NDalic.GRADIENT_VISUAL_UNITS;
1615 public static readonly int SpreadMethod = NDalic.GRADIENT_VISUAL_SPREAD_METHOD;
1619 /// This specifies properties of ImageVisual.
1621 public struct ImageVisualProperty
1623 public static readonly int URL = NDalic.IMAGE_VISUAL_URL;
1624 public static readonly int FittingMode = NDalic.IMAGE_VISUAL_FITTING_MODE;
1625 public static readonly int SamplingMode = NDalic.IMAGE_VISUAL_SAMPLING_MODE;
1626 public static readonly int DesiredWidth = NDalic.IMAGE_VISUAL_DESIRED_WIDTH;
1627 public static readonly int DesiredHeight = NDalic.IMAGE_VISUAL_DESIRED_HEIGHT;
1628 public static readonly int SynchronousLoading = NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING;
1629 public static readonly int BorderOnly = NDalic.IMAGE_VISUAL_BORDER_ONLY;
1630 public static readonly int PixelArea = NDalic.IMAGE_VISUAL_PIXEL_AREA;
1631 public static readonly int WrapModeU = NDalic.IMAGE_VISUAL_WRAP_MODE_U;
1632 public static readonly int WrapModeV = NDalic.IMAGE_VISUAL_WRAP_MODE_V;
1633 public static readonly int Border = NDalic.IMAGE_VISUAL_BORDER;
1637 /// This specifies properties of MeshVisual.
1639 public struct MeshVisualProperty
1641 public static readonly int ObjectURL = NDalic.MESH_VISUAL_OBJECT_URL;
1642 public static readonly int MaterialtURL = NDalic.MESH_VISUAL_MATERIAL_URL;
1643 public static readonly int TexturesPath = NDalic.MESH_VISUAL_TEXTURES_PATH;
1644 public static readonly int ShadingMode = NDalic.MESH_VISUAL_SHADING_MODE;
1645 public static readonly int UseMipmapping = NDalic.MESH_VISUAL_USE_MIPMAPPING;
1646 public static readonly int UseSoftNormals = NDalic.MESH_VISUAL_USE_SOFT_NORMALS;
1647 public static readonly int LightPosition = NDalic.MESH_VISUAL_LIGHT_POSITION;
1651 /// This specifies properties of PrimitiveVisual.
1653 public struct PrimitiveVisualProperty
1655 public static readonly int Shape = NDalic.PRIMITIVE_VISUAL_SHAPE;
1656 public static readonly int MixColor = NDalic.PRIMITIVE_VISUAL_MIX_COLOR;
1657 public static readonly int Slices = NDalic.PRIMITIVE_VISUAL_SLICES;
1658 public static readonly int Stacks = NDalic.PRIMITIVE_VISUAL_STACKS;
1659 public static readonly int ScaleTopRadius = NDalic.PRIMITIVE_VISUAL_SCALE_TOP_RADIUS;
1660 public static readonly int ScaleBottomRadius = NDalic.PRIMITIVE_VISUAL_SCALE_BOTTOM_RADIUS;
1661 public static readonly int ScaleHeight = NDalic.PRIMITIVE_VISUAL_SCALE_HEIGHT;
1662 public static readonly int ScaleRadius = NDalic.PRIMITIVE_VISUAL_SCALE_RADIUS;
1663 public static readonly int ScaleDimensions = NDalic.PRIMITIVE_VISUAL_SCALE_DIMENSIONS;
1664 public static readonly int BevelPercentage = NDalic.PRIMITIVE_VISUAL_BEVEL_PERCENTAGE;
1665 public static readonly int BevelSmoothness = NDalic.PRIMITIVE_VISUAL_BEVEL_SMOOTHNESS;
1666 public static readonly int LightPosition = NDalic.PRIMITIVE_VISUAL_LIGHT_POSITION;
1670 /// This specifies properties of TextVisual.
1672 public struct TextVisualProperty
1674 public static readonly int Text = NDalic.TEXT_VISUAL_TEXT;
1675 public static readonly int FontFamily = NDalic.TEXT_VISUAL_FONT_FAMILY;
1676 public static readonly int FontStyle = NDalic.TEXT_VISUAL_FONT_STYLE;
1677 public static readonly int PointSize = NDalic.TEXT_VISUAL_POINT_SIZE;
1678 public static readonly int MultiLine = NDalic.TEXT_VISUAL_MULTI_LINE;
1679 public static readonly int HorizontalAlignment = NDalic.TEXT_VISUAL_HORIZONTAL_ALIGNMENT;
1680 public static readonly int VerticalAlignment = NDalic.TEXT_VISUAL_VERTICAL_ALIGNMENT;
1681 public static readonly int TextColor = NDalic.TEXT_VISUAL_TEXT_COLOR;
1682 public static readonly int EnableMarkup = NDalic.TEXT_VISUAL_ENABLE_MARKUP;
1686 /// This specifies properties of NpatchImageVisual.
1688 public struct NpatchImageVisualProperty
1690 public static readonly int URL = NDalic.IMAGE_VISUAL_URL;
1691 public static readonly int FittingMode = NDalic.IMAGE_VISUAL_FITTING_MODE;
1692 public static readonly int SamplingMode = NDalic.IMAGE_VISUAL_SAMPLING_MODE;
1693 public static readonly int DesiredWidth = NDalic.IMAGE_VISUAL_DESIRED_WIDTH;
1694 public static readonly int DesiredHeight = NDalic.IMAGE_VISUAL_DESIRED_HEIGHT;
1695 public static readonly int SynchronousLoading = NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING;
1696 public static readonly int BorderOnly = NDalic.IMAGE_VISUAL_BORDER_ONLY;
1697 public static readonly int PixelArea = NDalic.IMAGE_VISUAL_PIXEL_AREA;
1698 public static readonly int WrapModeU = NDalic.IMAGE_VISUAL_WRAP_MODE_U;
1699 public static readonly int WrapModeV = NDalic.IMAGE_VISUAL_WRAP_MODE_V;
1700 public static readonly int Border = NDalic.IMAGE_VISUAL_WRAP_MODE_V + 1;
1704 /// A class encapsulating the property map of a SVG visual.
1706 public class SVGVisual : VisualMap
1708 public SVGVisual() : base()
1712 private string _url = null;
1727 protected override void ComposingPropertyMap()
1729 _outputVisualMap = new PropertyMap();
1730 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
1731 if (_url != null) { _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url)); }
1736 /// A class encapsulating the property map of a Animated Image(AGIF) visual.
1738 public class AnimatedImageVisual : VisualMap
1740 public AnimatedImageVisual() : base()
1744 private string _url = null;
1759 protected override void ComposingPropertyMap()
1761 _outputVisualMap = new PropertyMap();
1762 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage));
1763 if (_url != null) { _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url)); }
1768 /// A class encapsulating the property map of a visual transition(Animator).
1770 public class AnimatorVisual : VisualMap
1772 public AnimatorVisual() : base()
1776 private string _alphaFunction = null;
1777 private int _startTime = 0;
1778 private int _endTime = 0;
1779 private string _target = null;
1780 private string _propertyIndex = null;
1781 private object _destinationValue = null;
1783 public string AlphaFunction
1787 return _alphaFunction;
1791 _alphaFunction = value;
1795 public int StartTime
1819 public string Target
1831 public string PropertyIndex
1835 return _propertyIndex;
1839 _propertyIndex = value;
1843 public object DestinationValue
1847 return _destinationValue;
1851 _destinationValue = value;
1855 protected override void ComposingPropertyMap()
1857 PropertyMap _animator = new PropertyMap();
1858 _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
1860 PropertyMap _timePeriod = new PropertyMap();
1861 _timePeriod.Add("duration", new PropertyValue((_endTime - _startTime) / 1000.0f));
1862 _timePeriod.Add("delay", new PropertyValue(_startTime / 1000.0f));
1863 _animator.Add("timePeriod", new PropertyValue(_timePeriod));
1865 string _str1 = _propertyIndex.Substring(0, 1);
1866 string _str2 = _propertyIndex.Substring(1);
1867 string _str = _str1.ToLower() + _str2;
1868 dynamic _obj = (object)_destinationValue;
1870 PropertyMap _transition = new PropertyMap();
1871 _transition.Add("target", new PropertyValue(_target));
1872 _transition.Add("property", new PropertyValue(_str));
1873 _transition.Add("targetValue", new PropertyValue(_obj));
1874 _transition.Add("animator", new PropertyValue(_animator));
1876 _outputVisualMap = _transition;