2 * Copyright (c) 2017 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.
23 /// RelativeVector2 is a two dimensional vector.
24 /// Both values(x and y) should be between [0, 1].
26 public class RelativeVector2 : global::System.IDisposable
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 protected bool swigCMemOwn;
31 internal RelativeVector2(global::System.IntPtr cPtr, bool cMemoryOwn)
33 swigCMemOwn = cMemoryOwn;
34 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector2 obj)
39 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
44 DisposeQueue.Instance.Add(this);
47 public virtual void Dispose()
49 if (!Stage.IsInstalled())
51 DisposeQueue.Instance.Add(this);
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_Vector2(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
66 global::System.GC.SuppressFinalize(this);
72 /// Addition operator.
74 /// <param name="arg1">Vector to add</param>
75 /// <param name="arg2">Vector to add</param>
76 /// <returns>A vector containing the result of the addition</returns>
77 public static RelativeVector2 operator +(RelativeVector2 arg1, RelativeVector2 arg2)
79 RelativeVector2 result = arg1.Add(arg2);
85 /// Subtraction operator.
87 /// <param name="arg1">Vector to subtract</param>
88 /// <param name="arg2">Vector to subtract</param>
89 /// <returns>A vector containing the result of the subtraction</returns>
90 public static RelativeVector2 operator -(RelativeVector2 arg1, RelativeVector2 arg2)
92 RelativeVector2 result = arg1.Subtract(arg2);
98 /// Multiplication operator.
100 /// <param name="arg1">The vector to multiply</param>
101 /// <param name="arg2">The vector to multiply</param>
102 /// <returns>A vector containing the result of the multiplication</returns>
103 public static RelativeVector2 operator *(RelativeVector2 arg1, RelativeVector2 arg2)
105 RelativeVector2 result = arg1.Multiply(arg2);
111 /// Multiplication operator.
113 /// <param name="arg1">The vector to multiply</param>
114 /// <param name="arg2">The float value to scale the vector</param>
115 /// <returns>A vector containing the result of the scaling</returns>
116 public static RelativeVector2 operator *(RelativeVector2 arg1, float arg2)
118 RelativeVector2 result = arg1.Multiply(arg2);
124 /// Division operator.
126 /// <param name="arg1">The vector to divide</param>
127 /// <param name="arg2">The vector to divide</param>
128 /// <returns>A vector containing the result of the division</returns>
129 public static RelativeVector2 operator /(RelativeVector2 arg1, RelativeVector2 arg2)
131 RelativeVector2 result = arg1.Divide(arg2);
137 /// Division operator.
139 /// <param name="arg1">The vector to divide</param>
140 /// <param name="arg2">The float value to scale the vector by</param>
141 /// <returns>A vector containing the result of the scaling</returns>
142 public static RelativeVector2 operator /(RelativeVector2 arg1, float arg2)
144 RelativeVector2 result = arg1.Divide(arg2);
151 /// Const array subscript operator overload. Should be 0, 1.
153 /// <param name="index">Subscript index</param>
154 /// <returns>The float at the given index</returns>
155 public float this[uint index]
159 return ValueOfIndex(index);
165 internal static RelativeVector2 GetRelativeVector2FromPtr(global::System.IntPtr cPtr)
167 RelativeVector2 ret = new RelativeVector2(cPtr, false);
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 public RelativeVector2() : this(NDalicPINVOKE.new_Vector2__SWIG_0(), true)
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 /// <param name="x">x component</param>
185 /// <param name="y">y component</param>
186 public RelativeVector2(float x, float y) : this(NDalicPINVOKE.new_Vector2__SWIG_1(x, y), true)
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 /// <param name="relativeVector3">RelativeVector3 to create this vector from</param>
197 public RelativeVector2(RelativeVector3 relativeVector3) : this(NDalicPINVOKE.new_Vector2__SWIG_3(RelativeVector3.getCPtr(relativeVector3)), true)
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// <param name="relativeVector4">RelativeVector4 to create this vector from</param>
206 public RelativeVector2(RelativeVector4 relativeVector4) : this(NDalicPINVOKE.new_Vector2__SWIG_4(RelativeVector4.getCPtr(relativeVector4)), true)
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 private RelativeVector2 Add(RelativeVector2 rhs)
214 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Add(swigCPtr, RelativeVector2.getCPtr(rhs)), true);
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 private RelativeVector2 Subtract(RelativeVector2 rhs)
221 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Subtract__SWIG_0(swigCPtr, RelativeVector2.getCPtr(rhs)), true);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 private RelativeVector2 Multiply(RelativeVector2 rhs)
228 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Multiply__SWIG_0(swigCPtr, RelativeVector2.getCPtr(rhs)), true);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 private RelativeVector2 Multiply(float rhs)
235 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Multiply__SWIG_1(swigCPtr, rhs), true);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240 private RelativeVector2 Divide(RelativeVector2 rhs)
242 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, RelativeVector2.getCPtr(rhs)), true);
243 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247 private RelativeVector2 Divide(float rhs)
249 RelativeVector2 ret = new RelativeVector2(NDalicPINVOKE.Vector2_Divide__SWIG_1(swigCPtr, rhs), true);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 private float ValueOfIndex(uint index)
256 float ret = NDalicPINVOKE.Vector2_ValueOfIndex__SWIG_0(swigCPtr, index);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// Compare if rhs is equal to
264 /// <param name="rhs">The vector to compare</param>
265 /// <returns>Returns true if the two vectors are equal, otherwise false</returns>
266 public bool EqualTo(RelativeVector2 rhs)
268 bool ret = NDalicPINVOKE.Vector2_EqualTo(swigCPtr, RelativeVector2.getCPtr(rhs));
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 /// Compare if rhs is not equal to
276 /// <param name="rhs">The vector to compare</param>
277 /// <returns>Returns true if the two vectors are not equal, otherwise false</returns>
278 public bool NotEqualTo(RelativeVector2 rhs)
280 bool ret = NDalicPINVOKE.Vector2_NotEqualTo(swigCPtr, RelativeVector2.getCPtr(rhs));
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294 NDalicPINVOKE.Vector2_X_set(swigCPtr, value);
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 float ret = NDalicPINVOKE.Vector2_X_get(swigCPtr);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 NDalicPINVOKE.Vector2_Y_set(swigCPtr, value);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 float ret = NDalicPINVOKE.Vector2_Y_get(swigCPtr);
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 public static implicit operator Vector2(RelativeVector2 relativeVector2)
328 return new Vector2(relativeVector2.X, relativeVector2.Y);
333 public static implicit operator RelativeVector2(Vector2 vec)
337 return new RelativeVector2(vec.X, vec.Y);
340 internal static void ValueCheck(RelativeVector2 relativeVector2)
342 if(relativeVector2.X < 0.0f)
344 relativeVector2.X = 0.0f;
345 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
347 else if(relativeVector2.X > 1.0f)
349 relativeVector2.X = 1.0f;
350 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
352 if(relativeVector2.Y < 0.0f)
354 relativeVector2.Y = 0.0f;
355 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
357 else if(relativeVector2.Y > 1.0f)
359 relativeVector2.Y = 1.0f;
360 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
364 internal static void ValueCheck(float value)
369 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
371 else if(value > 1.0f)
374 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");