[NUI] Fix comments according to document review
[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. 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         /// // 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             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
100             set
101             {
102                 Interop.Vector4.XSet(SwigCPtr, value);
103                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104
105                 callback?.Invoke(X, Y, Z, W);
106             }
107             get
108             {
109                 float ret = Interop.Vector4.XGet(SwigCPtr);
110                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
111                 return ret;
112             }
113         }
114
115         /// <summary>
116         /// The y component.
117         /// </summary>
118         /// <remarks>
119         /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
120         /// </remarks>
121         /// <code>
122         /// // DO NOT use like the followings!
123         /// RelativeVector4 relativeVector4 = new RelativeVector4();
124         /// relativeVector4.Y = 0.5f; 
125         /// // USE like this
126         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
127         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
128         /// </code>
129         /// <since_tizen> 3 </since_tizen>
130         public float Y
131         {
132             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
133             set
134             {
135                 Interop.Vector4.YSet(SwigCPtr, value);
136                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137
138                 callback?.Invoke(X, Y, Z, W);
139             }
140             get
141             {
142                 float ret = Interop.Vector4.YGet(SwigCPtr);
143                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
144                 return ret;
145             }
146         }
147
148         /// <summary>
149         /// The z component.
150         /// </summary>
151         /// <remarks>
152         /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
153         /// </remarks>
154         /// <code>
155         /// // DO NOT use like the followings!
156         /// RelativeVector4 relativeVector4 = new RelativeVector4();
157         /// relativeVector4.Z = 0.9f; 
158         /// // USE like this
159         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
160         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
161         /// </code>
162         /// <since_tizen> 3 </since_tizen>
163         public float Z
164         {
165             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
166             set
167             {
168                 Interop.Vector4.ZSet(SwigCPtr, value);
169                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170
171                 callback?.Invoke(X, Y, Z, W);
172             }
173             get
174             {
175                 float ret = Interop.Vector4.ZGet(SwigCPtr);
176                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
177                 return ret;
178             }
179         }
180
181         /// <summary>
182         /// The w component.
183         /// </summary>
184         /// <remarks>
185         /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
186         /// </remarks>
187         /// <code>
188         /// // DO NOT use like the followings!
189         /// RelativeVector4 relativeVector4 = new RelativeVector4();
190         /// relativeVector4.W = 1.0f; 
191         /// // USE like this
192         /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
193         /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
194         /// </code>
195         /// <since_tizen> 3 </since_tizen>
196         public float W
197         {
198             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
199             set
200             {
201                 Interop.Vector4.WSet(SwigCPtr, value);
202                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203
204                 callback?.Invoke(X, Y, Z, W);
205             }
206             get
207             {
208                 float ret = Interop.Vector4.WGet(SwigCPtr);
209                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
210                 return ret;
211             }
212         }
213
214         /// <summary>
215         /// The addition operator.
216         /// </summary>
217         /// <param name="arg1">The vector to add.</param>
218         /// <param name="arg2">The vector to add.</param>
219         /// <returns>The vector containing the result of the addition.</returns>
220         /// <since_tizen> 3 </since_tizen>
221         public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
222         {
223             RelativeVector4 result = arg1?.Add(arg2);
224             return result;
225         }
226
227         /// <summary>
228         /// The subtraction operator.
229         /// </summary>
230         /// <param name="arg1">The vector to subtract.</param>
231         /// <param name="arg2">The vector to subtract.</param>
232         /// <returns>The vector containing the result of the subtraction.</returns>
233         /// <since_tizen> 3 </since_tizen>
234         public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
235         {
236             RelativeVector4 result = arg1?.Subtract(arg2);
237             return result;
238         }
239
240         /// <summary>
241         /// The multiplication operator.
242         /// </summary>
243         /// <param name="arg1">The vector to multiply.</param>
244         /// <param name="arg2">The vector to multiply.</param>
245         /// <returns>The vector containing the result of the multiplication.</returns>
246         /// <since_tizen> 3 </since_tizen>
247         public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
248         {
249             RelativeVector4 result = arg1?.Multiply(arg2);
250             return result;
251         }
252
253         /// <summary>
254         /// The multiplication operator.
255         /// </summary>
256         /// <param name="arg1">The vector to multiply.</param>
257         /// <param name="arg2">The float value to scale the vector.</param>
258         /// <returns>The vector containing the result of the scaling.</returns>
259         /// <since_tizen> 3 </since_tizen>
260         public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
261         {
262             RelativeVector4 result = arg1?.Multiply(arg2);
263             return result;
264         }
265
266         /// <summary>
267         /// The division operator.
268         /// </summary>
269         /// <param name="arg1">The vector to divide.</param>
270         /// <param name="arg2">The vector to divide.</param>
271         /// <returns>The vector containing the result of the division.</returns>
272         /// <since_tizen> 3 </since_tizen>
273         public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
274         {
275             RelativeVector4 result = arg1?.Divide(arg2);
276             return result;
277         }
278
279         /// <summary>
280         /// The division operator.
281         /// </summary>
282         /// <param name="arg1">The vector to divide.</param>
283         /// <param name="arg2">The float value to scale the vector by.</param>
284         /// <returns>The vector containing the result of the scaling.</returns>
285         /// <since_tizen> 3 </since_tizen>
286         public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
287         {
288             RelativeVector4 result = arg1?.Divide(arg2);
289             return result;
290         }
291
292         /// <summary>
293         /// </summary>
294         /// <since_tizen> 3 </since_tizen>
295         public static implicit operator Vector4(RelativeVector4 relativeVector4)
296         {
297             if (relativeVector4 == null)
298             {
299                 return null;
300             }
301             return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
302         }
303
304         /// <summary>
305         /// </summary>
306         /// <since_tizen> 3 </since_tizen>
307         public static implicit operator RelativeVector4(Vector4 vec)
308         {
309             if (vec == null)
310             {
311                 return null;
312             }
313             return new RelativeVector4(vec.X, vec.Y, vec.Z, vec.W);
314         }
315
316         /// <summary>
317         /// The const array subscript operator overload. Should be 0, 1 3 or 3.
318         /// </summary>
319         /// <param name="index">The subscript index.</param>
320         /// <returns>The float at the given index.</returns>
321         /// <since_tizen> 3 </since_tizen>
322         public float this[uint index]
323         {
324             get
325             {
326                 return ValueOfIndex(index);
327             }
328         }
329
330         /// <summary>
331         /// Determines whether the specified object is equal to the current object.
332         /// </summary>
333         /// <param name="obj">The object to compare with the current object.</param>
334         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
335         public override bool Equals(System.Object obj)
336         {
337             RelativeVector4 relativeVector4 = obj as RelativeVector4;
338             bool equal = false;
339             if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
340             {
341                 equal = true;
342             }
343             return equal;
344         }
345
346         /// <summary>
347         /// Gets the hash code of this RelativeVector4.
348         /// </summary>
349         /// <returns>The Hash Code.</returns>
350         /// <since_tizen> 6 </since_tizen>
351         public override int GetHashCode()
352         {
353             return SwigCPtr.Handle.GetHashCode();
354         }
355
356         /// <summary>
357         /// Compares if the rhs is equal to.
358         /// </summary>
359         /// <param name="rhs">The vector to compare.</param>
360         /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
361         /// <since_tizen> 3 </since_tizen>
362         public bool EqualTo(RelativeVector4 rhs)
363         {
364             bool ret = Interop.Vector4.EqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
365             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366             return ret;
367         }
368
369         /// <summary>
370         /// Compares if the rhs is not equal to.
371         /// </summary>
372         /// <param name="rhs">The vector to compare.</param>
373         /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
374         /// <since_tizen> 3 </since_tizen>
375         public bool NotEqualTo(RelativeVector4 rhs)
376         {
377             bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
378             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379             return ret;
380         }
381
382         /// <summary>
383         /// </summary>
384         internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
385         {
386             RelativeVector4 ret = new RelativeVector4(cPtr, false);
387             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388             return ret;
389         }
390
391         internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
392         {
393         }
394
395         /// This will not be public opened.
396         [EditorBrowsable(EditorBrowsableState.Never)]
397         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
398         {
399             Interop.Vector4.DeleteVector4(swigCPtr);
400         }
401
402         private RelativeVector4 Add(RelativeVector4 rhs)
403         {
404             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Add(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
405             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406             return ret;
407         }
408
409         private RelativeVector4 Subtract(RelativeVector4 rhs)
410         {
411             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Subtract(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
412             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413             return ret;
414         }
415
416         private RelativeVector4 Multiply(RelativeVector4 rhs)
417         {
418             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
419             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420             return ret;
421         }
422
423         private RelativeVector4 Multiply(float rhs)
424         {
425             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427             return ret;
428         }
429
430         private RelativeVector4 Divide(RelativeVector4 rhs)
431         {
432             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
433             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434             return ret;
435         }
436
437         private RelativeVector4 Divide(float rhs)
438         {
439             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, rhs), true);
440             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441             return ret;
442         }
443
444         private float ValueOfIndex(uint index)
445         {
446             float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
447             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448             return ret;
449         }
450     }
451 }