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;
40 /// <since_tizen> 5 </since_tizen>
41 public Size() : this(Interop.Vector3.new_Vector3__SWIG_0(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
49 /// <param name="x">The x (or width) component.</param>
50 /// <param name="y">The y (or height) component.</param>
51 /// <param name="z">The z (or depth) component(optional).</param>
52 /// <since_tizen> 5 </since_tizen>
53 public Size(float x, float y, float z = 0.0f) : this(Interop.Vector3.new_Vector3__SWIG_1(x, y, z), true)
55 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61 /// <param name="size2d">Size2D with x (width) and y (height).</param>
62 /// <since_tizen> 5 </since_tizen>
63 public Size(Size2D size2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
65 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 /// The Zero constant, (0.0f, 0.0f, 0.0f).
71 /// <since_tizen> 5 </since_tizen>
72 public static Size Zero
76 global::System.IntPtr cPtr = Interop.Vector3.Vector3_ZERO_get();
77 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
78 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 /// The Width property for the width component of size
86 /// <since_tizen> 5 </since_tizen>
91 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
92 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94 callback?.Invoke(Width, Height, Depth);
98 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 /// The Height property for the height component of size.
107 /// <since_tizen> 5 </since_tizen>
112 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 callback?.Invoke(Width, Height, Depth);
119 float ret = Interop.Vector3.Vector3_Height_get(swigCPtr);
120 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 /// The Depth property for the depth component of size.
128 /// <since_tizen> 5 </since_tizen>
133 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 callback?.Invoke(Width, Height, Depth);
140 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// The addition operator for A+B.
149 /// <param name="arg1">Size to assign A.</param>
150 /// <param name="arg2">Size to assign B.</param>
151 /// <returns>A size containing the result of the addition.</returns>
152 /// <since_tizen> 5 </since_tizen>
153 public static Size operator +(Size arg1, Size arg2)
155 return arg1.Add(arg2);
159 /// The subtraction operator for A-B.
161 /// <param name="arg1">Size to subtract A.</param>
162 /// <param name="arg2">Size to subtract B.</param>
163 /// <returns>The size containing the result of the subtraction.</returns>
164 /// <since_tizen> 5 </since_tizen>
165 public static Size operator -(Size arg1, Size arg2)
167 return arg1.Subtract(arg2);
171 /// The unary negation operator.
173 /// <param name="arg1">Size for unary negation.</param>
174 /// <returns>A size containing the negation.</returns>
175 /// <since_tizen> 5 </since_tizen>
176 public static Size operator -(Size arg1)
178 return arg1.Subtract();
182 /// The multiplication operator.
184 /// <param name="arg1">Size for multiplication.</param>
185 /// <param name="arg2">The size to multiply.</param>
186 /// <returns>A size containing the result of the multiplication.</returns>
187 /// <since_tizen> 5 </since_tizen>
188 public static Size operator *(Size arg1, Size arg2)
190 return arg1.Multiply(arg2);
194 /// The multiplication operator.
196 /// <param name="arg1">Size for multiplication.</param>
197 /// <param name="arg2">The float value to scale the size.</param>
198 /// <returns>A size containing the result of the scaling.</returns>
199 /// <since_tizen> 5 </since_tizen>
200 public static Size operator *(Size arg1, float arg2)
202 return arg1.Multiply(arg2);
206 /// The division operator.
208 /// <param name="arg1">Size for division.</param>
209 /// <param name="arg2">The size to divide.</param>
210 /// <returns>A size containing the result of the division.</returns>
211 /// <since_tizen> 5 </since_tizen>
212 public static Size operator /(Size arg1, Size arg2)
214 return arg1.Divide(arg2);
218 /// The division operator.
220 /// <param name="arg1">Size for division.</param>
221 /// <param name="arg2">The float value to scale the size by.</param>
222 /// <returns>A Size containing the result of the scaling.</returns>
223 /// <since_tizen> 5 </since_tizen>
224 public static Size operator /(Size arg1, float arg2)
226 return arg1.Divide(arg2);
230 /// The array subscript operator.
232 /// <param name="index">Subscript index.</param>
233 /// <returns>The float at the given index.</returns>
234 /// <since_tizen> 5 </since_tizen>
235 public float this[uint index]
239 return ValueOfIndex(index);
244 /// Determines whether the specified object is equal to the current object.
246 /// <param name="obj">The object to compare with the current object.</param>
247 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
248 public override bool Equals(System.Object obj)
250 Size size = obj as Size;
252 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
260 /// Gets the the hash code of this Size.
262 /// <returns>The Hash Code.</returns>
263 /// <since_tizen> 6 </since_tizen>
264 public override int GetHashCode()
266 return swigCPtr.Handle.GetHashCode();
270 /// Checks equality.<br />
271 /// Utilizes appropriate machine epsilon values.<br />
273 /// <param name="rhs">The size to test against.</param>
274 /// <returns>True if the sizes are equal.</returns>
275 /// <since_tizen> 5 </since_tizen>
276 public bool EqualTo(Size rhs)
278 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 /// Checks inequality.<br />
285 /// Utilizes appropriate machine epsilon values.<br />
287 /// <param name="rhs">The size to test against.</param>
288 /// <returns>True if the sizes are not equal.</returns>
289 /// <since_tizen> 5 </since_tizen>
290 public bool NotEqualTo(Size rhs)
292 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 /// The type cast operator, Size to Vector3.
300 /// <param name="size">The object of size type.</param>
301 /// <since_tizen> 5 </since_tizen>
302 public static implicit operator Vector3(Size size)
304 return new Vector3(size.Width, size.Height, size.Depth);
308 /// The type cast operator, Vector3 to Size type.
310 /// <param name="vec">The object of Vector3 type.</param>
311 /// <since_tizen> 5 </since_tizen>
312 public static implicit operator Size(Vector3 vec)
314 return new Size(vec.Width, vec.Height, vec.Depth);
317 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
319 Size ret = new Size(cPtr, false);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
326 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
329 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
331 swigCMemOwn = cMemoryOwn;
332 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
338 /// <since_tizen> 5 </since_tizen>
339 protected override void Dispose(DisposeTypes type)
346 //Release your own unmanaged resources here.
347 //You should not access any managed member here except static instance.
348 //because the execution order of Finalizes is non-deterministic.
350 if (swigCPtr.Handle != global::System.IntPtr.Zero)
355 Interop.Vector3.delete_Vector3(swigCPtr);
357 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
363 private Size Add(Size rhs)
365 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 private Size Subtract(Size rhs)
372 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377 private Size Multiply(Size rhs)
379 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 private Size Multiply(float rhs)
386 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391 private Size Divide(Size rhs)
393 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 private Size Divide(float rhs)
400 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405 private Size Subtract()
407 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 private float ValueOfIndex(uint index)
414 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419 internal delegate void SizeChangedCallback(float width, float height, float depth);
421 internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
424 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 private SizeChangedCallback callback = null;