2 * Copyright (c) 2019 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 : Disposable
31 /// <summary>swigCMemOwn.</summary>
32 /// <since_tizen> 5 </since_tizen>
33 protected bool swigCMemOwn;
35 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37 //A Flag to check who called Dispose(). (By User or DisposeQueue)
38 private bool isDisposeQueued = false;
43 /// <since_tizen> 5 </since_tizen>
44 public Size() : this(Interop.Vector3.new_Vector3__SWIG_0(), true)
46 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 /// <param name="x">The x (or width) component.</param>
53 /// <param name="y">The y (or height) component.</param>
54 /// <param name="z">The z (or depth) component(optional).</param>
55 /// <since_tizen> 5 </since_tizen>
56 public Size(float x, float y, float z = 0.0f) : this(Interop.Vector3.new_Vector3__SWIG_1(x, y, z), true)
58 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64 /// <param name="size2d">Size2D with x (width) and y (height).</param>
65 /// <since_tizen> 5 </since_tizen>
66 public Size(Size2D size2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
68 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 /// The Zero constant, (0.0f, 0.0f, 0.0f).
74 /// <since_tizen> 5 </since_tizen>
75 public static Size Zero
79 global::System.IntPtr cPtr = Interop.Vector3.Vector3_ZERO_get();
80 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
81 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87 /// The Width property for the width component of size
89 /// <since_tizen> 5 </since_tizen>
94 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 callback?.Invoke(Width, Height, Depth);
101 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 /// The Height property for the height component of size.
110 /// <since_tizen> 5 </since_tizen>
115 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 callback?.Invoke(Width, Height, Depth);
122 float ret = Interop.Vector3.Vector3_Height_get(swigCPtr);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 /// The Depth property for the depth component of size.
131 /// <since_tizen> 5 </since_tizen>
136 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 callback?.Invoke(Width, Height, Depth);
143 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 /// The addition operator for A+B.
152 /// <param name="arg1">Size to assign A.</param>
153 /// <param name="arg2">Size to assign B.</param>
154 /// <returns>A size containing the result of the addition.</returns>
155 /// <since_tizen> 5 </since_tizen>
156 public static Size operator +(Size arg1, Size arg2)
158 return arg1.Add(arg2);
162 /// The subtraction operator for A-B.
164 /// <param name="arg1">Size to subtract A.</param>
165 /// <param name="arg2">Size to subtract B.</param>
166 /// <returns>The size containing the result of the subtraction.</returns>
167 /// <since_tizen> 5 </since_tizen>
168 public static Size operator -(Size arg1, Size arg2)
170 return arg1.Subtract(arg2);
174 /// The unary negation operator.
176 /// <param name="arg1">Size for unary negation.</param>
177 /// <returns>A size containing the negation.</returns>
178 /// <since_tizen> 5 </since_tizen>
179 public static Size operator -(Size arg1)
181 return arg1.Subtract();
185 /// The multiplication operator.
187 /// <param name="arg1">Size for multiplication.</param>
188 /// <param name="arg2">The size to multiply.</param>
189 /// <returns>A size containing the result of the multiplication.</returns>
190 /// <since_tizen> 5 </since_tizen>
191 public static Size operator *(Size arg1, Size arg2)
193 return arg1.Multiply(arg2);
197 /// The multiplication operator.
199 /// <param name="arg1">Size for multiplication.</param>
200 /// <param name="arg2">The float value to scale the size.</param>
201 /// <returns>A size containing the result of the scaling.</returns>
202 /// <since_tizen> 5 </since_tizen>
203 public static Size operator *(Size arg1, float arg2)
205 return arg1.Multiply(arg2);
209 /// The division operator.
211 /// <param name="arg1">Size for division.</param>
212 /// <param name="arg2">The size to divide.</param>
213 /// <returns>A size containing the result of the division.</returns>
214 /// <since_tizen> 5 </since_tizen>
215 public static Size operator /(Size arg1, Size arg2)
217 return arg1.Divide(arg2);
221 /// The division operator.
223 /// <param name="arg1">Size for division.</param>
224 /// <param name="arg2">The float value to scale the size by.</param>
225 /// <returns>A Size containing the result of the scaling.</returns>
226 /// <since_tizen> 5 </since_tizen>
227 public static Size operator /(Size arg1, float arg2)
229 return arg1.Divide(arg2);
233 /// The array subscript operator.
235 /// <param name="index">Subscript index.</param>
236 /// <returns>The float at the given index.</returns>
237 /// <since_tizen> 5 </since_tizen>
238 public float this[uint index]
242 return ValueOfIndex(index);
247 /// Determines whether the specified object is equal to the current object.
249 /// <param name="obj">The object to compare with the current object.</param>
250 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
251 public override bool Equals(System.Object obj)
253 Size size = obj as Size;
255 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
263 /// Gets the the hash code of this Size.
265 /// <returns>The Hash Code.</returns>
266 /// <since_tizen> 6 </since_tizen>
267 public override int GetHashCode()
269 return swigCPtr.Handle.GetHashCode();
273 /// Checks equality.<br />
274 /// Utilizes appropriate machine epsilon values.<br />
276 /// <param name="rhs">The size to test against.</param>
277 /// <returns>True if the sizes are equal.</returns>
278 /// <since_tizen> 5 </since_tizen>
279 public bool EqualTo(Size rhs)
281 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 /// Checks inequality.<br />
288 /// Utilizes appropriate machine epsilon values.<br />
290 /// <param name="rhs">The size to test against.</param>
291 /// <returns>True if the sizes are not equal.</returns>
292 /// <since_tizen> 5 </since_tizen>
293 public bool NotEqualTo(Size rhs)
295 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 /// The type cast operator, Size to Vector3.
303 /// <param name="size">The object of size type.</param>
304 /// <since_tizen> 5 </since_tizen>
305 public static implicit operator Vector3(Size size)
307 return new Vector3(size.Width, size.Height, size.Depth);
311 /// The type cast operator, Vector3 to Size type.
313 /// <param name="vec">The object of Vector3 type.</param>
314 /// <since_tizen> 5 </since_tizen>
315 public static implicit operator Size(Vector3 vec)
317 return new Size(vec.Width, vec.Height, vec.Depth);
320 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
322 Size ret = new Size(cPtr, false);
323 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
329 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
332 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
334 swigCMemOwn = cMemoryOwn;
335 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
341 /// <since_tizen> 5 </since_tizen>
342 protected override void Dispose(DisposeTypes type)
349 //Release your own unmanaged resources here.
350 //You should not access any managed member here except static instance.
351 //because the execution order of Finalizes is non-deterministic.
353 if (swigCPtr.Handle != global::System.IntPtr.Zero)
358 Interop.Vector3.delete_Vector3(swigCPtr);
360 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
366 private Size Add(Size rhs)
368 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 private Size Subtract(Size rhs)
375 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 private Size Multiply(Size rhs)
382 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 private Size Multiply(float rhs)
389 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394 private Size Divide(Size rhs)
396 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 private Size Divide(float rhs)
403 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 private Size Subtract()
410 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 private float ValueOfIndex(uint index)
417 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 internal delegate void SizeChangedCallback(float width, float height, float depth);
424 internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 private SizeChangedCallback callback = null;