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>
98 [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
103 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
105 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 callback?.Invoke(value, null, null);
112 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 /// The Height property for the height component of size.
121 /// <since_tizen> 5 </since_tizen>
122 [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
127 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
129 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132 callback?.Invoke(null, value, null);
136 float ret = Interop.Vector3.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>
146 [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
151 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
153 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 callback?.Invoke(null, null, value);
160 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// The addition operator for A+B.
169 /// <param name="arg1">Size to assign A.</param>
170 /// <param name="arg2">Size to assign B.</param>
171 /// <returns>A size containing the result of the addition.</returns>
172 /// <since_tizen> 5 </since_tizen>
173 public static Size operator +(Size arg1, Size arg2)
175 return arg1.Add(arg2);
179 /// The subtraction operator for A-B.
181 /// <param name="arg1">Size to subtract A.</param>
182 /// <param name="arg2">Size to subtract B.</param>
183 /// <returns>The size containing the result of the subtraction.</returns>
184 /// <since_tizen> 5 </since_tizen>
185 public static Size operator -(Size arg1, Size arg2)
187 return arg1.Subtract(arg2);
191 /// The unary negation operator.
193 /// <param name="arg1">Size for unary negation.</param>
194 /// <returns>A size containing the negation.</returns>
195 /// <since_tizen> 5 </since_tizen>
196 public static Size operator -(Size arg1)
198 return arg1.Subtract();
202 /// The multiplication operator.
204 /// <param name="arg1">Size for multiplication.</param>
205 /// <param name="arg2">The size to multiply.</param>
206 /// <returns>A size containing the result of the multiplication.</returns>
207 /// <since_tizen> 5 </since_tizen>
208 public static Size operator *(Size arg1, Size arg2)
210 return arg1.Multiply(arg2);
214 /// The multiplication operator.
216 /// <param name="arg1">Size for multiplication.</param>
217 /// <param name="arg2">The float value to scale the size.</param>
218 /// <returns>A size containing the result of the scaling.</returns>
219 /// <since_tizen> 5 </since_tizen>
220 public static Size operator *(Size arg1, float arg2)
222 return arg1.Multiply(arg2);
226 /// The division operator.
228 /// <param name="arg1">Size for division.</param>
229 /// <param name="arg2">The size to divide.</param>
230 /// <returns>A size containing the result of the division.</returns>
231 /// <since_tizen> 5 </since_tizen>
232 public static Size operator /(Size arg1, Size arg2)
234 return arg1.Divide(arg2);
238 /// The division operator.
240 /// <param name="arg1">Size for division.</param>
241 /// <param name="arg2">The float value to scale the size by.</param>
242 /// <returns>A Size containing the result of the scaling.</returns>
243 /// <since_tizen> 5 </since_tizen>
244 public static Size operator /(Size arg1, float arg2)
246 return arg1.Divide(arg2);
250 /// The array subscript operator.
252 /// <param name="index">Subscript index.</param>
253 /// <returns>The float at the given index.</returns>
254 /// <since_tizen> 5 </since_tizen>
255 public float this[uint index]
259 return ValueOfIndex(index);
264 /// Determines whether the specified object is equal to the current object.
266 /// <param name="obj">The object to compare with the current object.</param>
267 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
268 public override bool Equals(System.Object obj)
270 Size size = obj as Size;
272 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
280 /// Gets the the hash code of this Size.
282 /// <returns>The Hash Code.</returns>
283 /// <since_tizen> 6 </since_tizen>
284 public override int GetHashCode()
286 return swigCPtr.Handle.GetHashCode();
290 /// Checks equality.<br />
291 /// Utilizes appropriate machine epsilon values.<br />
293 /// <param name="rhs">The size to test against.</param>
294 /// <returns>True if the sizes are equal.</returns>
295 /// <since_tizen> 5 </since_tizen>
296 public bool EqualTo(Size rhs)
298 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 /// Checks inequality.<br />
305 /// Utilizes appropriate machine epsilon values.<br />
307 /// <param name="rhs">The size to test against.</param>
308 /// <returns>True if the sizes are not equal.</returns>
309 /// <since_tizen> 5 </since_tizen>
310 public bool NotEqualTo(Size rhs)
312 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 /// The type cast operator, Size to Vector3.
320 /// <param name="size">The object of size type.</param>
321 /// <since_tizen> 5 </since_tizen>
322 public static implicit operator Vector3(Size size)
324 return new Vector3(size.Width, size.Height, size.Depth);
328 /// The type cast operator, Vector3 to Size type.
330 /// <param name="vec">The object of Vector3 type.</param>
331 /// <since_tizen> 5 </since_tizen>
332 public static implicit operator Size(Vector3 vec)
334 return new Size(vec.Width, vec.Height, vec.Depth);
338 /// Implicit type cast operator, Size2D to Size
340 /// <param name="size2d">The object of Size2D type.</param>
341 /// <since_tizen> none </since_tizen>
342 /// This will be public opened in tizen_next by ACR.
343 [EditorBrowsable(EditorBrowsableState.Never)]
344 public static implicit operator Size(Size2D size2d)
346 return new Size(size2d.Width, size2d.Height, 0);
350 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
352 Size ret = new Size(cPtr, false);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
359 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
362 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
366 /// This will not be public opened.
367 [EditorBrowsable(EditorBrowsableState.Never)]
368 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
370 Interop.Vector3.delete_Vector3(swigCPtr);
373 private Size Add(Size rhs)
375 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 private Size Subtract(Size rhs)
382 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 private Size Multiply(Size rhs)
389 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394 private Size Multiply(float rhs)
396 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 private Size Divide(Size rhs)
403 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 private Size Divide(float rhs)
410 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 private Size Subtract()
417 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 private float ValueOfIndex(uint index)
424 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 internal delegate void SizeChangedCallback(float? width, float? height, float? depth);
431 internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 internal Size(SizeChangedCallback cb, Size other) : this(cb, other.Width, other.Height, other.Depth)
441 private SizeChangedCallback callback = null;