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;
20 using Tizen.NUI.UIComponents;
21 using Tizen.NUI.BaseComponents;
24 /// A class encapsulating the transform map of visual.
26 public class VisualMap
28 private Vector2 _visualSize = null;
29 private Vector2 _visualOffset = null;
30 private Vector2 _visualOffsetPolicy = null;
31 private Vector2 _visualSizePolicy = null;
32 private Visual.AlignType? _visualOrigin = null;
33 private Visual.AlignType? _visualAnchorPoint = null;
35 private PropertyMap _visualTransformMap = null;
37 private float? _depthIndex = null;
38 protected PropertyMap _outputVisualMap = null;
46 internal int VisualIndex
52 internal VisualView Parent
63 /// Get or set size of the visual.<br>
64 /// It can be either relative (percentage of the parent)
65 /// or absolute (in world units).<br>
72 return _visualSize ?? (new Vector2(1.0f, 1.0f));
77 if (_visualSizePolicy == null)
79 _visualSizePolicy = new Vector2(0.0f, 0.0f);
86 /// Get or set offset of the visual.<br>
87 /// It can be either relative (percentage of the parent)
88 /// or absolute (in world units).<br>
91 public Vector2 Position
95 return _visualOffset ?? (new Vector2(0.0f, 0.0f));
99 _visualOffset = value;
100 if (_visualOffsetPolicy == null)
102 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
109 /// Get or set relative size of the visual<br>
110 /// (percentage [0.0f to 1.0f] of the control).<br>
113 public RelativeVector2 RelativeSize
117 return _visualSize ?? (new RelativeVector2(1.0f, 1.0f));
122 _visualSizePolicy = new Vector2(0.0f, 0.0f);
128 /// Get or set relative offset of the visual<br>
129 /// (percentage [0.0f to 1.0f] of the control).<br>
132 public RelativeVector2 RelativePosition
136 return _visualOffset ?? (new RelativeVector2(0.0f, 0.0f));
140 _visualOffset = value;
141 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
147 /// Get or set whether the x and y offset values are relative<br>
148 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
149 /// Be default, both the x and the y offset is relative.<br>
152 public VisualTransformPolicyType PositionPolicy
156 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f
157 && _visualOffsetPolicy.Y == 1.0f)
159 return VisualTransformPolicyType.Absolute;
161 return VisualTransformPolicyType.Relative;
167 case VisualTransformPolicyType.Relative:
168 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
170 case VisualTransformPolicyType.Absolute:
171 _visualOffsetPolicy = new Vector2(1.0f, 1.0f);
174 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
182 /// Get or set whether the x offset values are relative<br>
183 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
184 /// Be default, the x offset is relative.<br>
187 public VisualTransformPolicyType PositionPolicyX
191 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f)
193 return VisualTransformPolicyType.Absolute;
195 return VisualTransformPolicyType.Relative;
199 if (_visualOffsetPolicy == null)
201 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
206 case VisualTransformPolicyType.Relative:
207 _visualOffsetPolicy.X = 0.0f;
209 case VisualTransformPolicyType.Absolute:
210 _visualOffsetPolicy.X = 1.0f;
213 _visualOffsetPolicy.X = 0.0f;
222 /// Get or set whether the y offset values are relative<br>
223 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
224 /// Be default, the y offset is relative.<br>
227 public VisualTransformPolicyType PositionPolicyY
231 if (_visualOffsetPolicy != null && _visualOffsetPolicy.Y == 1.0f)
233 return VisualTransformPolicyType.Absolute;
235 return VisualTransformPolicyType.Relative;
239 if (_visualOffsetPolicy == null)
241 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
246 case VisualTransformPolicyType.Relative:
247 _visualOffsetPolicy.Y = 0.0f;
249 case VisualTransformPolicyType.Absolute:
250 _visualOffsetPolicy.Y = 1.0f;
253 _visualOffsetPolicy.Y = 0.0f;
261 /// Get or set whether the width or height size values are relative<br>
262 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
263 /// Be default, both the width and the height offset is relative to the control's size.<br>
266 public VisualTransformPolicyType SizePolicy
270 if (_visualSizePolicy != null && _visualSizePolicy.X == 1.0f
271 && _visualSizePolicy.Y == 1.0f)
273 return VisualTransformPolicyType.Absolute;
275 return VisualTransformPolicyType.Relative;
281 case VisualTransformPolicyType.Relative:
282 _visualSizePolicy = new Vector2(0.0f, 0.0f);
284 case VisualTransformPolicyType.Absolute:
285 _visualSizePolicy = new Vector2(1.0f, 1.0f);
288 _visualSizePolicy = new Vector2(0.0f, 0.0f);
296 /// Get or set whether the width size values are relative<br>
297 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
298 /// Be default, the width value is relative to the control's width.<br>
301 public VisualTransformPolicyType SizePolicyWidth
305 if (_visualSizePolicy != null && _visualSizePolicy.Width == 1.0f)
307 return VisualTransformPolicyType.Absolute;
309 return VisualTransformPolicyType.Relative;
313 if (_visualSizePolicy == null)
315 _visualSizePolicy = new Vector2(0.0f, 0.0f);
320 case VisualTransformPolicyType.Relative:
321 _visualSizePolicy.Width = 0.0f;
323 case VisualTransformPolicyType.Absolute:
324 _visualSizePolicy.Width = 1.0f;
327 _visualSizePolicy.Width = 0.0f;
335 /// Get or set whether the height size values are relative<br>
336 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
337 /// Be default, both the height value is relative to the control's height.<br>
340 public VisualTransformPolicyType SizePolicyHeight
344 if (_visualSizePolicy != null && _visualSizePolicy.Height == 1.0f)
346 return VisualTransformPolicyType.Absolute;
348 return VisualTransformPolicyType.Relative;
352 if (_visualSizePolicy == null)
354 _visualSizePolicy = new Vector2(0.0f, 0.0f);
359 case VisualTransformPolicyType.Relative:
360 _visualSizePolicy.Height = 0.0f;
362 case VisualTransformPolicyType.Absolute:
363 _visualSizePolicy.Height = 1.0f;
366 _visualSizePolicy.Height = 0.0f;
374 /// Get or set the origin of the visual within its control area.<br>
375 /// By default, the origin is Center.<br>
378 public Visual.AlignType Origin
382 return _visualOrigin ?? (Visual.AlignType.Center);
386 _visualOrigin = value;
392 /// Get or set the anchor-point of the visual.<br>
393 /// By default, the anchor point is Center.<br>
396 public Visual.AlignType AnchorPoint
400 return _visualAnchorPoint ?? (Visual.AlignType.Center);
404 _visualAnchorPoint = value;
410 /// Get or set the depth index of the visual.<br>
411 /// By default, the depth index is 0.<br>
414 public float DepthIndex
418 return _depthIndex ?? (0.0f);
426 private void ComposingTransformMap()
428 _visualTransformMap = new PropertyMap();
429 if (_visualSize != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Size, new PropertyValue(_visualSize)); }
430 if (_visualOffset != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(_visualOffset)); }
431 if (_visualOffsetPolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(_visualOffsetPolicy)); }
432 if (_visualSizePolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(_visualSizePolicy)); }
433 if (_visualOrigin != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin)); }
434 if (_visualAnchorPoint != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint)); }
438 /// Get the transform map used by the visual.
440 public PropertyMap OutputTransformMap
444 ComposingTransformMap();
445 return _visualTransformMap;
449 protected virtual void ComposingPropertyMap()
451 _outputVisualMap = new PropertyMap();
455 /// Get the property map to create the visual.
457 public PropertyMap OutputVisualMap
461 ComposingPropertyMap();
462 return _outputVisualMap;
466 internal void UpdateVisual()
471 Tizen.Log.Debug("NUI", "UpdateVisual()! VisualIndex=" + VisualIndex);
473 Parent.UpdateVisual(VisualIndex, Name, this);
478 Tizen.Log.Debug("NUI", "VisualIndex was not set");
483 protected PropertyMap _shader = null;
484 //private PropertyMap _transform = null;
485 protected bool? _premultipliedAlpha = null;
486 protected Color _mixColor = null;
487 protected float? _opacity = null;
488 protected PropertyMap _commonlyUsedMap = null;
491 /// The shader to use in the visual.
493 public PropertyMap Shader
507 /// Enables/disables premultiplied alpha. <br>
508 /// The premultiplied alpha is false by default unless this behaviour is modified by the derived Visual type.
510 public bool PremultipliedAlpha
514 return _premultipliedAlpha ?? (false);
518 _premultipliedAlpha = value;
524 /// Mix color is a blend color for any visual.
526 public Color MixColor
540 /// Opacity is the alpha component of the mixColor, above.
546 return _opacity ?? (1.0f);
558 /// A class encapsulating the property map of a image visual.
560 public class ImageVisual : VisualMap
562 public ImageVisual() : base()
566 private string _url = null;
567 private FittingModeType? _fittingMode = null;
568 private SamplingModeType? _samplingMode = null;
569 private int? _desiredWidth = null;
570 private int? _desiredHeight = null;
571 private bool? _synchronousLoading = false;
572 private bool? _borderOnly = null;
573 private Vector4 _pixelArea = null;
574 private WrapModeType? _wrapModeU = null;
575 private WrapModeType? _wrapModeV = null;
578 /// Get or set the URL of the image.<br>
595 /// Get or set fitting options, used when resizing images to fit desired dimensions.<br>
596 /// If not supplied, default is FittingModeType.ShrinkToFit.<br>
597 /// For Normal Quad images only.<br>
600 public FittingModeType FittingMode
604 return _fittingMode ?? (FittingModeType.ShrinkToFit);
608 _fittingMode = value;
614 /// Get or set filtering options, used when resizing images to sample original pixels.<br>
615 /// If not supplied, default is SamplingModeType.Box.<br>
616 /// For Normal Quad images only.<br>
619 public SamplingModeType SamplingMode
623 return _samplingMode ?? (SamplingModeType.Box);
627 _samplingMode = value;
633 /// Get or set the desired image width.<br>
634 /// If not specified, the actual image width is used.<br>
635 /// For Normal Quad images only.<br>
638 public int DesiredWidth
642 return _desiredWidth ?? (-1);
646 _desiredWidth = value;
652 /// Get or set the desired image height.<br>
653 /// If not specified, the actual image height is used.<br>
654 /// For Normal Quad images only.<br>
657 public int DesiredHeight
661 return _desiredHeight ?? (-1);
665 _desiredHeight = value;
671 /// Get or set whether to load the image synchronously.<br>
672 /// If not specified, the default is false, i.e. the image is loaded asynchronously.<br>
673 /// For Normal Quad images only.<br>
676 public bool SynchronousLoading
680 return _synchronousLoading ?? (false);
684 _synchronousLoading = value;
690 /// Get or set whether to draws the borders only(If true).<br>
691 /// If not specified, the default is false.<br>
692 /// For N-Patch images only.<br>
695 public bool BorderOnly
699 return _borderOnly ?? (false);
709 /// Get or set the image area to be displayed.<br>
710 /// It is a rectangular area.<br>
711 /// 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>
712 /// If not specified, the default value is Vector4(0.0, 0.0, 1.0, 1.0), i.e. the entire area of the image.<br>
713 /// For For Normal QUAD image only.<br>
716 public Vector4 PixelArea
720 return _pixelArea ?? (new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
730 /// Get or set the wrap mode for u coordinate.<br>
731 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br>
732 /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
733 /// For Normal QUAD image only.<br>
736 public WrapModeType WrapModeU
740 return _wrapModeU ?? (WrapModeType.Default);
750 /// Get or set the wrap mode for v coordinate.<br>
751 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br>
752 /// 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>
753 /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
754 /// For Normal QUAD image only.
757 public WrapModeType WrapModeV
761 return _wrapModeV ?? (WrapModeType.Default);
770 protected override void ComposingPropertyMap()
774 _outputVisualMap = new PropertyMap();
775 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
776 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
777 if (_fittingMode != null) { _outputVisualMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode)); }
778 if (_samplingMode != null) { _outputVisualMap.Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode)); }
779 if (_desiredWidth != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredWidth, new PropertyValue((int)_desiredWidth)); }
780 if (_desiredHeight != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredHeight, new PropertyValue((int)_desiredHeight)); }
781 if (_synchronousLoading != null) { _outputVisualMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
782 if (_borderOnly != null) { _outputVisualMap.Add(ImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
783 if (_pixelArea != null) { _outputVisualMap.Add(ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea)); }
784 if (_wrapModeU != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU)); }
785 if (_wrapModeV != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV)); }
786 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
787 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
788 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
789 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
795 /// A class encapsulating the property map of a text visual.
797 public class TextVisual : VisualMap
799 public TextVisual() : base()
803 private string _text = null;
804 private string _fontFamily = null;
805 private PropertyMap _fontStyle = null;
806 private float? _pointSize = null;
807 private bool? _multiLine = null;
808 private string _horizontalAlignment = null;
809 private string _verticalAlignment = null;
810 private Color _textColor = null;
811 private bool? _enableMarkup = null;
814 /// Get or set the text to display in UTF-8 format.<br>
831 /// Get or set the requested font family to use.<br>
834 public string FontFamily
848 /// Get or set the requested font style to use.<br>
851 public PropertyMap FontStyle
865 /// Get or set the size of font in points.<br>
868 public float PointSize
872 return _pointSize ?? (0.0f);
882 /// Get or set the single-line or multi-line layout option.<br>
883 /// If not specified, the default is false.<br>
886 public bool MultiLine
890 return _multiLine ?? (false);
900 /// Get or set the line horizontal alignment.<br>
901 /// If not specified, the default is Begin.<br>
904 public HorizontalAlignment HorizontalAlignment
908 switch (_horizontalAlignment)
911 return HorizontalAlignment.Begin;
913 return HorizontalAlignment.Center;
915 return HorizontalAlignment.End;
917 return HorizontalAlignment.Begin;
924 case HorizontalAlignment.Begin:
926 _horizontalAlignment = "BEGIN";
929 case HorizontalAlignment.Center:
931 _horizontalAlignment = "CENTER";
934 case HorizontalAlignment.End:
936 _horizontalAlignment = "END";
941 _horizontalAlignment = "BEGIN";
950 /// Get or set the line vertical alignment.<br>
951 /// If not specified, the default is Top.<br>
954 public VerticalAlignment VerticalAlignment
958 switch (_verticalAlignment)
961 return VerticalAlignment.Top;
963 return VerticalAlignment.Center;
965 return VerticalAlignment.Bottom;
967 return VerticalAlignment.Top;
974 case VerticalAlignment.Top:
976 _verticalAlignment = "TOP";
979 case VerticalAlignment.Center:
981 _verticalAlignment = "CENTER";
984 case VerticalAlignment.Bottom:
986 _verticalAlignment = "BOTTOM";
991 _verticalAlignment = "TOP";
1000 /// Get or set the color of the text.<br>
1003 public Color TextColor
1017 /// Get or set whether the mark-up processing is enabled.<br>
1020 public bool EnableMarkup
1024 return _enableMarkup ?? (false);
1028 _enableMarkup = value;
1033 protected override void ComposingPropertyMap()
1035 if (_text != null && _pointSize != null)
1037 _outputVisualMap = new PropertyMap();
1038 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
1039 _outputVisualMap.Add(TextVisualProperty.Text, new PropertyValue(_text));
1040 _outputVisualMap.Add(TextVisualProperty.PointSize, new PropertyValue((float)_pointSize));
1041 if (_fontFamily != null) { _outputVisualMap.Add(TextVisualProperty.FontFamily, new PropertyValue(_fontFamily)); }
1042 if (_fontStyle != null) { _outputVisualMap.Add(TextVisualProperty.FontStyle, new PropertyValue(_fontStyle)); }
1043 if (_multiLine != null) { _outputVisualMap.Add(TextVisualProperty.MultiLine, new PropertyValue((bool)_multiLine)); }
1044 if (_horizontalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment)); }
1045 if (_verticalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment)); }
1046 if (_textColor != null) { _outputVisualMap.Add(TextVisualProperty.TextColor, new PropertyValue(_textColor)); }
1047 if (_enableMarkup != null) { _outputVisualMap.Add(TextVisualProperty.EnableMarkup, new PropertyValue((bool)_enableMarkup)); }
1048 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1049 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1050 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1051 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1057 /// A class encapsulating the property map of a border visual.
1059 public class BorderVisual : VisualMap
1061 public BorderVisual() : base()
1065 private Color _color = null;
1066 private float? _size = null;
1067 private bool? _antiAliasing = null;
1070 /// Get or set the color of the border.<br>
1087 /// Get or set the width of the border (in pixels).<br>
1090 public float BorderSize
1094 return _size ?? (-1.0f);
1104 /// Get or set whether anti-aliasing of the border is required.<br>
1105 /// If not supplied, default is false.<br>
1108 public bool AntiAliasing
1112 return _antiAliasing ?? (false);
1116 _antiAliasing = value;
1121 protected override void ComposingPropertyMap()
1123 if (_color != null && _size != null)
1125 _outputVisualMap = new PropertyMap();
1126 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
1127 _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue((float)_size));
1128 _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color));
1129 if (_antiAliasing != null) { _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue((bool)_antiAliasing)); }
1130 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1131 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1132 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1133 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1139 /// A class encapsulating the property map of a color visual.
1141 public class ColorVisual : VisualMap
1143 public ColorVisual() : base()
1147 private Color _mixColorForColorVisual = null;
1150 /// Get or set the solid color required.<br>
1157 return _mixColorForColorVisual;
1161 _mixColorForColorVisual = value;
1166 protected override void ComposingPropertyMap()
1168 if (_mixColorForColorVisual != null)
1170 _outputVisualMap = new PropertyMap();
1171 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
1172 _outputVisualMap.Add(ColorVisualProperty.MixColor, new PropertyValue(_mixColorForColorVisual));
1173 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1174 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1175 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1181 /// A class encapsulating the property map of a gradient visual.
1183 public class GradientVisual : VisualMap
1185 public GradientVisual() : base()
1189 private Vector2 _startPosition = null;
1190 private Vector2 _endPosition = null;
1191 private Vector2 _center = null;
1192 private float? _radius = null;
1193 private PropertyArray _stopOffset = null;
1194 private PropertyArray _stopColor = null;
1195 private GradientVisualUnitsType? _units = null;
1196 private GradientVisualSpreadMethodType? _spreadMethod = null;
1199 /// Get or set the start position of a linear gradient.<br>
1200 /// Mandatory for Linear.<br>
1202 public Vector2 StartPosition
1206 return _startPosition;
1210 _startPosition = value;
1216 /// Get or set the end position of a linear gradient.<br>
1217 /// Mandatory for Linear.<br>
1219 public Vector2 EndPosition
1223 return _endPosition;
1227 _endPosition = value;
1233 /// Get or set the center point of a radial gradient.<br>
1234 /// Mandatory for Radial.<br>
1236 public Vector2 Center
1250 /// Get or set the size of the radius of a radial gradient.<br>
1251 /// Mandatory for Radial.<br>
1257 return _radius ?? (-1.0f);
1267 /// Get or set all the stop offsets.<br>
1268 /// A PropertyArray of float.<br>
1269 /// If not supplied, default is 0.0f and 1.0f.<br>
1272 public PropertyArray StopOffset
1280 _stopOffset = value;
1286 /// Get or set the color at the stop offsets.<br>
1287 /// A PropertyArray of Color.<br>
1288 /// At least 2 values required to show a gradient.<br>
1291 public PropertyArray StopColor
1305 /// Get or set defines the coordinate system for certain attributes of the points in a gradient.<br>
1306 /// If not supplied, default is GradientVisualUnitsType.ObjectBoundingBox.<br>
1309 public GradientVisualUnitsType Units
1313 return _units ?? (GradientVisualUnitsType.ObjectBoundingBox);
1323 /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.<br>
1324 /// If not supplied, default is GradientVisualSpreadMethodType.Pad.<br>
1327 public GradientVisualSpreadMethodType SpreadMethod
1331 return _spreadMethod ?? (GradientVisualSpreadMethodType.Pad);
1335 _spreadMethod = value;
1340 protected override void ComposingPropertyMap()
1342 if (((_startPosition != null && _endPosition != null) || (_center != null && _radius != null)) && _stopColor != null)
1344 _outputVisualMap = new PropertyMap();
1345 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
1346 _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
1347 if (_startPosition != null) { _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition)); }
1348 if (_endPosition != null) { _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition)); }
1349 if (_center != null) { _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center)); }
1350 if (_radius != null) { _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue((float)_radius)); }
1351 if (_stopOffset != null) { _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset)); }
1352 if (_units != null) { _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units)); }
1353 if (_spreadMethod != null) { _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod)); }
1354 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1355 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1356 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1357 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1363 /// A class encapsulating the property map of a mesh visual.
1365 public class MeshVisual : VisualMap
1367 public MeshVisual() : base()
1371 private string _objectURL = null;
1372 private string _materialtURL = null;
1373 private string _texturesPath = null;
1374 private MeshVisualShadingModeValue? _shadingMode = null;
1375 private bool? _useMipmapping = null;
1376 private bool? _useSoftNormals = null;
1377 private Vector3 _lightPosition = null;
1380 /// Get or set the location of the ".obj" file.<br>
1383 public string ObjectURL
1397 /// Get or set the location of the ".mtl" file.<br>
1398 /// If not specified, then a textureless object is assumed.<br>
1401 public string MaterialtURL
1405 return _materialtURL;
1409 _materialtURL = value;
1415 /// Get or set path to the directory the textures (including gloss and normal) are stored in.<br>
1416 /// Mandatory if using material.<br>
1418 public string TexturesPath
1422 return _texturesPath;
1426 _texturesPath = value;
1432 /// Get or set the type of shading mode that the mesh will use.<br>
1433 /// 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>
1434 /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting first).<br>
1437 public MeshVisualShadingModeValue ShadingMode
1441 return _shadingMode ?? (MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting);
1445 _shadingMode = value;
1451 /// Get or set whether to use mipmaps for textures or not.<br>
1452 /// If not specified, the default is true.<br>
1455 public bool UseMipmapping
1459 return _useMipmapping ?? (true);
1463 _useMipmapping = value;
1469 /// Get or set whether to average normals at each point to smooth textures or not.<br>
1470 /// If not specified, the default is true.<br>
1473 public bool UseSoftNormals
1477 return _useSoftNormals ?? (true);
1481 _useSoftNormals = value;
1487 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1488 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1489 /// and using all zeroes will place the light at the top left corner.<br>
1490 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1493 public Vector3 LightPosition
1497 return _lightPosition;
1501 _lightPosition = value;
1506 protected override void ComposingPropertyMap()
1508 if (_objectURL != null)
1510 _outputVisualMap = new PropertyMap();
1511 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
1512 _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
1513 if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
1514 if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
1515 if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
1516 if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
1517 if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
1518 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1519 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1520 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1521 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1527 /// A class encapsulating the property map of a primetive visual.
1529 public class PrimitiveVisual : VisualMap
1531 public PrimitiveVisual() : base()
1535 private PrimitiveVisualShapeType? _shape = null;
1536 private Color _mixColorForPrimitiveVisual = null;
1537 private int? _slices = null;
1538 private int? _stacks = null;
1539 private float? _scaleTopRadius = null;
1540 private float? _scaleBottomRadius = null;
1541 private float? _scaleHeight = null;
1542 private float? _scaleRadius = null;
1543 private Vector3 _scaleDimensions = null;
1544 private float? _bevelPercentage = null;
1545 private float? _bevelSmoothness = null;
1546 private Vector3 _lightPosition = null;
1549 /// Get or set the specific shape to render.<br>
1550 /// If not specified, the default is PrimitiveVisualShapeType.Sphere.<br>
1553 public PrimitiveVisualShapeType Shape
1557 return _shape ?? (PrimitiveVisualShapeType.Sphere);
1567 /// Get or set the color of the shape.<br>
1568 /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).<br>
1569 /// Applies to ALL shapes.<br>
1572 public Color MixColor
1576 return _mixColorForPrimitiveVisual ?? (new Color(0.5f, 0.5f, 0.5f, 1.0f));
1580 _mixColorForPrimitiveVisual = value;
1586 /// Get or set the number of slices as you go around the shape.<br>
1587 /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.<br>
1588 /// If not specified, the default is 128.<br>
1589 /// The range is from 1 to 255.<br>
1596 return _slices ?? (128);
1606 /// Get or set the number of stacks as you go down the shape.<br>
1607 /// For spheres, 'stacks' determines how many layers there are as you go down the object.<br>
1608 /// If not specified, the default is 128.<br>
1609 /// The range is from 1 to 255.<br>
1616 return _stacks ?? (128);
1626 /// Get or set the scale of the radius of the top circle of a conical frustrum.<br>
1627 /// If not specified, the default is 1.0f.<br>
1628 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br>
1629 /// Only values greater than or equal to 0.0f are accepted.<br>
1632 public float ScaleTopRadius
1636 return _scaleTopRadius ?? (1.0f);
1640 _scaleTopRadius = value;
1646 /// Get or set the scale of the radius of the bottom circle of a conical frustrum.<br>
1647 /// If not specified, the default is 1.5f.<br>
1648 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br>
1649 /// - PrimitiveVisualShapeType.Cone<br>
1650 /// Only values greater than or equal to 0.0f are accepted.<br>
1653 public float ScaleBottomRadius
1657 return _scaleBottomRadius ?? (1.5f);
1661 _scaleBottomRadius = value;
1667 /// Get or set the scale of the height of a conic.<br>
1668 /// If not specified, the default is 3.0f.<br>
1670 /// - PrimitiveVisualShapeType.ConicalFrustrum<br>
1671 /// - PrimitiveVisualShapeType.Cone<br>
1672 /// - PrimitiveVisualShapeType.Cylinder<br>
1673 /// Only values greater than or equal to 0.0f are accepted.<br>
1676 public float ScaleHeight
1680 return _scaleHeight ?? (3.0f);
1684 _scaleHeight = value;
1690 /// Get or set the scale of the radius of a cylinder.<br>
1691 /// If not specified, the default is 1.0f.<br>
1693 /// - PrimitiveVisualShapeType.Cylinder<br>
1694 /// Only values greater than or equal to 0.0f are accepted.<br>
1697 public float ScaleRadius
1701 return _scaleRadius ?? (1.0f);
1705 _scaleRadius = value;
1711 /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.<br>
1712 /// If not specified, the default is Vector3.One.<br>
1714 /// - PrimitiveVisualShapeType.Cube<br>
1715 /// - PrimitiveVisualShapeType.Octahedron<br>
1716 /// - PrimitiveVisualShapeType.BevelledCube<br>
1717 /// Each vector3 parameter should be greater than or equal to 0.0f.<br>
1720 public Vector3 ScaleDimensions
1724 return _scaleDimensions ?? (Vector3.One);
1728 _scaleDimensions = value;
1734 /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.<br>
1735 /// 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>
1736 /// If not specified, the default is 0.0f (no bevel).<br>
1738 /// - PrimitiveVisualShapeType.BevelledCube<br>
1739 /// The range is from 0.0f to 1.0f.<br>
1742 public float BevelPercentage
1746 return _bevelPercentage ?? (0.0f);
1750 _bevelPercentage = value;
1756 /// Get or set defines how smooth the bevelled edges should be.<br>
1757 /// If not specified, the default is 0.0f (sharp edges).<br>
1759 /// - PrimitiveVisualShapeType.BevelledCube<br>
1760 /// The range is from 0.0f to 1.0f.<br>
1763 public float BevelSmoothness
1767 return _bevelSmoothness ?? (0.0f);
1771 _bevelSmoothness = value;
1777 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1778 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1779 /// and using all zeroes will place the light at the top left corner.<br>
1780 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1781 /// Applies to ALL shapes.<br>
1784 public Vector3 LightPosition
1788 return _lightPosition;
1792 _lightPosition = value;
1797 protected override void ComposingPropertyMap()
1799 _outputVisualMap = new PropertyMap(); ;
1800 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
1801 if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
1802 if (_mixColorForPrimitiveVisual != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColorForPrimitiveVisual)); }
1803 if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
1804 if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
1805 if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
1806 if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
1807 if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
1808 if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
1809 if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
1810 if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
1811 if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
1812 if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
1813 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1814 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1815 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1820 /// A class encapsulating the property map of a n-patch image visual.
1822 public class NPatchVisual : VisualMap
1824 public NPatchVisual() : base()
1828 private string _url = null;
1829 private bool? _borderOnly = null;
1830 private Rectangle _border = null;
1833 /// Get or set the URL of the image.<br>
1850 /// Get or set whether to draws the borders only(If true).<br>
1851 /// If not specified, the default is false.<br>
1852 /// For N-Patch images only.<br>
1855 public bool BorderOnly
1859 return _borderOnly ?? false;
1863 _borderOnly = value;
1869 /// The border of the image in the order: left, right, bottom, top.<br>
1870 /// For N-Patch images only.<br>
1873 public Rectangle Border
1886 protected override void ComposingPropertyMap()
1890 _outputVisualMap = new PropertyMap();
1891 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1892 _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
1893 if (_borderOnly != null) { _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
1894 if (_border != null) { _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); }
1895 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1896 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1897 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1898 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1904 /// A class encapsulating the property map of a SVG visual.
1906 public class SVGVisual : VisualMap
1908 public SVGVisual() : base()
1912 private string _url = null;
1927 protected override void ComposingPropertyMap()
1931 _outputVisualMap = new PropertyMap();
1932 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
1933 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1934 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1935 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1936 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1937 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1943 /// A class encapsulating the property map of a Animated Image(AGIF) visual.
1945 public class AnimatedImageVisual : VisualMap
1947 public AnimatedImageVisual() : base()
1951 private string _url = null;
1966 protected override void ComposingPropertyMap()
1970 _outputVisualMap = new PropertyMap();
1971 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage));
1972 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1973 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1974 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1975 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1976 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }