2 * Copyright (c) 2018 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.
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
25 /// A three-dimensional size.
27 /// <since_tizen> 5 </since_tizen>
28 [Tizen.NUI.Binding.TypeConverter(typeof(SizeTypeConverter))]
29 public class Size : global::System.IDisposable
31 /// <summary>swigCMemOwn.</summary>
32 /// <since_tizen> 5 </since_tizen>
33 protected bool swigCMemOwn;
36 /// A Flat to check if it is already disposed.
38 /// <since_tizen> 5 </since_tizen>
39 protected bool disposed = false;
41 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
43 //A Flag to check who called Dispose(). (By User or DisposeQueue)
44 private bool isDisposeQueued = false;
49 /// <since_tizen> 5 </since_tizen>
50 public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
52 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 /// <param name="x">The x (or width) component.</param>
59 /// <param name="y">The y (or height) component.</param>
60 /// <param name="z">The z (or depth) component.</param>
61 /// <since_tizen> 5 </since_tizen>
62 public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
64 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70 /// <param name="size2d">Size2D with x (width) and y (height).</param>
71 /// <since_tizen> 5 </since_tizen>
72 public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
74 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 isDisposeQueued = true;
85 DisposeQueue.Instance.Add(this);
90 /// The Zero constant, (0.0f, 0.0f, 0.0f).
92 /// <since_tizen> 5 </since_tizen>
93 public static Size Zero
97 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
98 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 /// The Width property for the width component of size
107 /// <since_tizen> 5 </since_tizen>
112 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124 /// The Height property for the height component of size.
126 /// <since_tizen> 5 </since_tizen>
131 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 /// The Depth property for the depth component of size.
145 /// <since_tizen> 5 </since_tizen>
150 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// The addition operator for A+B.
164 /// <param name="arg1">Size to assign A.</param>
165 /// <param name="arg2">Size to assign B.</param>
166 /// <returns>A size containing the result of the addition.</returns>
167 /// <since_tizen> 5 </since_tizen>
168 public static Size operator +(Size arg1, Size arg2)
170 return arg1.Add(arg2);
174 /// The subtraction operator for A-B.
176 /// <param name="arg1">Size to subtract A.</param>
177 /// <param name="arg2">Size to subtract B.</param>
178 /// <returns>The size containing the result of the subtraction.</returns>
179 /// <since_tizen> 5 </since_tizen>
180 public static Size operator -(Size arg1, Size arg2)
182 return arg1.Subtract(arg2);
186 /// The unary negation operator.
188 /// <param name="arg1">Size for unary negation.</param>
189 /// <returns>A size containing the negation.</returns>
190 /// <since_tizen> 5 </since_tizen>
191 public static Size operator -(Size arg1)
193 return arg1.Subtract();
197 /// The multiplication operator.
199 /// <param name="arg1">Size for multiplication.</param>
200 /// <param name="arg2">The size to multiply.</param>
201 /// <returns>A size containing the result of the multiplication.</returns>
202 /// <since_tizen> 5 </since_tizen>
203 public static Size operator *(Size arg1, Size arg2)
205 return arg1.Multiply(arg2);
209 /// The multiplication operator.
211 /// <param name="arg1">Size for multiplication.</param>
212 /// <param name="arg2">The float value to scale the size.</param>
213 /// <returns>A size containing the result of the scaling.</returns>
214 /// <since_tizen> 5 </since_tizen>
215 public static Size operator *(Size arg1, float arg2)
217 return arg1.Multiply(arg2);
221 /// The division operator.
223 /// <param name="arg1">Size for division.</param>
224 /// <param name="arg2">The size to divide.</param>
225 /// <returns>A size containing the result of the division.</returns>
226 /// <since_tizen> 5 </since_tizen>
227 public static Size operator /(Size arg1, Size arg2)
229 return arg1.Divide(arg2);
233 /// The division operator.
235 /// <param name="arg1">Size for division.</param>
236 /// <param name="arg2">The float value to scale the size by.</param>
237 /// <returns>A Size containing the result of the scaling.</returns>
238 /// <since_tizen> 5 </since_tizen>
239 public static Size operator /(Size arg1, float arg2)
241 return arg1.Divide(arg2);
245 /// The array subscript operator.
247 /// <param name="index">Subscript index.</param>
248 /// <returns>The float at the given index.</returns>
249 /// <since_tizen> 5 </since_tizen>
250 public float this[uint index]
254 return ValueOfIndex(index);
261 /// <since_tizen> 5 </since_tizen>
262 public void Dispose()
264 //Throw excpetion if Dispose() is called in separate thread.
265 if (!Window.IsInstalled())
267 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
272 Dispose(DisposeTypes.Implicit);
276 Dispose(DisposeTypes.Explicit);
277 System.GC.SuppressFinalize(this);
282 /// Determines whether the specified object is equal to the current object.
284 /// <param name="obj">The object to compare with the current object.</param>
285 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
286 public override bool Equals(System.Object obj)
288 Size size = obj as Size;
290 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
298 /// Gets the the hash code of this Size.
300 /// <returns>The Hash Code.</returns>
301 /// <since_tizen> 5 </since_tizen>
302 public override int GetHashCode()
304 return swigCPtr.GetHashCode();
308 /// Checks equality.<br />
309 /// Utilizes appropriate machine epsilon values.<br />
311 /// <param name="rhs">The size to test against.</param>
312 /// <returns>True if the sizes are equal.</returns>
313 /// <since_tizen> 5 </since_tizen>
314 public bool EqualTo(Size rhs)
316 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322 /// Checks inequality.<br />
323 /// Utilizes appropriate machine epsilon values.<br />
325 /// <param name="rhs">The size to test against.</param>
326 /// <returns>True if the sizes are not equal.</returns>
327 /// <since_tizen> 5 </since_tizen>
328 public bool NotEqualTo(Size rhs)
330 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
338 /// The type cast operator, Size to Vector3.
340 /// <param name="size">The object of size type.</param>
341 /// <since_tizen> 5 </since_tizen>
342 public static implicit operator Vector3(Size size)
344 return new Vector3(size.Width, size.Height, size.Depth);
348 /// The type cast operator, Vector3 to Size type.
350 /// <param name="vec">The object of Vector3 type.</param>
351 /// <since_tizen> 5 </since_tizen>
352 public static implicit operator Size(Vector3 vec)
354 return new Size(vec.Width, vec.Height, vec.Depth);
357 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
359 Size ret = new Size(cPtr, false);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
366 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
369 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
371 swigCMemOwn = cMemoryOwn;
372 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
378 /// <since_tizen> 5 </since_tizen>
379 protected virtual void Dispose(DisposeTypes type)
386 if (type == DisposeTypes.Explicit)
389 //Release your own managed resources here.
390 //You should release all of your own disposable objects here.
394 //Release your own unmanaged resources here.
395 //You should not access any managed member here except static instance.
396 //because the execution order of Finalizes is non-deterministic.
398 if (swigCPtr.Handle != global::System.IntPtr.Zero)
403 NDalicPINVOKE.delete_Vector3(swigCPtr);
405 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
411 private Size Add(Size rhs)
413 Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 private Size Subtract(Size rhs)
420 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 private Size Multiply(Size rhs)
427 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 private Size Multiply(float rhs)
434 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 private Size Divide(Size rhs)
441 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 private Size Divide(float rhs)
448 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 private Size Subtract()
455 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 private float ValueOfIndex(uint index)
462 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();