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