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;
41 /// Size2D and Size are implicitly converted to each other, so these are compatible and can be replaced without any type casting. <br />
42 /// For example, the followings are possible. <br />
43 /// view.Size2D = new Size(10.0f, 10.0f, 10.0f); // be aware that here the depth value(10.0f) will be lost. <br />
44 /// view.Size = new Size2D(10, 10); // be aware that here the depth value is 0.0f by default. <br />
45 /// view.MinimumSize = new Size(10, 10, 0); <br />
46 /// Size Tmp = view.MaximumSize; //here Tmp.Depth will be 0.0f. <br />
48 /// <since_tizen> 5 </since_tizen>
49 public Size() : this(Interop.Vector3.new_Vector3__SWIG_0(), true)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 /// <param name="width">The width component.</param>
58 /// <param name="height">The height component.</param>
59 /// <param name="depth">The depth component(optional).</param>
61 /// Size2D and Size are implicitly converted to each other, so these are compatible and can be replaced without any type casting. <br />
62 /// For example, the followings are possible. <br />
63 /// view.Size2D = new Size(10.0f, 10.0f, 10.0f); // be aware that here the depth value(10.0f) will be lost. <br />
64 /// view.Size = new Size2D(10, 10); // be aware that here the depth value is 0.0f by default. <br />
65 /// view.MinimumSize = new Size(10, 10, 0); <br />
66 /// Size Tmp = view.MaximumSize; //here Tmp.Depth will be 0.0f. <br />
68 /// <since_tizen> 5 </since_tizen>
69 public Size(float width, float height, float depth = 0.0f) : this(Interop.Vector3.new_Vector3__SWIG_1(width, height, depth), true)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77 /// <param name="size2d">Size2D with width and height.</param>
78 /// <since_tizen> 5 </since_tizen>
79 public Size(Size2D size2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
81 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 /// The Zero constant, (0.0f, 0.0f, 0.0f).
87 /// <since_tizen> 5 </since_tizen>
88 public static Size Zero
92 global::System.IntPtr cPtr = Interop.Vector3.Vector3_ZERO_get();
93 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100 /// The Width property for the width component of size
102 /// <since_tizen> 5 </since_tizen>
107 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 callback?.Invoke(Width, Height, Depth);
114 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// The Height property for the height component of size.
123 /// <since_tizen> 5 </since_tizen>
128 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 callback?.Invoke(Width, Height, Depth);
135 float ret = Interop.Vector3.Vector3_Height_get(swigCPtr);
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 /// The Depth property for the depth component of size.
144 /// <since_tizen> 5 </since_tizen>
149 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152 callback?.Invoke(Width, Height, Depth);
156 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 /// The addition operator for A+B.
165 /// <param name="arg1">Size to assign A.</param>
166 /// <param name="arg2">Size to assign B.</param>
167 /// <returns>A size containing the result of the addition.</returns>
168 /// <since_tizen> 5 </since_tizen>
169 public static Size operator +(Size arg1, Size arg2)
171 return arg1.Add(arg2);
175 /// The subtraction operator for A-B.
177 /// <param name="arg1">Size to subtract A.</param>
178 /// <param name="arg2">Size to subtract B.</param>
179 /// <returns>The size containing the result of the subtraction.</returns>
180 /// <since_tizen> 5 </since_tizen>
181 public static Size operator -(Size arg1, Size arg2)
183 return arg1.Subtract(arg2);
187 /// The unary negation operator.
189 /// <param name="arg1">Size for unary negation.</param>
190 /// <returns>A size containing the negation.</returns>
191 /// <since_tizen> 5 </since_tizen>
192 public static Size operator -(Size arg1)
194 return arg1.Subtract();
198 /// The multiplication operator.
200 /// <param name="arg1">Size for multiplication.</param>
201 /// <param name="arg2">The size to multiply.</param>
202 /// <returns>A size containing the result of the multiplication.</returns>
203 /// <since_tizen> 5 </since_tizen>
204 public static Size operator *(Size arg1, Size arg2)
206 return arg1.Multiply(arg2);
210 /// The multiplication operator.
212 /// <param name="arg1">Size for multiplication.</param>
213 /// <param name="arg2">The float value to scale the size.</param>
214 /// <returns>A size containing the result of the scaling.</returns>
215 /// <since_tizen> 5 </since_tizen>
216 public static Size operator *(Size arg1, float arg2)
218 return arg1.Multiply(arg2);
222 /// The division operator.
224 /// <param name="arg1">Size for division.</param>
225 /// <param name="arg2">The size to divide.</param>
226 /// <returns>A size containing the result of the division.</returns>
227 /// <since_tizen> 5 </since_tizen>
228 public static Size operator /(Size arg1, Size arg2)
230 return arg1.Divide(arg2);
234 /// The division operator.
236 /// <param name="arg1">Size for division.</param>
237 /// <param name="arg2">The float value to scale the size by.</param>
238 /// <returns>A Size containing the result of the scaling.</returns>
239 /// <since_tizen> 5 </since_tizen>
240 public static Size operator /(Size arg1, float arg2)
242 return arg1.Divide(arg2);
246 /// The array subscript operator.
248 /// <param name="index">Subscript index.</param>
249 /// <returns>The float at the given index.</returns>
250 /// <since_tizen> 5 </since_tizen>
251 public float this[uint index]
255 return ValueOfIndex(index);
260 /// Determines whether the specified object is equal to the current object.
262 /// <param name="obj">The object to compare with the current object.</param>
263 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
264 public override bool Equals(System.Object obj)
266 Size size = obj as Size;
268 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
276 /// Gets the the hash code of this Size.
278 /// <returns>The Hash Code.</returns>
279 /// <since_tizen> 6 </since_tizen>
280 public override int GetHashCode()
282 return swigCPtr.Handle.GetHashCode();
286 /// Checks equality.<br />
287 /// Utilizes appropriate machine epsilon values.<br />
289 /// <param name="rhs">The size to test against.</param>
290 /// <returns>True if the sizes are equal.</returns>
291 /// <since_tizen> 5 </since_tizen>
292 public bool EqualTo(Size rhs)
294 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 /// Checks inequality.<br />
301 /// Utilizes appropriate machine epsilon values.<br />
303 /// <param name="rhs">The size to test against.</param>
304 /// <returns>True if the sizes are not equal.</returns>
305 /// <since_tizen> 5 </since_tizen>
306 public bool NotEqualTo(Size rhs)
308 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 /// The type cast operator, Size to Vector3.
316 /// <param name="size">The object of size type.</param>
317 /// <since_tizen> 5 </since_tizen>
318 public static implicit operator Vector3(Size size)
320 return new Vector3(size.Width, size.Height, size.Depth);
324 /// The type cast operator, Vector3 to Size type.
326 /// <param name="vec">The object of Vector3 type.</param>
327 /// <since_tizen> 5 </since_tizen>
328 public static implicit operator Size(Vector3 vec)
330 return new Size(vec.Width, vec.Height, vec.Depth);
334 /// Implicit type cast operator, Size2D to Size
336 /// <param name="size2d">The object of Size2D type.</param>
337 /// <since_tizen> none </since_tizen>
338 /// This will be public opened in tizen_next by ACR.
339 [EditorBrowsable(EditorBrowsableState.Never)]
340 public static implicit operator Size(Size2D size2d)
342 return new Size(size2d.Width, size2d.Height, 0);
346 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
348 Size ret = new Size(cPtr, false);
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
355 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
358 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
360 swigCMemOwn = cMemoryOwn;
361 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
367 /// <since_tizen> 5 </since_tizen>
368 protected override void Dispose(DisposeTypes type)
375 //Release your own unmanaged resources here.
376 //You should not access any managed member here except static instance.
377 //because the execution order of Finalizes is non-deterministic.
379 if (swigCPtr.Handle != global::System.IntPtr.Zero)
384 Interop.Vector3.delete_Vector3(swigCPtr);
386 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
392 private Size Add(Size rhs)
394 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 private Size Subtract(Size rhs)
401 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 private Size Multiply(Size rhs)
408 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 private Size Multiply(float rhs)
415 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 private Size Divide(Size rhs)
422 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 private Size Divide(float rhs)
429 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 private Size Subtract()
436 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441 private float ValueOfIndex(uint index)
443 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 internal delegate void SizeChangedCallback(float width, float height, float depth);
450 internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 private SizeChangedCallback callback = null;