Add ScriptUI to support XAML file (#320)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Path.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     /// <summary>
25     /// A 3D parametric curve.<br />
26     /// Paths can be used to animate the position and orientation of actors.<br />
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public class Path : BaseHandle
30     {
31         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32
33         internal Path(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Path_SWIGUpcast(cPtr), cMemoryOwn)
34         {
35             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36         }
37
38         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Path obj)
39         {
40             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41         }
42
43         /// <summary>
44         /// Dispose
45         /// </summary>
46         /// <param name="type">The dispoase type</param>
47         /// <since_tizen> 3 </since_tizen>
48         protected override void Dispose(DisposeTypes type)
49         {
50             if(disposed)
51             {
52                 return;
53             }
54
55             if(type == DisposeTypes.Explicit)
56             {
57                 //Called by User
58                 //Release your own managed resources here.
59                 //You should release all of your own disposable objects here.
60             }
61
62             //Release your own unmanaged resources here.
63             //You should not access any managed member here except static instance.
64             //because the execution order of Finalizes is non-deterministic.
65
66             if (swigCPtr.Handle != global::System.IntPtr.Zero)
67             {
68                 if (swigCMemOwn)
69                 {
70                     swigCMemOwn = false;
71                     NDalicPINVOKE.delete_Path(swigCPtr);
72                 }
73                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74             }
75
76             base.Dispose(type);
77         }
78
79
80         internal class Property
81         {
82             internal static readonly int POINTS = NDalicPINVOKE.Path_Property_POINTS_get();
83             internal static readonly int CONTROL_POINTS = NDalicPINVOKE.Path_Property_CONTROL_POINTS_get();
84         }
85
86         /// <summary>
87         /// Creates an initialized path handle.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public Path() : this(NDalicPINVOKE.Path_New(), true)
91         {
92             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93
94         }
95
96         /// <summary>
97         /// Adds an interpolation point.
98         /// </summary>
99         /// <param name="point">The new interpolation point to be added.</param>
100         /// <since_tizen> 3 </since_tizen>
101         public void AddPoint(Position point)
102         {
103             NDalicPINVOKE.Path_AddPoint(swigCPtr, Position.getCPtr(point));
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105         }
106
107         /// <summary>
108         /// Adds a control point.
109         /// </summary>
110         /// <param name="point">The new control point to be added.</param>
111         /// <since_tizen> 3 </since_tizen>
112         public void AddControlPoint(Vector3 point)
113         {
114             NDalicPINVOKE.Path_AddControlPoint(swigCPtr, Vector3.getCPtr(point));
115             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116         }
117
118         /// <summary>
119         /// Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment.<br />
120         /// The generating algorithm is as follows:<br />
121         /// For a given knot point K[N], find the vector that bisects K[N-1],[N] and [N],[N+1].<br />
122         /// Calculate the tangent vector by taking the normal of this bisector.<br />
123         /// The in control point is the length of the preceding segment back along this bisector multiplied by the curvature.<br />
124         /// The out control point is the length of the succeeding segment forward along this bisector multiplied by the curvature.<br />
125         /// </summary>
126         /// <param name="curvature">The curvature of the spline. 0 gives straight lines between the knots, negative values means the spline contains loops, positive values up to 0.5 result in a smooth curve, positive values between 0.5 and 1 result in looped curves where the loops are not distinct (i.e., the curve appears to be non-continuous), positive values higher than 1 result in looped curves.</param>
127         /// <since_tizen> 3 </since_tizen>
128         public void GenerateControlPoints(float curvature)
129         {
130             NDalicPINVOKE.Path_GenerateControlPoints(swigCPtr, curvature);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132         }
133
134         /// <summary>
135         /// Sample path at a given progress. Calculates the position and tangent at that point of the curve.
136         /// </summary>
137         /// <param name="progress">A floating point value between 0.0 and 1.0.</param>
138         /// <param name="position">The interpolated position at that progress.</param>
139         /// <param name="tangent">The interpolated tangent at that progress.</param>
140         /// <since_tizen> 3 </since_tizen>
141         public void Sample(float progress, Vector3 position, Vector3 tangent)
142         {
143             NDalicPINVOKE.Path_Sample(swigCPtr, progress, Vector3.getCPtr(position), Vector3.getCPtr(tangent));
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145         }
146
147         /// <summary>
148         /// An accessor for the interpolation points.
149         /// </summary>
150         /// <param name="index">The index of the interpolation point.</param>
151         /// <since_tizen> 3 </since_tizen>
152         public Vector3 GetPoint(uint index)
153         {
154             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetPoint(swigCPtr, index), false);
155             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156             return ret;
157         }
158
159         /// <summary>
160         /// An accessor for the control points.
161         /// </summary>
162         /// <param name="index">The index of the control point.</param>
163         /// <since_tizen> 3 </since_tizen>
164         public Vector3 GetControlPoint(uint index)
165         {
166             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetControlPoint(swigCPtr, index), false);
167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168             return ret;
169         }
170
171         /// <summary>
172         /// Gets the number of interpolation points in the path.
173         /// </summary>
174         /// <returns>The number of interpolation points in the path.</returns>
175         /// <since_tizen> 3 </since_tizen>
176         public uint GetPointCount()
177         {
178             uint ret = NDalicPINVOKE.Path_GetPointCount(swigCPtr);
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180             return ret;
181         }
182
183         /// <summary>
184         /// Enumeration for the Points.
185         /// </summary>
186         /// <since_tizen> 3 </since_tizen>
187         public PropertyArray Points
188         {
189             get
190             {
191                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
192                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.POINTS).Get(temp);
193                 return temp;
194             }
195             set
196             {
197                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.POINTS, new Tizen.NUI.PropertyValue(value));
198             }
199         }
200
201         /// <summary>
202         /// Enumeration for the ControlPoints.
203         /// </summary>
204         /// <since_tizen> 3 </since_tizen>
205         public PropertyArray ControlPoints
206         {
207             get
208             {
209                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
210                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.CONTROL_POINTS).Get(temp);
211                 return temp;
212             }
213             set
214             {
215                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.CONTROL_POINTS, new Tizen.NUI.PropertyValue(value));
216             }
217         }
218
219     }
220
221 }