bfdde5eacbe161985fd7abaf26f299282a97373d
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / RelativeVector4.cs
1 /*
2  * Copyright (c) 2019 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 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// RelativeVector4 is a four-dimensional vector.
25     /// All values (x, y, and z) should be between [0, 1].
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     [Binding.TypeConverter(typeof(RelativeVector4TypeConverter))]
29     public class RelativeVector4 : Disposable
30     {
31
32         /// <summary>
33         /// The constructor.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public RelativeVector4() : this(Interop.Vector4.NewVector4(), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// The constructor.
43         /// </summary>
44         /// <param name="x">The x component.</param>
45         /// <param name="y">The y component.</param>
46         /// <param name="z">The z component.</param>
47         /// <param name="w">The w component.</param>
48         /// <since_tizen> 3 </since_tizen>
49         public RelativeVector4(float x, float y, float z, float w) : this(Interop.Vector4.NewVector4(x, y, z, w), true)
50         {
51             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52         }
53
54         /// <summary>
55         /// The constructor.
56         /// </summary>
57         /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
58         /// <since_tizen> 3 </since_tizen>
59         public RelativeVector4(RelativeVector2 relativeVector2) : this(Interop.Vector4.NewVector4WithVector2(RelativeVector2.getCPtr(relativeVector2)), true)
60         {
61             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
62         }
63
64         /// <summary>
65         /// The constructor.
66         /// </summary>
67         /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
68         /// <since_tizen> 3 </since_tizen>
69         public RelativeVector4(RelativeVector3 relativeVector3) : this(Interop.Vector4.NewVector4WithVector3(RelativeVector3.getCPtr(relativeVector3)), true)
70         {
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72         }
73
74         internal RelativeVector4(RelativeVector4ChangedCallback cb, float x, float y, float z, float w) : this(Interop.Vector4.NewVector4(x, y, z, w), true)
75         {
76             callback = cb;
77             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78         }
79         internal delegate void RelativeVector4ChangedCallback(float x, float y, float z, float w);
80         private RelativeVector4ChangedCallback callback = null;
81
82         /// <summary>
83         /// The x component.
84         /// </summary>
85         /// <remarks>
86         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
87         /// </remarks>
88         /// <code>
89         /// // DO NOT use like the followings!
90         /// RelativeVector4 relativeVector4 = new RelativeVector4();
91         /// relativeVector4.X = 0.1f; 
92         /// // Please USE like this
93         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
94         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
95         /// </code>
96         /// <since_tizen> 3 </since_tizen>
97         public float X
98         {
99             set
100             {
101                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
102
103                 Interop.Vector4.XSet(SwigCPtr, value);
104                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105
106                 callback?.Invoke(X, Y, Z, W);
107             }
108             get
109             {
110                 float ret = Interop.Vector4.XGet(SwigCPtr);
111                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
112                 return ret;
113             }
114         }
115
116         /// <summary>
117         /// The y component.
118         /// </summary>
119         /// <remarks>
120         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
121         /// </remarks>
122         /// <code>
123         /// // DO NOT use like the followings!
124         /// RelativeVector4 relativeVector4 = new RelativeVector4();
125         /// relativeVector4.Y = 0.5f; 
126         /// // Please USE like this
127         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
128         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
129         /// </code>
130         /// <since_tizen> 3 </since_tizen>
131         public float Y
132         {
133             set
134             {
135                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
136
137                 Interop.Vector4.YSet(SwigCPtr, value);
138                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139
140                 callback?.Invoke(X, Y, Z, W);
141             }
142             get
143             {
144                 float ret = Interop.Vector4.YGet(SwigCPtr);
145                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
146                 return ret;
147             }
148         }
149
150         /// <summary>
151         /// The z component.
152         /// </summary>
153         /// <remarks>
154         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
155         /// </remarks>
156         /// <code>
157         /// // DO NOT use like the followings!
158         /// RelativeVector4 relativeVector4 = new RelativeVector4();
159         /// relativeVector4.Z = 0.9f; 
160         /// // Please USE like this
161         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
162         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
163         /// </code>
164         /// <since_tizen> 3 </since_tizen>
165         public float Z
166         {
167             set
168             {
169                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
170
171                 Interop.Vector4.ZSet(SwigCPtr, value);
172                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173
174                 callback?.Invoke(X, Y, Z, W);
175             }
176             get
177             {
178                 float ret = Interop.Vector4.ZGet(SwigCPtr);
179                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
180                 return ret;
181             }
182         }
183
184         /// <summary>
185         /// The w component.
186         /// </summary>
187         /// <remarks>
188         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
189         /// </remarks>
190         /// <code>
191         /// // DO NOT use like the followings!
192         /// RelativeVector4 relativeVector4 = new RelativeVector4();
193         /// relativeVector4.W = 1.0f; 
194         /// // Please USE like this
195         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
196         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
197         /// </code>
198         /// <since_tizen> 3 </since_tizen>
199         public float W
200         {
201             set
202             {
203                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
204
205                 Interop.Vector4.WSet(SwigCPtr, value);
206                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207
208                 callback?.Invoke(X, Y, Z, W);
209             }
210             get
211             {
212                 float ret = Interop.Vector4.WGet(SwigCPtr);
213                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
214                 return ret;
215             }
216         }
217
218         /// <summary>
219         /// The addition operator.
220         /// </summary>
221         /// <param name="arg1">The vector to add.</param>
222         /// <param name="arg2">The vector to add.</param>
223         /// <returns>The vector containing the result of the addition.</returns>
224         /// <since_tizen> 3 </since_tizen>
225         public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
226         {
227             RelativeVector4 result = arg1?.Add(arg2);
228             return result;
229         }
230
231         /// <summary>
232         /// The subtraction operator.
233         /// </summary>
234         /// <param name="arg1">The vector to subtract.</param>
235         /// <param name="arg2">The vector to subtract.</param>
236         /// <returns>The vector containing the result of the subtraction.</returns>
237         /// <since_tizen> 3 </since_tizen>
238         public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
239         {
240             RelativeVector4 result = arg1?.Subtract(arg2);
241             return result;
242         }
243
244         /// <summary>
245         /// The multiplication operator.
246         /// </summary>
247         /// <param name="arg1">The vector to multiply.</param>
248         /// <param name="arg2">The vector to multiply.</param>
249         /// <returns>The vector containing the result of the multiplication.</returns>
250         /// <since_tizen> 3 </since_tizen>
251         public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
252         {
253             RelativeVector4 result = arg1?.Multiply(arg2);
254             return result;
255         }
256
257         /// <summary>
258         /// The multiplication operator.
259         /// </summary>
260         /// <param name="arg1">The vector to multiply.</param>
261         /// <param name="arg2">The float value to scale the vector.</param>
262         /// <returns>The vector containing the result of the scaling.</returns>
263         /// <since_tizen> 3 </since_tizen>
264         public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
265         {
266             RelativeVector4 result = arg1?.Multiply(arg2);
267             return result;
268         }
269
270         /// <summary>
271         /// The division operator.
272         /// </summary>
273         /// <param name="arg1">The vector to divide.</param>
274         /// <param name="arg2">The vector to divide.</param>
275         /// <returns>The vector containing the result of the division.</returns>
276         /// <since_tizen> 3 </since_tizen>
277         public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
278         {
279             RelativeVector4 result = arg1?.Divide(arg2);
280             return result;
281         }
282
283         /// <summary>
284         /// The division operator.
285         /// </summary>
286         /// <param name="arg1">The vector to divide.</param>
287         /// <param name="arg2">The float value to scale the vector by.</param>
288         /// <returns>The vector containing the result of the scaling.</returns>
289         /// <since_tizen> 3 </since_tizen>
290         public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
291         {
292             RelativeVector4 result = arg1?.Divide(arg2);
293             return result;
294         }
295
296         /// <summary>
297         /// </summary>
298         /// <since_tizen> 3 </since_tizen>
299         public static implicit operator Vector4(RelativeVector4 relativeVector4)
300         {
301             return new Vector4((float)relativeVector4?.X, (float)relativeVector4.Y, (float)relativeVector4.Z, (float)relativeVector4.W);
302         }
303
304         /// <summary>
305         /// </summary>
306         /// <since_tizen> 3 </since_tizen>
307         public static implicit operator RelativeVector4(Vector4 vec)
308         {
309             return new RelativeVector4((float)vec?.X, (float)vec.Y, (float)vec.Z, (float)vec.W);
310         }
311
312         /// <summary>
313         /// The const array subscript operator overload. Should be 0, 1 3 or 3.
314         /// </summary>
315         /// <param name="index">The subscript index.</param>
316         /// <returns>The float at the given index.</returns>
317         /// <since_tizen> 3 </since_tizen>
318         public float this[uint index]
319         {
320             get
321             {
322                 return ValueOfIndex(index);
323             }
324         }
325
326         /// <summary>
327         /// Determines whether the specified object is equal to the current object.
328         /// </summary>
329         /// <param name="obj">The object to compare with the current object.</param>
330         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
331         public override bool Equals(System.Object obj)
332         {
333             RelativeVector4 relativeVector4 = obj as RelativeVector4;
334             bool equal = false;
335             if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
336             {
337                 equal = true;
338             }
339             return equal;
340         }
341
342         /// <summary>
343         /// Gets the the hash code of this RelativeVector4.
344         /// </summary>
345         /// <returns>The Hash Code.</returns>
346         /// <since_tizen> 6 </since_tizen>
347         public override int GetHashCode()
348         {
349             return SwigCPtr.Handle.GetHashCode();
350         }
351
352         /// <summary>
353         /// Compares if the rhs is equal to.
354         /// </summary>
355         /// <param name="rhs">The vector to compare.</param>
356         /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
357         /// <since_tizen> 3 </since_tizen>
358         public bool EqualTo(RelativeVector4 rhs)
359         {
360             bool ret = Interop.Vector4.EqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
361             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362             return ret;
363         }
364
365         /// <summary>
366         /// Compares if the rhs is not equal to.
367         /// </summary>
368         /// <param name="rhs">The vector to compare.</param>
369         /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
370         /// <since_tizen> 3 </since_tizen>
371         public bool NotEqualTo(RelativeVector4 rhs)
372         {
373             bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
374             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375             return ret;
376         }
377
378         /// <summary>
379         /// </summary>
380         internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
381         {
382             RelativeVector4 ret = new RelativeVector4(cPtr, false);
383             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384             return ret;
385         }
386
387         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
388         {
389             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
390         }
391
392         internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
393         {
394         }
395
396         /// This will not be public opened.
397         [EditorBrowsable(EditorBrowsableState.Never)]
398         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
399         {
400             Interop.Vector4.DeleteVector4(swigCPtr);
401         }
402
403         private RelativeVector4 Add(RelativeVector4 rhs)
404         {
405             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Add(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
406             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407             return ret;
408         }
409
410         private RelativeVector4 Subtract(RelativeVector4 rhs)
411         {
412             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Subtract(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
413             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414             return ret;
415         }
416
417         private RelativeVector4 Multiply(RelativeVector4 rhs)
418         {
419             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
420             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421             return ret;
422         }
423
424         private RelativeVector4 Multiply(float rhs)
425         {
426             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
427             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428             return ret;
429         }
430
431         private RelativeVector4 Divide(RelativeVector4 rhs)
432         {
433             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
434             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
435             return ret;
436         }
437
438         private RelativeVector4 Divide(float rhs)
439         {
440             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, rhs), true);
441             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442             return ret;
443         }
444
445         private float ValueOfIndex(uint index)
446         {
447             float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
448             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449             return ret;
450         }
451     }
452 }
453
454