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
36 /// Size2D and Size are implicitly converted to each other, so these are compatible and can be replaced without any type casting. <br />
37 /// For example, the followings are possible. <br />
38 /// view.Size2D = new Size(10.0f, 10.0f, 10.0f); // be aware that here the depth value(10.0f) will be lost. <br />
39 /// view.Size = new Size2D(10, 10); // be aware that here the depth value is 0.0f by default. <br />
40 /// view.MinimumSize = new Size(10, 10, 0); <br />
41 /// Size Tmp = view.MaximumSize; //here Tmp.Depth will be 0.0f. <br />
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="width">The width component.</param>
53 /// <param name="height">The height component.</param>
54 /// <param name="depth">The depth component(optional).</param>
56 /// Size2D and Size are implicitly converted to each other, so these are compatible and can be replaced without any type casting. <br />
57 /// For example, the followings are possible. <br />
58 /// view.Size2D = new Size(10.0f, 10.0f, 10.0f); // be aware that here the depth value(10.0f) will be lost. <br />
59 /// view.Size = new Size2D(10, 10); // be aware that here the depth value is 0.0f by default. <br />
60 /// view.MinimumSize = new Size(10, 10, 0); <br />
61 /// Size Tmp = view.MaximumSize; //here Tmp.Depth will be 0.0f. <br />
63 /// <since_tizen> 5 </since_tizen>
64 public Size(float width, float height, float depth = 0.0f) : this(Interop.Vector3.new_Vector3__SWIG_1(width, height, depth), true)
66 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 /// <param name="size2d">Size2D with width and height.</param>
73 /// <since_tizen> 5 </since_tizen>
74 public Size(Size2D size2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 /// The Zero constant, (0.0f, 0.0f, 0.0f).
82 /// <since_tizen> 5 </since_tizen>
83 public static Size Zero
87 global::System.IntPtr cPtr = Interop.Vector3.Vector3_ZERO_get();
88 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95 /// The Width property for the width component of size
97 /// <since_tizen> 5 </since_tizen>
102 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 callback?.Invoke(Width, Height, Depth);
109 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 /// The Height property for the height component of size.
118 /// <since_tizen> 5 </since_tizen>
123 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 callback?.Invoke(Width, Height, Depth);
130 float ret = Interop.Vector3.Vector3_Height_get(swigCPtr);
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 /// The Depth property for the depth component of size.
139 /// <since_tizen> 5 </since_tizen>
144 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 callback?.Invoke(Width, Height, Depth);
151 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 /// The addition operator for A+B.
160 /// <param name="arg1">Size to assign A.</param>
161 /// <param name="arg2">Size to assign B.</param>
162 /// <returns>A size containing the result of the addition.</returns>
163 /// <since_tizen> 5 </since_tizen>
164 public static Size operator +(Size arg1, Size arg2)
166 return arg1.Add(arg2);
170 /// The subtraction operator for A-B.
172 /// <param name="arg1">Size to subtract A.</param>
173 /// <param name="arg2">Size to subtract B.</param>
174 /// <returns>The size containing the result of the subtraction.</returns>
175 /// <since_tizen> 5 </since_tizen>
176 public static Size operator -(Size arg1, Size arg2)
178 return arg1.Subtract(arg2);
182 /// The unary negation operator.
184 /// <param name="arg1">Size for unary negation.</param>
185 /// <returns>A size containing the negation.</returns>
186 /// <since_tizen> 5 </since_tizen>
187 public static Size operator -(Size arg1)
189 return arg1.Subtract();
193 /// The multiplication operator.
195 /// <param name="arg1">Size for multiplication.</param>
196 /// <param name="arg2">The size to multiply.</param>
197 /// <returns>A size containing the result of the multiplication.</returns>
198 /// <since_tizen> 5 </since_tizen>
199 public static Size operator *(Size arg1, Size arg2)
201 return arg1.Multiply(arg2);
205 /// The multiplication operator.
207 /// <param name="arg1">Size for multiplication.</param>
208 /// <param name="arg2">The float value to scale the size.</param>
209 /// <returns>A size containing the result of the scaling.</returns>
210 /// <since_tizen> 5 </since_tizen>
211 public static Size operator *(Size arg1, float arg2)
213 return arg1.Multiply(arg2);
217 /// The division operator.
219 /// <param name="arg1">Size for division.</param>
220 /// <param name="arg2">The size to divide.</param>
221 /// <returns>A size containing the result of the division.</returns>
222 /// <since_tizen> 5 </since_tizen>
223 public static Size operator /(Size arg1, Size arg2)
225 return arg1.Divide(arg2);
229 /// The division operator.
231 /// <param name="arg1">Size for division.</param>
232 /// <param name="arg2">The float value to scale the size by.</param>
233 /// <returns>A Size containing the result of the scaling.</returns>
234 /// <since_tizen> 5 </since_tizen>
235 public static Size operator /(Size arg1, float arg2)
237 return arg1.Divide(arg2);
241 /// The array subscript operator.
243 /// <param name="index">Subscript index.</param>
244 /// <returns>The float at the given index.</returns>
245 /// <since_tizen> 5 </since_tizen>
246 public float this[uint index]
250 return ValueOfIndex(index);
255 /// Determines whether the specified object is equal to the current object.
257 /// <param name="obj">The object to compare with the current object.</param>
258 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
259 public override bool Equals(System.Object obj)
261 Size size = obj as Size;
263 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
271 /// Gets the the hash code of this Size.
273 /// <returns>The Hash Code.</returns>
274 /// <since_tizen> 6 </since_tizen>
275 public override int GetHashCode()
277 return swigCPtr.Handle.GetHashCode();
281 /// Checks equality.<br />
282 /// Utilizes appropriate machine epsilon values.<br />
284 /// <param name="rhs">The size to test against.</param>
285 /// <returns>True if the sizes are equal.</returns>
286 /// <since_tizen> 5 </since_tizen>
287 public bool EqualTo(Size rhs)
289 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 /// Checks inequality.<br />
296 /// Utilizes appropriate machine epsilon values.<br />
298 /// <param name="rhs">The size to test against.</param>
299 /// <returns>True if the sizes are not equal.</returns>
300 /// <since_tizen> 5 </since_tizen>
301 public bool NotEqualTo(Size rhs)
303 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 /// The type cast operator, Size to Vector3.
311 /// <param name="size">The object of size type.</param>
312 /// <since_tizen> 5 </since_tizen>
313 public static implicit operator Vector3(Size size)
315 return new Vector3(size.Width, size.Height, size.Depth);
319 /// The type cast operator, Vector3 to Size type.
321 /// <param name="vec">The object of Vector3 type.</param>
322 /// <since_tizen> 5 </since_tizen>
323 public static implicit operator Size(Vector3 vec)
325 return new Size(vec.Width, vec.Height, vec.Depth);
329 /// Implicit type cast operator, Size2D to Size
331 /// <param name="size2d">The object of Size2D type.</param>
332 /// <since_tizen> none </since_tizen>
333 /// This will be public opened in tizen_next by ACR.
334 [EditorBrowsable(EditorBrowsableState.Never)]
335 public static implicit operator Size(Size2D size2d)
337 return new Size(size2d.Width, size2d.Height, 0);
341 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
343 Size ret = new Size(cPtr, false);
344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
350 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
353 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
357 /// This will not be public opened.
358 [EditorBrowsable(EditorBrowsableState.Never)]
359 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
361 Interop.Vector3.delete_Vector3(swigCPtr);
364 private Size Add(Size rhs)
366 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371 private Size Subtract(Size rhs)
373 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
374 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 private Size Multiply(Size rhs)
380 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 private Size Multiply(float rhs)
387 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 private Size Divide(Size rhs)
394 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 private Size Divide(float rhs)
401 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 private Size Subtract()
408 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 private float ValueOfIndex(uint index)
415 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 internal delegate void SizeChangedCallback(float width, float height, float depth);
422 internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428 private SizeChangedCallback callback = null;