[NUI] Fix NUI Svace issue (#2806)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / RelativeVector4.cs
1 /*
2  * Copyright (c) 2021 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             if (relativeVector4 == null)
302             {
303                 return null;
304             }
305             return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
306         }
307
308         /// <summary>
309         /// </summary>
310         /// <since_tizen> 3 </since_tizen>
311         public static implicit operator RelativeVector4(Vector4 vec)
312         {
313             if (vec == null)
314             {
315                 return null;
316             }
317             return new RelativeVector4(vec.X, vec.Y, vec.Z, vec.W);
318         }
319
320         /// <summary>
321         /// The const array subscript operator overload. Should be 0, 1 3 or 3.
322         /// </summary>
323         /// <param name="index">The subscript index.</param>
324         /// <returns>The float at the given index.</returns>
325         /// <since_tizen> 3 </since_tizen>
326         public float this[uint index]
327         {
328             get
329             {
330                 return ValueOfIndex(index);
331             }
332         }
333
334         /// <summary>
335         /// Determines whether the specified object is equal to the current object.
336         /// </summary>
337         /// <param name="obj">The object to compare with the current object.</param>
338         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
339         public override bool Equals(System.Object obj)
340         {
341             RelativeVector4 relativeVector4 = obj as RelativeVector4;
342             bool equal = false;
343             if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
344             {
345                 equal = true;
346             }
347             return equal;
348         }
349
350         /// <summary>
351         /// Gets the hash code of this RelativeVector4.
352         /// </summary>
353         /// <returns>The Hash Code.</returns>
354         /// <since_tizen> 6 </since_tizen>
355         public override int GetHashCode()
356         {
357             return SwigCPtr.Handle.GetHashCode();
358         }
359
360         /// <summary>
361         /// Compares if the rhs is equal to.
362         /// </summary>
363         /// <param name="rhs">The vector to compare.</param>
364         /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
365         /// <since_tizen> 3 </since_tizen>
366         public bool EqualTo(RelativeVector4 rhs)
367         {
368             bool ret = Interop.Vector4.EqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
369             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370             return ret;
371         }
372
373         /// <summary>
374         /// Compares if the rhs is not equal to.
375         /// </summary>
376         /// <param name="rhs">The vector to compare.</param>
377         /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
378         /// <since_tizen> 3 </since_tizen>
379         public bool NotEqualTo(RelativeVector4 rhs)
380         {
381             bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
382             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
383             return ret;
384         }
385
386         /// <summary>
387         /// </summary>
388         internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
389         {
390             RelativeVector4 ret = new RelativeVector4(cPtr, false);
391             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392             return ret;
393         }
394
395         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
396         {
397             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
398         }
399
400         internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
401         {
402         }
403
404         /// This will not be public opened.
405         [EditorBrowsable(EditorBrowsableState.Never)]
406         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
407         {
408             Interop.Vector4.DeleteVector4(swigCPtr);
409         }
410
411         private RelativeVector4 Add(RelativeVector4 rhs)
412         {
413             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Add(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
414             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415             return ret;
416         }
417
418         private RelativeVector4 Subtract(RelativeVector4 rhs)
419         {
420             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Subtract(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
421             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422             return ret;
423         }
424
425         private RelativeVector4 Multiply(RelativeVector4 rhs)
426         {
427             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
428             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429             return ret;
430         }
431
432         private RelativeVector4 Multiply(float rhs)
433         {
434             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
435             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436             return ret;
437         }
438
439         private RelativeVector4 Divide(RelativeVector4 rhs)
440         {
441             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
442             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443             return ret;
444         }
445
446         private RelativeVector4 Divide(float rhs)
447         {
448             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, rhs), true);
449             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450             return ret;
451         }
452
453         private float ValueOfIndex(uint index)
454         {
455             float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
456             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457             return ret;
458         }
459     }
460 }