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;
23 /// A class encapsulating the transform map of visual.
25 public class VisualMap
27 private Vector2 _visualSize = null;
28 private Vector2 _visualOffset = null;
29 private Vector2 _visualOffsetPolicy = null;
30 private Vector2 _visualSizePolicy = null;
31 private Visual.AlignType? _visualOrigin = null;
32 private Visual.AlignType? _visualAnchorPoint = null;
34 private PropertyMap _visualTransformMap = null;
36 private float? _depthIndex = null;
37 protected PropertyMap _outputVisualMap = null;
45 internal int VisualIndex
51 internal VisualView Parent
62 /// Get or set size of the visual.<br>
63 /// It can be either relative (percentage of the parent)
64 /// or absolute (in world units).<br>
71 return _visualSize ?? (new Vector2(1.0f, 1.0f));
76 if (_visualSizePolicy == null)
78 _visualSizePolicy = new Vector2(0.0f, 0.0f);
85 /// Get or set offset of the visual.<br>
86 /// It can be either relative (percentage of the parent)
87 /// or absolute (in world units).<br>
90 public Vector2 Position
94 return _visualOffset ?? (new Vector2(0.0f, 0.0f));
98 _visualOffset = value;
99 if (_visualOffsetPolicy == null)
101 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
108 /// Get or set relative size of the visual<br>
109 /// (percentage [0.0f to 1.0f] of the control).<br>
112 public RelativeVector2 RelativeSize
116 return _visualSize ?? (new RelativeVector2(1.0f, 1.0f));
121 _visualSizePolicy = new Vector2(0.0f, 0.0f);
127 /// Get or set relative offset of the visual<br>
128 /// (percentage [0.0f to 1.0f] of the control).<br>
131 public RelativeVector2 RelativePosition
135 return _visualOffset ?? (new RelativeVector2(0.0f, 0.0f));
139 _visualOffset = value;
140 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
146 /// Get or set whether the x and y offset values are relative<br>
147 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
148 /// Be default, both the x and the y offset is relative.<br>
151 public VisualTransformPolicyType PositionPolicy
155 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f
156 && _visualOffsetPolicy.Y == 1.0f)
158 return VisualTransformPolicyType.Absolute;
160 return VisualTransformPolicyType.Relative;
166 case VisualTransformPolicyType.Relative:
167 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
169 case VisualTransformPolicyType.Absolute:
170 _visualOffsetPolicy = new Vector2(1.0f, 1.0f);
173 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
181 /// Get or set whether the x offset values are relative<br>
182 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
183 /// Be default, the x offset is relative.<br>
186 public VisualTransformPolicyType PositionPolicyX
190 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f)
192 return VisualTransformPolicyType.Absolute;
194 return VisualTransformPolicyType.Relative;
198 if (_visualOffsetPolicy == null)
200 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
205 case VisualTransformPolicyType.Relative:
206 _visualOffsetPolicy.X = 0.0f;
208 case VisualTransformPolicyType.Absolute:
209 _visualOffsetPolicy.X = 1.0f;
212 _visualOffsetPolicy.X = 0.0f;
221 /// Get or set whether the y offset values are relative<br>
222 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
223 /// Be default, the y offset is relative.<br>
226 public VisualTransformPolicyType PositionPolicyY
230 if (_visualOffsetPolicy != null && _visualOffsetPolicy.Y == 1.0f)
232 return VisualTransformPolicyType.Absolute;
234 return VisualTransformPolicyType.Relative;
238 if (_visualOffsetPolicy == null)
240 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
245 case VisualTransformPolicyType.Relative:
246 _visualOffsetPolicy.Y = 0.0f;
248 case VisualTransformPolicyType.Absolute:
249 _visualOffsetPolicy.Y = 1.0f;
252 _visualOffsetPolicy.Y = 0.0f;
260 /// Get or set whether the width or height size values are relative<br>
261 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
262 /// Be default, both the width and the height offset is relative to the control's size.<br>
265 public VisualTransformPolicyType SizePolicy
269 if (_visualSizePolicy != null && _visualSizePolicy.X == 1.0f
270 && _visualSizePolicy.Y == 1.0f)
272 return VisualTransformPolicyType.Absolute;
274 return VisualTransformPolicyType.Relative;
280 case VisualTransformPolicyType.Relative:
281 _visualSizePolicy = new Vector2(0.0f, 0.0f);
283 case VisualTransformPolicyType.Absolute:
284 _visualSizePolicy = new Vector2(1.0f, 1.0f);
287 _visualSizePolicy = new Vector2(0.0f, 0.0f);
295 /// Get or set whether the width size values are relative<br>
296 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
297 /// Be default, the width value is relative to the control's width.<br>
300 public VisualTransformPolicyType SizePolicyWidth
304 if (_visualSizePolicy != null && _visualSizePolicy.Width == 1.0f)
306 return VisualTransformPolicyType.Absolute;
308 return VisualTransformPolicyType.Relative;
312 if (_visualSizePolicy == null)
314 _visualSizePolicy = new Vector2(0.0f, 0.0f);
319 case VisualTransformPolicyType.Relative:
320 _visualSizePolicy.Width = 0.0f;
322 case VisualTransformPolicyType.Absolute:
323 _visualSizePolicy.Width = 1.0f;
326 _visualSizePolicy.Width = 0.0f;
334 /// Get or set whether the height size values are relative<br>
335 /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
336 /// Be default, both the height value is relative to the control's height.<br>
339 public VisualTransformPolicyType SizePolicyHeight
343 if (_visualSizePolicy != null && _visualSizePolicy.Height == 1.0f)
345 return VisualTransformPolicyType.Absolute;
347 return VisualTransformPolicyType.Relative;
351 if (_visualSizePolicy == null)
353 _visualSizePolicy = new Vector2(0.0f, 0.0f);
358 case VisualTransformPolicyType.Relative:
359 _visualSizePolicy.Height = 0.0f;
361 case VisualTransformPolicyType.Absolute:
362 _visualSizePolicy.Height = 1.0f;
365 _visualSizePolicy.Height = 0.0f;
373 /// Get or set the origin of the visual within its control area.<br>
374 /// By default, the origin is Center.<br>
377 public Visual.AlignType Origin
381 return _visualOrigin ?? (Visual.AlignType.Center);
385 _visualOrigin = value;
391 /// Get or set the anchor-point of the visual.<br>
392 /// By default, the anchor point is Center.<br>
395 public Visual.AlignType AnchorPoint
399 return _visualAnchorPoint ?? (Visual.AlignType.Center);
403 _visualAnchorPoint = value;
409 /// Get or set the depth index of the visual.<br>
410 /// By default, the depth index is 0.<br>
413 public float DepthIndex
417 return _depthIndex ?? (0.0f);
425 private void ComposingTransformMap()
427 _visualTransformMap = new PropertyMap();
428 if (_visualSize != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Size, new PropertyValue(_visualSize)); }
429 if (_visualOffset != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(_visualOffset)); }
430 if (_visualOffsetPolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(_visualOffsetPolicy)); }
431 if (_visualSizePolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(_visualSizePolicy)); }
432 if (_visualOrigin != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin)); }
433 if (_visualAnchorPoint != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint)); }
437 /// Get the transform map used by the visual.
439 public PropertyMap OutputTransformMap
443 ComposingTransformMap();
444 return _visualTransformMap;
448 protected virtual void ComposingPropertyMap()
450 _outputVisualMap = new PropertyMap();
454 /// Get the property map to create the visual.
456 public PropertyMap OutputVisualMap
460 ComposingPropertyMap();
461 return _outputVisualMap;
465 internal void UpdateVisual()
470 Tizen.Log.Debug("NUI", "UpdateVisual()! VisualIndex=" + VisualIndex);
472 Parent.UpdateVisual(VisualIndex, Name, this);
477 Tizen.Log.Debug("NUI", "VisualIndex was not set");
482 protected PropertyMap _shader = null;
483 //private PropertyMap _transform = null;
484 protected bool? _premultipliedAlpha = null;
485 protected Color _mixColor = null;
486 protected float? _opacity = null;
487 protected PropertyMap _commonlyUsedMap = null;
490 /// The shader to use in the visual.
492 public PropertyMap Shader
506 /// Enables/disables premultiplied alpha. <br>
507 /// The premultiplied alpha is false by default unless this behaviour is modified by the derived Visual type.
509 public bool PremultipliedAlpha
513 return _premultipliedAlpha ?? (false);
517 _premultipliedAlpha = value;
523 /// Mix color is a blend color for any visual.
525 public Color MixColor
539 /// Opacity is the alpha component of the mixColor, above.
545 return _opacity ?? (1.0f);
557 /// A class encapsulating the property map of a image visual.
559 public class ImageVisual : VisualMap
561 public ImageVisual() : base()
565 private string _url = null;
566 private FittingModeType? _fittingMode = null;
567 private SamplingModeType? _samplingMode = null;
568 private int? _desiredWidth = null;
569 private int? _desiredHeight = null;
570 private bool? _synchronousLoading = false;
571 private bool? _borderOnly = null;
572 private Vector4 _pixelArea = null;
573 private WrapModeType? _wrapModeU = null;
574 private WrapModeType? _wrapModeV = null;
577 /// Get or set the URL of the image.<br>
594 /// Get or set fitting options, used when resizing images to fit desired dimensions.<br>
595 /// If not supplied, default is FittingModeType.ShrinkToFit.<br>
596 /// For Normal Quad images only.<br>
599 public FittingModeType FittingMode
603 return _fittingMode ?? (FittingModeType.ShrinkToFit);
607 _fittingMode = value;
613 /// Get or set filtering options, used when resizing images to sample original pixels.<br>
614 /// If not supplied, default is SamplingModeType.Box.<br>
615 /// For Normal Quad images only.<br>
618 public SamplingModeType SamplingMode
622 return _samplingMode ?? (SamplingModeType.Box);
626 _samplingMode = value;
632 /// Get or set the desired image width.<br>
633 /// If not specified, the actual image width is used.<br>
634 /// For Normal Quad images only.<br>
637 public int DesiredWidth
641 return _desiredWidth ?? (-1);
645 _desiredWidth = value;
651 /// Get or set the desired image height.<br>
652 /// If not specified, the actual image height is used.<br>
653 /// For Normal Quad images only.<br>
656 public int DesiredHeight
660 return _desiredHeight ?? (-1);
664 _desiredHeight = value;
670 /// Get or set whether to load the image synchronously.<br>
671 /// If not specified, the default is false, i.e. the image is loaded asynchronously.<br>
672 /// For Normal Quad images only.<br>
675 public bool SynchronousLoading
679 return _synchronousLoading ?? (false);
683 _synchronousLoading = value;
689 /// Get or set whether to draws the borders only(If true).<br>
690 /// If not specified, the default is false.<br>
691 /// For N-Patch images only.<br>
694 public bool BorderOnly
698 return _borderOnly ?? (false);
708 /// Get or set the image area to be displayed.<br>
709 /// It is a rectangular area.<br>
710 /// 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>
711 /// 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>
712 /// For For Normal QUAD image only.<br>
715 public Vector4 PixelArea
719 return _pixelArea ?? (new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
729 /// Get or set the wrap mode for u coordinate.<br>
730 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br>
731 /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
732 /// For Normal QUAD image only.<br>
735 public WrapModeType WrapModeU
739 return _wrapModeU ?? (WrapModeType.Default);
749 /// Get or set the wrap mode for v coordinate.<br>
750 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br>
751 /// 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>
752 /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
753 /// For Normal QUAD image only.
756 public WrapModeType WrapModeV
760 return _wrapModeV ?? (WrapModeType.Default);
769 protected override void ComposingPropertyMap()
773 _outputVisualMap = new PropertyMap();
774 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
775 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
776 if (_fittingMode != null) { _outputVisualMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode)); }
777 if (_samplingMode != null) { _outputVisualMap.Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode)); }
778 if (_desiredWidth != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredWidth, new PropertyValue((int)_desiredWidth)); }
779 if (_desiredHeight != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredHeight, new PropertyValue((int)_desiredHeight)); }
780 if (_synchronousLoading != null) { _outputVisualMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
781 if (_borderOnly != null) { _outputVisualMap.Add(ImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
782 if (_pixelArea != null) { _outputVisualMap.Add(ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea)); }
783 if (_wrapModeU != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU)); }
784 if (_wrapModeV != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV)); }
785 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
786 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
787 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
788 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
794 /// A class encapsulating the property map of a text visual.
796 public class TextVisual : VisualMap
798 public TextVisual() : base()
802 private string _text = null;
803 private string _fontFamily = null;
804 private PropertyMap _fontStyle = null;
805 private float? _pointSize = null;
806 private bool? _multiLine = null;
807 private string _horizontalAlignment = null;
808 private string _verticalAlignment = null;
809 private Color _textColor = null;
810 private bool? _enableMarkup = null;
813 /// Get or set the text to display in UTF-8 format.<br>
830 /// Get or set the requested font family to use.<br>
833 public string FontFamily
847 /// Get or set the requested font style to use.<br>
850 public PropertyMap FontStyle
864 /// Get or set the size of font in points.<br>
867 public float PointSize
871 return _pointSize ?? (0.0f);
881 /// Get or set the single-line or multi-line layout option.<br>
882 /// If not specified, the default is false.<br>
885 public bool MultiLine
889 return _multiLine ?? (false);
899 /// Get or set the line horizontal alignment.<br>
900 /// If not specified, the default is Begin.<br>
903 public HorizontalAlignment HorizontalAlignment
907 switch (_horizontalAlignment)
910 return HorizontalAlignment.Begin;
912 return HorizontalAlignment.Center;
914 return HorizontalAlignment.End;
916 return HorizontalAlignment.Begin;
923 case HorizontalAlignment.Begin:
925 _horizontalAlignment = "BEGIN";
928 case HorizontalAlignment.Center:
930 _horizontalAlignment = "CENTER";
933 case HorizontalAlignment.End:
935 _horizontalAlignment = "END";
940 _horizontalAlignment = "BEGIN";
949 /// Get or set the line vertical alignment.<br>
950 /// If not specified, the default is Top.<br>
953 public VerticalAlignment VerticalAlignment
957 switch (_verticalAlignment)
960 return VerticalAlignment.Top;
962 return VerticalAlignment.Center;
964 return VerticalAlignment.Bottom;
966 return VerticalAlignment.Top;
973 case VerticalAlignment.Top:
975 _verticalAlignment = "TOP";
978 case VerticalAlignment.Center:
980 _verticalAlignment = "CENTER";
983 case VerticalAlignment.Bottom:
985 _verticalAlignment = "BOTTOM";
990 _verticalAlignment = "TOP";
999 /// Get or set the color of the text.<br>
1002 public Color TextColor
1016 /// Get or set whether the mark-up processing is enabled.<br>
1019 public bool EnableMarkup
1023 return _enableMarkup ?? (false);
1027 _enableMarkup = value;
1032 protected override void ComposingPropertyMap()
1034 if (_text != null && _pointSize != null)
1036 _outputVisualMap = new PropertyMap();
1037 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
1038 _outputVisualMap.Add(TextVisualProperty.Text, new PropertyValue(_text));
1039 _outputVisualMap.Add(TextVisualProperty.PointSize, new PropertyValue((float)_pointSize));
1040 if (_fontFamily != null) { _outputVisualMap.Add(TextVisualProperty.FontFamily, new PropertyValue(_fontFamily)); }
1041 if (_fontStyle != null) { _outputVisualMap.Add(TextVisualProperty.FontStyle, new PropertyValue(_fontStyle)); }
1042 if (_multiLine != null) { _outputVisualMap.Add(TextVisualProperty.MultiLine, new PropertyValue((bool)_multiLine)); }
1043 if (_horizontalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment)); }
1044 if (_verticalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment)); }
1045 if (_textColor != null) { _outputVisualMap.Add(TextVisualProperty.TextColor, new PropertyValue(_textColor)); }
1046 if (_enableMarkup != null) { _outputVisualMap.Add(TextVisualProperty.EnableMarkup, new PropertyValue((bool)_enableMarkup)); }
1047 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1048 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1049 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1050 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1056 /// A class encapsulating the property map of a border visual.
1058 public class BorderVisual : VisualMap
1060 public BorderVisual() : base()
1064 private Color _color = null;
1065 private float? _size = null;
1066 private bool? _antiAliasing = null;
1069 /// Get or set the color of the border.<br>
1086 /// Get or set the width of the border (in pixels).<br>
1089 public float BorderSize
1093 return _size ?? (-1.0f);
1103 /// Get or set whether anti-aliasing of the border is required.<br>
1104 /// If not supplied, default is false.<br>
1107 public bool AntiAliasing
1111 return _antiAliasing ?? (false);
1115 _antiAliasing = value;
1120 protected override void ComposingPropertyMap()
1122 if (_color != null && _size != null)
1124 _outputVisualMap = new PropertyMap();
1125 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
1126 _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue((float)_size));
1127 _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color));
1128 if (_antiAliasing != null) { _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue((bool)_antiAliasing)); }
1129 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1130 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1131 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1132 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1138 /// A class encapsulating the property map of a color visual.
1140 public class ColorVisual : VisualMap
1142 public ColorVisual() : base()
1146 private Color _mixColorForColorVisual = null;
1149 /// Get or set the solid color required.<br>
1156 return _mixColorForColorVisual;
1160 _mixColorForColorVisual = value;
1165 protected override void ComposingPropertyMap()
1167 if (_mixColorForColorVisual != null)
1169 _outputVisualMap = new PropertyMap();
1170 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
1171 _outputVisualMap.Add(ColorVisualProperty.MixColor, new PropertyValue(_mixColorForColorVisual));
1172 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1173 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1174 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1180 /// A class encapsulating the property map of a gradient visual.
1182 public class GradientVisual : VisualMap
1184 public GradientVisual() : base()
1188 private Vector2 _startPosition = null;
1189 private Vector2 _endPosition = null;
1190 private Vector2 _center = null;
1191 private float? _radius = null;
1192 private PropertyArray _stopOffset = null;
1193 private PropertyArray _stopColor = null;
1194 private GradientVisualUnitsType? _units = null;
1195 private GradientVisualSpreadMethodType? _spreadMethod = null;
1198 /// Get or set the start position of a linear gradient.<br>
1199 /// Mandatory for Linear.<br>
1201 public Vector2 StartPosition
1205 return _startPosition;
1209 _startPosition = value;
1215 /// Get or set the end position of a linear gradient.<br>
1216 /// Mandatory for Linear.<br>
1218 public Vector2 EndPosition
1222 return _endPosition;
1226 _endPosition = value;
1232 /// Get or set the center point of a radial gradient.<br>
1233 /// Mandatory for Radial.<br>
1235 public Vector2 Center
1249 /// Get or set the size of the radius of a radial gradient.<br>
1250 /// Mandatory for Radial.<br>
1256 return _radius ?? (-1.0f);
1266 /// Get or set all the stop offsets.<br>
1267 /// A PropertyArray of float.<br>
1268 /// If not supplied, default is 0.0f and 1.0f.<br>
1271 public PropertyArray StopOffset
1279 _stopOffset = value;
1285 /// Get or set the color at the stop offsets.<br>
1286 /// A PropertyArray of Color.<br>
1287 /// At least 2 values required to show a gradient.<br>
1290 public PropertyArray StopColor
1304 /// Get or set defines the coordinate system for certain attributes of the points in a gradient.<br>
1305 /// If not supplied, default is GradientVisualUnitsType.ObjectBoundingBox.<br>
1308 public GradientVisualUnitsType Units
1312 return _units ?? (GradientVisualUnitsType.ObjectBoundingBox);
1322 /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.<br>
1323 /// If not supplied, default is GradientVisualSpreadMethodType.Pad.<br>
1326 public GradientVisualSpreadMethodType SpreadMethod
1330 return _spreadMethod ?? (GradientVisualSpreadMethodType.Pad);
1334 _spreadMethod = value;
1339 protected override void ComposingPropertyMap()
1341 if (((_startPosition != null && _endPosition != null) || (_center != null && _radius != null)) && _stopColor != null)
1343 _outputVisualMap = new PropertyMap();
1344 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
1345 _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
1346 if (_startPosition != null) { _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition)); }
1347 if (_endPosition != null) { _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition)); }
1348 if (_center != null) { _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center)); }
1349 if (_radius != null) { _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue((float)_radius)); }
1350 if (_stopOffset != null) { _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset)); }
1351 if (_units != null) { _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units)); }
1352 if (_spreadMethod != null) { _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod)); }
1353 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1354 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1355 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1356 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1362 /// A class encapsulating the property map of a mesh visual.
1364 public class MeshVisual : VisualMap
1366 public MeshVisual() : base()
1370 private string _objectURL = null;
1371 private string _materialtURL = null;
1372 private string _texturesPath = null;
1373 private MeshVisualShadingModeValue? _shadingMode = null;
1374 private bool? _useMipmapping = null;
1375 private bool? _useSoftNormals = null;
1376 private Vector3 _lightPosition = null;
1379 /// Get or set the location of the ".obj" file.<br>
1382 public string ObjectURL
1396 /// Get or set the location of the ".mtl" file.<br>
1397 /// If not specified, then a textureless object is assumed.<br>
1400 public string MaterialtURL
1404 return _materialtURL;
1408 _materialtURL = value;
1414 /// Get or set path to the directory the textures (including gloss and normal) are stored in.<br>
1415 /// Mandatory if using material.<br>
1417 public string TexturesPath
1421 return _texturesPath;
1425 _texturesPath = value;
1431 /// Get or set the type of shading mode that the mesh will use.<br>
1432 /// 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>
1433 /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting first).<br>
1436 public MeshVisualShadingModeValue ShadingMode
1440 return _shadingMode ?? (MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting);
1444 _shadingMode = value;
1450 /// Get or set whether to use mipmaps for textures or not.<br>
1451 /// If not specified, the default is true.<br>
1454 public bool UseMipmapping
1458 return _useMipmapping ?? (true);
1462 _useMipmapping = value;
1468 /// Get or set whether to average normals at each point to smooth textures or not.<br>
1469 /// If not specified, the default is true.<br>
1472 public bool UseSoftNormals
1476 return _useSoftNormals ?? (true);
1480 _useSoftNormals = value;
1486 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1487 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1488 /// and using all zeroes will place the light at the top left corner.<br>
1489 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1492 public Vector3 LightPosition
1496 return _lightPosition;
1500 _lightPosition = value;
1505 protected override void ComposingPropertyMap()
1507 if (_objectURL != null)
1509 _outputVisualMap = new PropertyMap();
1510 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
1511 _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
1512 if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
1513 if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
1514 if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
1515 if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
1516 if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
1517 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1518 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1519 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1520 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1526 /// A class encapsulating the property map of a primetive visual.
1528 public class PrimitiveVisual : VisualMap
1530 public PrimitiveVisual() : base()
1534 private PrimitiveVisualShapeType? _shape = null;
1535 private Color _mixColorForPrimitiveVisual = null;
1536 private int? _slices = null;
1537 private int? _stacks = null;
1538 private float? _scaleTopRadius = null;
1539 private float? _scaleBottomRadius = null;
1540 private float? _scaleHeight = null;
1541 private float? _scaleRadius = null;
1542 private Vector3 _scaleDimensions = null;
1543 private float? _bevelPercentage = null;
1544 private float? _bevelSmoothness = null;
1545 private Vector3 _lightPosition = null;
1548 /// Get or set the specific shape to render.<br>
1549 /// If not specified, the default is PrimitiveVisualShapeType.Sphere.<br>
1552 public PrimitiveVisualShapeType Shape
1556 return _shape ?? (PrimitiveVisualShapeType.Sphere);
1566 /// Get or set the color of the shape.<br>
1567 /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).<br>
1568 /// Applies to ALL shapes.<br>
1571 public Color MixColor
1575 return _mixColorForPrimitiveVisual ?? (new Color(0.5f, 0.5f, 0.5f, 1.0f));
1579 _mixColorForPrimitiveVisual = value;
1585 /// Get or set the number of slices as you go around the shape.<br>
1586 /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.<br>
1587 /// If not specified, the default is 128.<br>
1588 /// The range is from 1 to 255.<br>
1595 return _slices ?? (128);
1605 /// Get or set the number of stacks as you go down the shape.<br>
1606 /// For spheres, 'stacks' determines how many layers there are as you go down the object.<br>
1607 /// If not specified, the default is 128.<br>
1608 /// The range is from 1 to 255.<br>
1615 return _stacks ?? (128);
1625 /// Get or set the scale of the radius of the top circle of a conical frustrum.<br>
1626 /// If not specified, the default is 1.0f.<br>
1627 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br>
1628 /// Only values greater than or equal to 0.0f are accepted.<br>
1631 public float ScaleTopRadius
1635 return _scaleTopRadius ?? (1.0f);
1639 _scaleTopRadius = value;
1645 /// Get or set the scale of the radius of the bottom circle of a conical frustrum.<br>
1646 /// If not specified, the default is 1.5f.<br>
1647 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br>
1648 /// - PrimitiveVisualShapeType.Cone<br>
1649 /// Only values greater than or equal to 0.0f are accepted.<br>
1652 public float ScaleBottomRadius
1656 return _scaleBottomRadius ?? (1.5f);
1660 _scaleBottomRadius = value;
1666 /// Get or set the scale of the height of a conic.<br>
1667 /// If not specified, the default is 3.0f.<br>
1669 /// - PrimitiveVisualShapeType.ConicalFrustrum<br>
1670 /// - PrimitiveVisualShapeType.Cone<br>
1671 /// - PrimitiveVisualShapeType.Cylinder<br>
1672 /// Only values greater than or equal to 0.0f are accepted.<br>
1675 public float ScaleHeight
1679 return _scaleHeight ?? (3.0f);
1683 _scaleHeight = value;
1689 /// Get or set the scale of the radius of a cylinder.<br>
1690 /// If not specified, the default is 1.0f.<br>
1692 /// - PrimitiveVisualShapeType.Cylinder<br>
1693 /// Only values greater than or equal to 0.0f are accepted.<br>
1696 public float ScaleRadius
1700 return _scaleRadius ?? (1.0f);
1704 _scaleRadius = value;
1710 /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.<br>
1711 /// If not specified, the default is Vector3.One.<br>
1713 /// - PrimitiveVisualShapeType.Cube<br>
1714 /// - PrimitiveVisualShapeType.Octahedron<br>
1715 /// - PrimitiveVisualShapeType.BevelledCube<br>
1716 /// Each vector3 parameter should be greater than or equal to 0.0f.<br>
1719 public Vector3 ScaleDimensions
1723 return _scaleDimensions ?? (Vector3.One);
1727 _scaleDimensions = value;
1733 /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.<br>
1734 /// 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>
1735 /// If not specified, the default is 0.0f (no bevel).<br>
1737 /// - PrimitiveVisualShapeType.BevelledCube<br>
1738 /// The range is from 0.0f to 1.0f.<br>
1741 public float BevelPercentage
1745 return _bevelPercentage ?? (0.0f);
1749 _bevelPercentage = value;
1755 /// Get or set defines how smooth the bevelled edges should be.<br>
1756 /// If not specified, the default is 0.0f (sharp edges).<br>
1758 /// - PrimitiveVisualShapeType.BevelledCube<br>
1759 /// The range is from 0.0f to 1.0f.<br>
1762 public float BevelSmoothness
1766 return _bevelSmoothness ?? (0.0f);
1770 _bevelSmoothness = value;
1776 /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1777 /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1778 /// and using all zeroes will place the light at the top left corner.<br>
1779 /// If not specified, the default is an offset outwards from the center of the screen.<br>
1780 /// Applies to ALL shapes.<br>
1783 public Vector3 LightPosition
1787 return _lightPosition;
1791 _lightPosition = value;
1796 protected override void ComposingPropertyMap()
1798 _outputVisualMap = new PropertyMap(); ;
1799 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
1800 if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
1801 if (_mixColorForPrimitiveVisual != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColorForPrimitiveVisual)); }
1802 if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
1803 if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
1804 if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
1805 if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
1806 if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
1807 if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
1808 if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
1809 if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
1810 if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
1811 if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
1812 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1813 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1814 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1819 /// A class encapsulating the property map of a n-patch image visual.
1821 public class NPatchVisual : VisualMap
1823 public NPatchVisual() : base()
1827 private string _url = null;
1828 private bool? _borderOnly = null;
1829 private Rectangle _border = null;
1832 /// Get or set the URL of the image.<br>
1849 /// Get or set whether to draws the borders only(If true).<br>
1850 /// If not specified, the default is false.<br>
1851 /// For N-Patch images only.<br>
1854 public bool BorderOnly
1858 return _borderOnly ?? false;
1862 _borderOnly = value;
1868 /// The border of the image in the order: left, right, bottom, top.<br>
1869 /// For N-Patch images only.<br>
1872 public Rectangle Border
1885 protected override void ComposingPropertyMap()
1889 _outputVisualMap = new PropertyMap();
1890 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1891 _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
1892 if (_borderOnly != null) { _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
1893 if (_border != null) { _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); }
1894 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1895 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1896 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1897 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1903 /// A class encapsulating the property map of a SVG visual.
1905 public class SVGVisual : VisualMap
1907 public SVGVisual() : base()
1911 private string _url = null;
1926 protected override void ComposingPropertyMap()
1930 _outputVisualMap = new PropertyMap();
1931 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
1932 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1933 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1934 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1935 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1936 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1942 /// A class encapsulating the property map of a Animated Image(AGIF) visual.
1944 public class AnimatedImageVisual : VisualMap
1946 public AnimatedImageVisual() : base()
1950 private string _url = null;
1965 protected override void ComposingPropertyMap()
1969 _outputVisualMap = new PropertyMap();
1970 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage));
1971 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1972 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1973 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1974 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1975 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1981 /// A class encapsulating the property map of a visual transition(Animator).
1983 public class AnimatorVisual : VisualMap
1985 public AnimatorVisual() : base()
1989 private string _alphaFunction = null;
1990 private int _startTime = 0;
1991 private int _endTime = 0;
1992 private string _target = null;
1993 private string _propertyIndex = null;
1994 private object _destinationValue = null;
1996 public string AlphaFunction
2000 return _alphaFunction;
2004 _alphaFunction = value;
2008 public int StartTime
2032 public string Target
2044 public string PropertyIndex
2048 return _propertyIndex;
2052 _propertyIndex = value;
2056 public object DestinationValue
2060 return _destinationValue;
2064 _destinationValue = value;
2068 protected override void ComposingPropertyMap()
2070 PropertyMap _animator = new PropertyMap();
2071 _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
2073 PropertyMap _timePeriod = new PropertyMap();
2074 _timePeriod.Add("duration", new PropertyValue((_endTime - _startTime) / 1000.0f));
2075 _timePeriod.Add("delay", new PropertyValue(_startTime / 1000.0f));
2076 _animator.Add("timePeriod", new PropertyValue(_timePeriod));
2078 string _str1 = _propertyIndex.Substring(0, 1);
2079 string _str2 = _propertyIndex.Substring(1);
2080 string _str = _str1.ToLower() + _str2;
2082 PropertyValue val = PropertyValue.CreateFromObject(_destinationValue);
2084 PropertyMap _transition = new PropertyMap();
2085 _transition.Add("target", new PropertyValue(_target));
2086 _transition.Add("property", new PropertyValue(_str));
2087 _transition.Add("targetValue", val);
2088 _transition.Add("animator", new PropertyValue(_animator));
2090 _outputVisualMap = _transition;