2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
24 /// RelativeVector4 is a four-dimensional vector.
25 /// All values (x, y, and z) should be between [0, 1].
27 /// <since_tizen> 3 </since_tizen>
28 [Binding.TypeConverter(typeof(RelativeVector4TypeConverter))]
29 public class RelativeVector4 : Disposable
35 /// <since_tizen> 3 </since_tizen>
36 public RelativeVector4() : this(Interop.Vector4.NewVector4(), true)
38 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
61 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74 internal RelativeVector4(RelativeVector4ChangedCallback cb, float x, float y, float z, float w) : this(Interop.Vector4.NewVector4(x, y, z, w), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79 internal delegate void RelativeVector4ChangedCallback(float x, float y, float z, float w);
80 private RelativeVector4ChangedCallback callback = null;
86 /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
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);
96 /// <since_tizen> 3 </since_tizen>
101 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
103 Interop.Vector4.XSet(SwigCPtr, value);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 callback?.Invoke(X, Y, Z, W);
110 float ret = Interop.Vector4.XGet(SwigCPtr);
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
120 /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
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);
130 /// <since_tizen> 3 </since_tizen>
135 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
137 Interop.Vector4.YSet(SwigCPtr, value);
138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 callback?.Invoke(X, Y, Z, W);
144 float ret = Interop.Vector4.YGet(SwigCPtr);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
154 /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
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);
164 /// <since_tizen> 3 </since_tizen>
169 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
171 Interop.Vector4.ZSet(SwigCPtr, value);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 callback?.Invoke(X, Y, Z, W);
178 float ret = Interop.Vector4.ZGet(SwigCPtr);
179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
188 /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector4(...) constructor.
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);
198 /// <since_tizen> 3 </since_tizen>
203 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector4(...) constructor");
205 Interop.Vector4.WSet(SwigCPtr, value);
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 callback?.Invoke(X, Y, Z, W);
212 float ret = Interop.Vector4.WGet(SwigCPtr);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
219 /// The addition operator.
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)
227 RelativeVector4 result = arg1?.Add(arg2);
232 /// The subtraction operator.
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)
240 RelativeVector4 result = arg1?.Subtract(arg2);
245 /// The multiplication operator.
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)
253 RelativeVector4 result = arg1?.Multiply(arg2);
258 /// The multiplication operator.
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)
266 RelativeVector4 result = arg1?.Multiply(arg2);
271 /// The division operator.
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)
279 RelativeVector4 result = arg1?.Divide(arg2);
284 /// The division operator.
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)
292 RelativeVector4 result = arg1?.Divide(arg2);
298 /// <since_tizen> 3 </since_tizen>
299 public static implicit operator Vector4(RelativeVector4 relativeVector4)
301 if (relativeVector4 == null)
305 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
310 /// <since_tizen> 3 </since_tizen>
311 public static implicit operator RelativeVector4(Vector4 vec)
317 return new RelativeVector4(vec.X, vec.Y, vec.Z, vec.W);
321 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
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]
330 return ValueOfIndex(index);
335 /// Determines whether the specified object is equal to the current object.
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)
341 RelativeVector4 relativeVector4 = obj as RelativeVector4;
343 if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
351 /// Gets the hash code of this RelativeVector4.
353 /// <returns>The Hash Code.</returns>
354 /// <since_tizen> 6 </since_tizen>
355 public override int GetHashCode()
357 return SwigCPtr.Handle.GetHashCode();
361 /// Compares if the rhs is equal to.
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)
368 bool ret = Interop.Vector4.EqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 /// Compares if the rhs is not equal to.
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)
381 bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
390 RelativeVector4 ret = new RelativeVector4(cPtr, false);
391 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
397 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
400 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
404 /// This will not be public opened.
405 [EditorBrowsable(EditorBrowsableState.Never)]
406 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
408 Interop.Vector4.DeleteVector4(swigCPtr);
411 private RelativeVector4 Add(RelativeVector4 rhs)
413 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Add(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 private RelativeVector4 Subtract(RelativeVector4 rhs)
420 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Subtract(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 private RelativeVector4 Multiply(RelativeVector4 rhs)
427 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 private RelativeVector4 Multiply(float rhs)
434 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 private RelativeVector4 Divide(RelativeVector4 rhs)
441 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 private RelativeVector4 Divide(float rhs)
448 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, rhs), true);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 private float ValueOfIndex(uint index)
455 float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();