68fd46b33002cdd1f2ff5878094faca3ca22c5e4
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VisualMaps.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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.
14 //
15
16 namespace Tizen.NUI
17 {
18     using System;
19     using System.Runtime.InteropServices;
20
21     /// <summary>
22     /// A class encapsulating the transform map of visual.
23     /// </summary>
24     public class VisualMap
25     {
26         private Vector2 _visualSize = Vector2.Zero;
27         private Vector2 _visualOffset = Vector2.Zero;
28         private Vector4 _visualOffsetSizeMode = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); // default absolute
29         private AlignType _visualOrigin = AlignType.TOP_BEGIN;
30         private AlignType _visualAnchorPoint = AlignType.TOP_BEGIN;
31
32         private PropertyMap _visualTransformMap = null;
33
34         private float _depthIndex = 0.0f;
35         protected PropertyMap _outputVisualMap = null;
36
37         public VisualMap()
38         {
39         }
40
41         /// <summary>
42         /// Get or set size of the visual.
43         /// It can be either relative (percentage of the parent)
44         /// or absolute (in world units).
45         /// </summary>
46         public Vector2 VisualSize
47         {
48             get
49             {
50                 return _visualSize;
51             }
52             set
53             {
54                 _visualSize = value;
55             }
56         }
57
58         /// <summary>
59         /// Get or set offset of the visual.
60         /// It can be either relative (percentage of the parent)
61         /// or absolute (in world units).
62         /// </summary>
63         public Vector2 Offset
64         {
65             get
66             {
67                 return _visualOffset;
68             }
69             set
70             {
71                 _visualOffset = value;
72             }
73         }
74
75         /// <summary>
76         /// Get or set offset/size mode of the visual.
77         /// Indicates which components of the offset and size are relative
78         /// (percentage of the parent) or absolute (in world units).
79         /// 0 indicates the component is relative, and 1 absolute.
80         /// </summary>
81         public Vector4 OffsetSizeMode
82         {
83             get
84             {
85                 return _visualOffsetSizeMode;
86             }
87             set
88             {
89                 _visualOffsetSizeMode = value;
90             }
91         }
92
93         /// <summary>
94         /// Get or set the origin of the visual within its control area.
95         /// </summary>
96         public AlignType Origin
97         {
98             get
99             {
100                 return _visualOrigin;
101             }
102             set
103             {
104                 _visualOrigin = value;
105             }
106         }
107
108         /// <summary>
109         /// Get or set the anchor-point of the visual.
110         /// </summary>
111         public AlignType AnchorPoint
112         {
113             get
114             {
115                 return _visualAnchorPoint;
116             }
117             set
118             {
119                 _visualAnchorPoint = value;
120             }
121         }
122
123         /// <summary>
124         /// Get or set the depth index of the visual.
125         /// </summary>
126         public float DepthIndex
127         {
128             get
129             {
130                 return _depthIndex;
131             }
132             set
133             {
134                 _depthIndex = value;
135             }
136         }
137
138         private void ComposingTransformMap()
139         {
140             if (_visualSize != Vector2.Zero)
141             {
142                 _visualTransformMap = new PropertyMap();
143                 _visualTransformMap.Add((int)VisualTransformPropertyType.SIZE, new PropertyValue(_visualSize));
144                 _visualTransformMap.Add((int)VisualTransformPropertyType.OFFSET, new PropertyValue(_visualOffset));
145                 _visualTransformMap.Add((int)VisualTransformPropertyType.OFFSET_SIZE_MODE, new PropertyValue(_visualOffsetSizeMode));
146                 _visualTransformMap.Add((int)VisualTransformPropertyType.ORIGIN, new PropertyValue((int)_visualOrigin));
147                 _visualTransformMap.Add((int)VisualTransformPropertyType.ANCHOR_POINT, new PropertyValue((int)_visualAnchorPoint));
148             }
149         }
150
151         /// <summary>
152         /// Get the transform map used by the visual.
153         /// </summary>
154         public PropertyMap OutputTransformMap
155         {
156             get
157             {
158                 ComposingTransformMap();
159                 return _visualTransformMap;
160             }
161         }
162
163         protected virtual void ComposingPropertyMap()
164         {
165             _outputVisualMap = new PropertyMap();
166         }
167
168         /// <summary>
169         /// Get the property map to create the visual.
170         /// </summary>
171         public PropertyMap OutputVisualMap
172         {
173             get
174             {
175                 ComposingPropertyMap();
176                 return _outputVisualMap;
177             }
178         }
179     }
180
181     /// <summary>
182     /// A class encapsulating the property map of a image visual.
183     /// </summary>
184     public class ImageVisualMap : VisualMap
185     {
186         public ImageVisualMap() : base()
187         {
188         }
189
190         private string _url = "";
191         private FittingModeType _fittingMode = FittingModeType.ShrinkToFit;
192         private SamplingModeType _samplingMode = SamplingModeType.Box;
193         private int _desiredWidth = 0;
194         private int _desiredHeight = 0;
195         private bool _synchronousLoading = false;
196         private bool _borderOnly = false;
197         private Vector4 _pixelArea = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
198         private WrapModeType _wrapModeU = WrapModeType.ClampToEdge;
199         private WrapModeType _wrapModeV = WrapModeType.ClampToEdge;
200
201         /// <summary>
202         /// Get or set the URL of the image.
203         /// </summary>
204         public string URL
205         {
206             get
207             {
208                 return _url;
209             }
210             set
211             {
212                 _url = value;
213             }
214         }
215
216         /// <summary>
217         /// Get or set fitting options, used when resizing images to fit desired dimensions.
218         /// If not supplied, default is FittingMode::SHRINK_TO_FIT.
219         /// For Normal Quad images only.
220         /// </summary>
221         public FittingModeType FittingMode
222         {
223             get
224             {
225                 return _fittingMode;
226             }
227             set
228             {
229                 _fittingMode = value;
230             }
231         }
232
233         /// <summary>
234         /// Get or set filtering options, used when resizing images to sample original pixels.
235         /// If not supplied, default is SamplingMode::BOX.
236         /// For Normal Quad images only.
237         /// </summary>
238         public SamplingModeType SamplingMode
239         {
240             get
241             {
242                 return _samplingMode;
243             }
244             set
245             {
246                 _samplingMode = value;
247             }
248         }
249
250         /// <summary>
251         /// Get or set the desired image width.
252         /// If not specified, the actual image width is used.
253         /// For Normal Quad images only.
254         /// </summary>
255         public int DesiredWidth
256         {
257             get
258             {
259                 return _desiredWidth;
260             }
261             set
262             {
263                 _desiredWidth = value;
264             }
265         }
266
267         /// <summary>
268         /// Get or set the desired image height.
269         /// If not specified, the actual image height is used.
270         /// For Normal Quad images only.
271         /// </summary>
272         public int DesiredHeight
273         {
274             get
275             {
276                 return _desiredHeight;
277             }
278             set
279             {
280                 _desiredHeight = value;
281             }
282         }
283
284         /// <summary>
285         /// Get or set whether to load the image synchronously.
286         /// If not specified, the default is false, i.e. the image is loaded asynchronously.
287         /// For Normal Quad images only.
288         /// </summary>
289         public bool SynchronousLoading
290         {
291             get
292             {
293                 return _synchronousLoading;
294             }
295             set
296             {
297                 _synchronousLoading = value;
298             }
299         }
300
301         /// <summary>
302         /// Get or set whether to draws the borders only(If true).
303         /// If not specified, the default is false.
304         /// For N-Patch images only.
305         /// </summary>
306         public bool BorderOnly
307         {
308             get
309             {
310                 return _borderOnly;
311             }
312             set
313             {
314                 _borderOnly = value;
315             }
316         }
317
318         /// <summary>
319         /// Get or set the image area to be displayed.
320         /// It is a rectangular area.
321         /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.
322         /// If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
323         /// For For Normal QUAD image only.
324         /// </summary>
325         public Vector4 PixelArea
326         {
327             get
328             {
329                 return _pixelArea;
330             }
331             set
332             {
333                 _pixelArea = value;
334             }
335         }
336
337         /// <summary>
338         /// Get or set the wrap mode for u coordinate.
339         /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.
340         /// If not specified, the default is CLAMP.
341         /// For Normal QUAD image only.
342         /// </summary>
343         public WrapModeType WrapModeU
344         {
345             get
346             {
347                 return _wrapModeU;
348             }
349             set
350             {
351                 _wrapModeU = value;
352             }
353         }
354
355         /// <summary>
356         /// Get or set the wrap mode for v coordinate.
357         /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.
358         /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.
359         /// If not specified, the default is CLAMP.
360         /// For Normal QUAD image only.
361         /// </summary>
362         public WrapModeType WrapModeV
363         {
364             get
365             {
366                 return _wrapModeV;
367             }
368             set
369             {
370                 _wrapModeV = value;
371             }
372         }
373
374         protected override void ComposingPropertyMap()
375         {
376             if (_url != "")
377             {
378                 _outputVisualMap = new PropertyMap();
379                 _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Image));
380                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.URL, new PropertyValue(_url));
381                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode));
382                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode));
383
384                 if (_desiredWidth != 0)
385                 {
386                     _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.DesiredWidth, new PropertyValue(_desiredWidth));
387                 }
388
389                 if (_desiredHeight != 0)
390                 {
391                     _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.DesiredHeight, new PropertyValue(_desiredHeight));
392                 }
393
394                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronousLoading));
395                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly));
396                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea));
397                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU));
398                 _outputVisualMap.Add(Tizen.NUI.Constants.ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV));
399             }
400         }
401     }
402
403     /// <summary>
404     /// A class encapsulating the property map of a text visual.
405     /// </summary>
406     public class TextVisualMap : VisualMap
407     {
408         public TextVisualMap() : base()
409         {
410         }
411
412         private string _text = "";
413         private string _fontFamily = "";
414         private PropertyMap _fontStyle = null;
415         private float _pointSize = 0.0f;
416         private bool _multiLine = false;
417         private string _horizontalAlignment = "BEGIN";
418         private string _verticalAlignment = "TOP";
419         private Color _textColor = Color.Black;
420         private bool _enableMarkup = false;
421
422         /// <summary>
423         /// Get or set the text to display in UTF-8 format.
424         /// </summary>
425         public string Text
426         {
427             get
428             {
429                 return _text;
430             }
431             set
432             {
433                 _text = value;
434             }
435         }
436
437         /// <summary>
438         /// Get or set the requested font family to use.
439         /// </summary>
440         public string FontFamily
441         {
442             get
443             {
444                 return _fontFamily;
445             }
446             set
447             {
448                 _fontFamily = value;
449             }
450         }
451
452         /// <summary>
453         /// Get or set the requested font style to use.
454         /// </summary>
455         public PropertyMap FontStyle
456         {
457             get
458             {
459                 return _fontStyle;
460             }
461             set
462             {
463                 _fontStyle = value;
464             }
465         }
466
467         /// <summary>
468         /// Get or set the size of font in points.
469         /// </summary>
470         public float PointSize
471         {
472             get
473             {
474                 return _pointSize;
475             }
476             set
477             {
478                 _pointSize = value;
479             }
480         }
481
482         /// <summary>
483         /// Get or set the single-line or multi-line layout option.
484         /// </summary>
485         public bool MultiLine
486         {
487             get
488             {
489                 return _multiLine;
490             }
491             set
492             {
493                 _multiLine = value;
494             }
495         }
496
497         /// <summary>
498         /// Get or set the line horizontal alignment.
499         /// If not specified, the default is BEGIN.
500         /// </summary>
501         public string HorizontalAlignment
502         {
503             get
504             {
505                 return _horizontalAlignment;
506             }
507             set
508             {
509                 _horizontalAlignment = value;
510             }
511         }
512
513         /// <summary>
514         /// Get or set the line vertical alignment.
515         /// If not specified, the default is TOP.
516         /// </summary>
517         public string VerticalAlignment
518         {
519             get
520             {
521                 return _verticalAlignment;
522             }
523             set
524             {
525                 _verticalAlignment = value;
526             }
527         }
528
529         /// <summary>
530         /// Get or set the color of the text.
531         /// </summary>
532         public Color TextColor
533         {
534             get
535             {
536                 return _textColor;
537             }
538             set
539             {
540                 _textColor = value;
541             }
542         }
543
544         /// <summary>
545         /// Get or set whether the mark-up processing is enabled.
546         /// </summary>
547         public bool EnableMarkup
548         {
549             get
550             {
551                 return _enableMarkup;
552             }
553             set
554             {
555                 _enableMarkup = value;
556             }
557         }
558
559         protected override void ComposingPropertyMap()
560         {
561             if (_text != "")
562             {
563                 _outputVisualMap = new PropertyMap();
564                 _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Text));
565                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.Text, new PropertyValue(_text));
566
567                 if (_fontFamily != "")
568                 {
569                     _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.FontFamily, new PropertyValue(_fontFamily));
570                 }
571
572                 if (_fontStyle != null)
573                 {
574                     _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.FontStyle, new PropertyValue(_fontStyle));
575                 }
576
577                 if (_pointSize != 0)
578                 {
579                     _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.PointSize, new PropertyValue(_pointSize));
580                 }
581
582                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.MultiLine, new PropertyValue(_multiLine));
583                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment));
584                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment));
585                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.TextColor, new PropertyValue(_textColor));
586                 _outputVisualMap.Add(Tizen.NUI.Constants.TextVisualProperty.EnableMarkup, new PropertyValue(_enableMarkup));
587             }
588         }
589     }
590
591     /// <summary>
592     /// A class encapsulating the property map of a border visual.
593     /// </summary>
594     public class BorderVisualMap : VisualMap
595     {
596         public BorderVisualMap() : base()
597         {
598         }
599
600         private Color _color = Color.Black;
601         private float _size = 0.000001f;
602         private bool _antiAliasing = false;
603
604         /// <summary>
605         /// Get or set the color of the border.
606         /// </summary>
607         public Color Color
608         {
609             get
610             {
611                 return _color;
612             }
613             set
614             {
615                 _color = value;
616             }
617         }
618
619         /// <summary>
620         /// Get or set the width of the border (in pixels).
621         /// </summary>
622         public float Size
623         {
624             get
625             {
626                 return _size;
627             }
628             set
629             {
630                 _size = value;
631             }
632         }
633
634         /// <summary>
635         /// Get or set whether anti-aliasing of the border is required.
636         /// If not supplied, default is false.
637         /// </summary>
638         public bool AntiAliasing
639         {
640             get
641             {
642                 return _antiAliasing;
643             }
644             set
645             {
646                 _antiAliasing = value;
647             }
648         }
649
650         protected override void ComposingPropertyMap()
651         {
652             if (_size > 0.000001f)
653             {
654                 _outputVisualMap = new PropertyMap();
655                 _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Border));
656                 _outputVisualMap.Add(Tizen.NUI.Constants.BorderVisualProperty.Color, new PropertyValue(_color));
657                 _outputVisualMap.Add(Tizen.NUI.Constants.BorderVisualProperty.Size, new PropertyValue(_size));
658                 _outputVisualMap.Add(Tizen.NUI.Constants.BorderVisualProperty.AntiAliasing, new PropertyValue(_antiAliasing));
659             }
660         }
661     }
662
663     /// <summary>
664     /// A class encapsulating the property map of a color visual.
665     /// </summary>
666     public class ColorVisualMap : VisualMap
667     {
668         public ColorVisualMap() : base()
669         {
670         }
671
672         private Color _mixColor = Color.Black;
673
674         /// <summary>
675         /// Get or set the solid color required.
676         /// </summary>
677         public Color MixColor
678         {
679             get
680             {
681                 return _mixColor;
682             }
683             set
684             {
685                 _mixColor = value;
686             }
687         }
688
689         protected override void ComposingPropertyMap()
690         {
691             _outputVisualMap = new PropertyMap();
692             _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Color));
693             _outputVisualMap.Add(Tizen.NUI.Constants.ColorVisualProperty.MixColor, new PropertyValue(_mixColor));
694         }
695     }
696
697     /// <summary>
698     /// A class encapsulating the property map of a gradient visual.
699     /// </summary>
700     public class GradientVisualMap : VisualMap
701     {
702         public GradientVisualMap() : base()
703         {
704         }
705
706         private Vector2 _startPosition = Vector2.Zero;
707         private Vector2 _endPosition = Vector2.Zero;
708         private Vector2 _center = Vector2.Zero;
709         private float _radius = 0.000001f;
710         private PropertyArray _stopOffset = null; //0.0, 1.0
711         private PropertyArray _stopColor = null; // Color.Black, Color.Blue
712         private GradientVisualUnitsType _units = GradientVisualUnitsType.ObjectBoundingBox;
713         private GradientVisualSpreadMethodType _spreadMethod = GradientVisualSpreadMethodType.Pad;
714
715         /// <summary>
716         /// Get or set the start position of a linear gradient.
717         /// Mandatory for Linear.
718         /// </summary>
719         public Vector2 StartPosition
720         {
721             get
722             {
723                 return _startPosition;
724             }
725             set
726             {
727                 _startPosition = value;
728             }
729         }
730
731         /// <summary>
732         /// Get or set the end position of a linear gradient.
733         /// Mandatory for Linear.
734         /// </summary>
735         public Vector2 EndPosition
736         {
737             get
738             {
739                 return _endPosition;
740             }
741             set
742             {
743                 _endPosition = value;
744             }
745         }
746
747         /// <summary>
748         /// Get or set the center point of a radial gradient.
749         /// Mandatory for Radial.
750         /// </summary>
751         public Vector2 Center
752         {
753             get
754             {
755                 return _center;
756             }
757             set
758             {
759                 _center = value;
760             }
761         }
762
763         /// <summary>
764         /// Get or set the size of the radius of a radial gradient.
765         /// Mandatory for Radial.
766         /// </summary>
767         public float Radius
768         {
769             get
770             {
771                 return _radius;
772             }
773             set
774             {
775                 _radius = value;
776             }
777         }
778
779         /// <summary>
780         /// Get or set all the stop offsets.
781         /// A PropertyArray of float.
782         /// If not supplied, default is 0.0f and 1.0f.
783         /// </summary>
784         public PropertyArray StopOffset
785         {
786             get
787             {
788                 return _stopOffset;
789             }
790             set
791             {
792                 _stopOffset = value;
793             }
794         }
795
796         /// <summary>
797         /// Get or set the color at the stop offsets.
798         /// A PropertyArray of Color.
799         /// At least 2 values required to show a gradient.
800         /// </summary>
801         public PropertyArray StopColor
802         {
803             get
804             {
805                 return _stopColor;
806             }
807             set
808             {
809                 _stopColor = value;
810             }
811         }
812
813         /// <summary>
814         /// Get or set defines the coordinate system for certain attributes of the points in a gradient.
815         /// If not supplied, default is GradientVisualUnitsType.OBJECT_BOUNDING_BOX.
816         /// </summary>
817         public GradientVisualUnitsType Units
818         {
819             get
820             {
821                 return _units;
822             }
823             set
824             {
825                 _units = value;
826             }
827         }
828
829         /// <summary>
830         /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
831         /// If not supplied, default is GradientVisualSpreadMethodType.PAD.
832         /// </summary>
833         public GradientVisualSpreadMethodType SpreadMethod
834         {
835             get
836             {
837                 return _spreadMethod;
838             }
839             set
840             {
841                 _spreadMethod = value;
842             }
843         }
844
845         protected override void ComposingPropertyMap()
846         {
847             if (_startPosition != Vector2.Zero && _endPosition != Vector2.Zero && _center != Vector2.Zero
848                 && _radius > 0.000001f && _stopColor != null)
849             {
850                 _outputVisualMap = new PropertyMap();
851                 _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Gradient));
852                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.StartPosition, new PropertyValue(_startPosition));
853                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.EndPosition, new PropertyValue(_endPosition));
854                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.Center, new PropertyValue(_center));
855                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.Radius, new PropertyValue(_radius));
856
857                 if (_stopOffset != null)
858                 {
859                     _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset));
860                 }
861
862                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
863                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.Units, new PropertyValue((int)_units));
864                 _outputVisualMap.Add(Tizen.NUI.Constants.GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod));
865             }
866         }
867     }
868
869     /// <summary>
870     /// A class encapsulating the property map of a mesh visual.
871     /// </summary>
872     public class MeshVisualMap : VisualMap
873     {
874         public MeshVisualMap() : base()
875         {
876         }
877
878         private string _objectURL = "";
879         private string _materialtURL = "";
880         private string _texturesPath = "";
881         private MeshVisualShadingModeValue _shadingMode = MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting;
882         private bool _useMipmapping = true;
883         private bool _useSoftNormals = true;
884         private Vector3 _lightPosition = null; //default center of screen
885
886         /// <summary>
887         /// Get or set the location of the ".obj" file.
888         /// </summary>
889         public string ObjectURL
890         {
891             get
892             {
893                 return _objectURL;
894             }
895             set
896             {
897                 _objectURL = value;
898             }
899         }
900
901         /// <summary>
902         /// Get or set the location of the ".mtl" file.
903         /// If not specified, then a textureless object is assumed.
904         /// </summary>
905         public string MaterialtURL
906         {
907             get
908             {
909                 return _materialtURL;
910             }
911             set
912             {
913                 _materialtURL = value;
914             }
915         }
916
917         /// <summary>
918         /// Get or set path to the directory the textures (including gloss and normal) are stored in.
919         /// Mandatory if using material.
920         /// </summary>
921         public string TexturesPath
922         {
923             get
924             {
925                 return _texturesPath;
926             }
927             set
928             {
929                 _texturesPath = value;
930             }
931         }
932
933         /// <summary>
934         /// Get or set the type of shading mode that the mesh will use.
935         /// 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.
936         /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING first).
937         /// </summary>
938         public MeshVisualShadingModeValue ShadingMode
939         {
940             get
941             {
942                 return _shadingMode;
943             }
944             set
945             {
946                 _shadingMode = value;
947             }
948         }
949
950         /// <summary>
951         /// Get or set whether to use mipmaps for textures or not.
952         /// If not specified, the default is true.
953         /// </summary>
954         public bool UseMipmapping
955         {
956             get
957             {
958                 return _useMipmapping;
959             }
960             set
961             {
962                 _useMipmapping = value;
963             }
964         }
965
966         /// <summary>
967         /// Get or set whether to average normals at each point to smooth textures or not.
968         /// If not specified, the default is true.
969         /// </summary>
970         public bool UseSoftNormals
971         {
972             get
973             {
974                 return _useSoftNormals;
975             }
976             set
977             {
978                 _useSoftNormals = value;
979             }
980         }
981
982         /// <summary>
983         /// Get or set the position, in stage space, of the point light that applies lighting to the model.
984         /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
985         /// and using all zeroes will place the light at the top left corner.
986         /// If not specified, the default is an offset outwards from the center of the screen.
987         /// </summary>
988         public Vector3 LightPosition
989         {
990             get
991             {
992                 return _lightPosition;
993             }
994             set
995             {
996                 _lightPosition = value;
997             }
998         }
999
1000         protected override void ComposingPropertyMap()
1001         {
1002             if (_objectURL != "")
1003             {
1004                 _outputVisualMap = new PropertyMap();
1005                 _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Mesh));
1006                 _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
1007
1008                 if (_materialtURL != "" && _texturesPath != "")
1009                 {
1010                     _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL));
1011                     _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath));
1012                 }
1013
1014                 _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode));
1015                 _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.UseMipmapping, new PropertyValue(_useMipmapping));
1016                 _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.UseSoftNormals, new PropertyValue(_useSoftNormals));
1017
1018                 if (_lightPosition != null)
1019                 {
1020                     _outputVisualMap.Add(Tizen.NUI.Constants.MeshVisualProperty.LightPosition, new PropertyValue(_lightPosition));
1021                 }
1022             }
1023         }
1024     }
1025
1026     /// <summary>
1027     /// A class encapsulating the property map of a primetive visual.
1028     /// </summary>
1029     public class PrimitiveVisualMap : VisualMap
1030     {
1031         public PrimitiveVisualMap() : base()
1032         {
1033         }
1034
1035         private PrimitiveVisualShapeType _shape = PrimitiveVisualShapeType.Sphere;
1036         private Color _mixColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
1037         private int _slices = 128;
1038         private int _stacks = 128;
1039         private float _scaleTopRadius = 1.0f;
1040         private float _scaleBottomRadius = 1.5f;
1041         private float _scaleHeight = 3.0f;
1042         private float _scaleRadius = 1.0f;
1043         private Vector3 _scaleDimensions = Vector3.One;
1044         private float _bevelPercentage = 0.0f;
1045         private float _bevelSmoothness = 0.0f;
1046         private Vector3 _lightPosition = null; // default ?? center of screen
1047
1048         /// <summary>
1049         /// Get or set the specific shape to render.
1050         /// If not specified, the default is PrimitiveVisualShapeType.SPHERE.
1051         /// </summary>
1052         public PrimitiveVisualShapeType Shape
1053         {
1054             get
1055             {
1056                 return _shape;
1057             }
1058             set
1059             {
1060                 _shape = value;
1061             }
1062         }
1063
1064         /// <summary>
1065         /// Get or set the color of the shape.
1066         /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).
1067         /// Applies to ALL shapes.
1068         /// </summary>
1069         public Color MixColor
1070         {
1071             get
1072             {
1073                 return _mixColor;
1074             }
1075             set
1076             {
1077                 _mixColor = value;
1078             }
1079         }
1080
1081         /// <summary>
1082         /// Get or set the number of slices as you go around the shape.
1083         /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.
1084         /// If not specified, the default is 128.
1085         /// The range is from 1 to 255.
1086         /// </summary>
1087         public int Slices
1088         {
1089             get
1090             {
1091                 return _slices;
1092             }
1093             set
1094             {
1095                 _slices = value;
1096             }
1097         }
1098
1099         /// <summary>
1100         /// Get or set the number of stacks as you go down the shape.
1101         /// For spheres, 'stacks' determines how many layers there are as you go down the object.
1102         /// If not specified, the default is 128.
1103         /// The range is from 1 to 255.
1104         /// </summary>
1105         public int Stacks
1106         {
1107             get
1108             {
1109                 return _stacks;
1110             }
1111             set
1112             {
1113                 _stacks = value;
1114             }
1115         }
1116
1117         /// <summary>
1118         /// Get or set the scale of the radius of the top circle of a conical frustrum.
1119         /// If not specified, the default is 1.0f.
1120         /// Applies to: - PrimitiveVisualShapeType.CONICAL_FRUSTRUM
1121         /// Only values greater than or equal to 0.0f are accepted.
1122         /// </summary>
1123         public float ScaleTopRadius
1124         {
1125             get
1126             {
1127                 return _scaleTopRadius;
1128             }
1129             set
1130             {
1131                 _scaleTopRadius = value;
1132             }
1133         }
1134
1135         /// <summary>
1136         /// Get or set the scale of the radius of the bottom circle of a conical frustrum.
1137         /// If not specified, the default is 1.5f.
1138         /// Applies to:  - PrimitiveVisualShapeType.CONICAL_FRUSTRUM
1139         ///              - PrimitiveVisualShapeType.CONE
1140         /// Only values greater than or equal to 0.0f are accepted.
1141         /// </summary>
1142         public float ScaleBottomRadius
1143         {
1144             get
1145             {
1146                 return _scaleBottomRadius;
1147             }
1148             set
1149             {
1150                 _scaleBottomRadius = value;
1151             }
1152         }
1153
1154         /// <summary>
1155         /// Get or set the scale of the height of a conic.
1156         /// If not specified, the default is 3.0f.
1157         /// Applies to:
1158         ///      - Shape::CONICAL_FRUSTRUM
1159         ///      - Shape::CONE
1160         ///      - Shape::CYLINDER
1161         /// Only values greater than or equal to 0.0f are accepted.
1162         /// </summary>
1163         public float ScaleHeight
1164         {
1165             get
1166             {
1167                 return _scaleHeight;
1168             }
1169             set
1170             {
1171                 _scaleHeight = value;
1172             }
1173         }
1174
1175         /// <summary>
1176         /// Get or set the scale of the radius of a cylinder.
1177         /// If not specified, the default is 1.0f.
1178         /// Applies to:
1179         ///      - Shape::CYLINDER
1180         /// Only values greater than or equal to 0.0f are accepted.
1181         /// </summary>
1182         public float ScaleRadius
1183         {
1184             get
1185             {
1186                 return _scaleRadius;
1187             }
1188             set
1189             {
1190                 _scaleRadius = value;
1191             }
1192         }
1193
1194         /// <summary>
1195         /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.
1196         /// If not specified, the default is Vector3.One.
1197         /// Applies to:
1198         ///      - Shape::CUBE
1199         ///      - Shape::OCTAHEDRON
1200         ///      - Shape::BEVELLED_CUBE
1201         /// Each vector3 parameter should be greater than or equal to 0.0f.
1202         /// </summary>
1203         public Vector3 ScaleDimensions
1204         {
1205             get
1206             {
1207                 return _scaleDimensions;
1208             }
1209             set
1210             {
1211                 _scaleDimensions = value;
1212             }
1213         }
1214
1215         /// <summary>
1216         /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.
1217         /// 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.
1218         /// If not specified, the default is 0.0f (no bevel).
1219         /// Applies to:
1220         ///      - Shape::BEVELLED_CUBE
1221         /// The range is from 0.0f to 1.0f.
1222         /// </summary>
1223         public float BevelPercentage
1224         {
1225             get
1226             {
1227                 return _bevelPercentage;
1228             }
1229             set
1230             {
1231                 _bevelPercentage = value;
1232             }
1233         }
1234
1235         /// <summary>
1236         /// Get or set defines how smooth the bevelled edges should be.
1237         /// If not specified, the default is 0.0f (sharp edges).
1238         /// Applies to:
1239         ///      - Shape::BEVELLED_CUBE
1240         /// The range is from 0.0f to 1.0f.
1241         /// </summary>
1242         public float BevelSmoothness
1243         {
1244             get
1245             {
1246                 return _bevelSmoothness;
1247             }
1248             set
1249             {
1250                 _bevelSmoothness = value;
1251             }
1252         }
1253
1254         /// <summary>
1255         /// Get or set the position, in stage space, of the point light that applies lighting to the model.
1256         /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1257         /// and using all zeroes will place the light at the top left corner.
1258         /// If not specified, the default is an offset outwards from the center of the screen.
1259         /// Applies to ALL shapes.
1260         /// </summary>
1261         public Vector3 LightPosition
1262         {
1263             get
1264             {
1265                 return _lightPosition;
1266             }
1267             set
1268             {
1269                 _lightPosition = value;
1270             }
1271         }
1272
1273         protected override void ComposingPropertyMap()
1274         {
1275             _outputVisualMap = new PropertyMap(); ;
1276             _outputVisualMap.Add(Tizen.NUI.Constants.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Constants.Visual.Type.Primitive));
1277             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape));
1278             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColor));
1279             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.Slices, new PropertyValue(_slices));
1280             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.Stacks, new PropertyValue(_stacks));
1281             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue(_scaleTopRadius));
1282             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue(_scaleBottomRadius));
1283             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.ScaleHeight, new PropertyValue(_scaleHeight));
1284             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.ScaleRadius, new PropertyValue(_scaleRadius));
1285             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions));
1286             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.BevelPercentage, new PropertyValue(_bevelPercentage));
1287             _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.BevelSmoothness, new PropertyValue(_bevelSmoothness));
1288
1289             if (_lightPosition != null)
1290             {
1291                 _outputVisualMap.Add(Tizen.NUI.Constants.PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition));
1292             }
1293         }
1294     }
1295
1296
1297     public enum WrapModeType
1298     {
1299         Default = 0,
1300         ClampToEdge,
1301         Repeat,
1302         MirroredRepeat
1303     }
1304
1305     public enum GradientVisualUnitsType
1306     {
1307         ObjectBoundingBox,
1308         UserSpace
1309     }
1310
1311     public enum GradientVisualSpreadMethodType
1312     {
1313         Pad,
1314         Reflect,
1315         Repeat
1316     }
1317
1318     public enum MeshVisualShadingModeValue
1319     {
1320         TexturelessWithDiffuseLighting,
1321         TexturedWithSpecularLighting,
1322         TexturedWithDetailedSpecularLighting
1323     }
1324
1325     public enum PrimitiveVisualShapeType
1326     {
1327         Sphere,
1328         ConicalFrustrum,
1329         Cone,
1330         Cylinder,
1331         Cube,
1332         Octahedron,
1333         BevelledCube
1334     }
1335
1336     public enum FittingModeType
1337     {
1338         ShrinkToFit,
1339         ScaleToFill,
1340         FitWidth,
1341         FitHeight
1342     }
1343
1344     public enum SamplingModeType
1345     {
1346         Box,
1347         Nearest,
1348         Linear,
1349         BoxThenNearest,
1350         BoxThenLinear,
1351         NoFilter,
1352         DontCare
1353     }
1354
1355 }