Commit manual merge for dali-csharp.
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / Size.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20
21     /// <summary>
22     /// Three dimensional size
23     /// </summary>
24     public class Size : global::System.IDisposable
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27         protected bool swigCMemOwn;
28
29         internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
30         {
31             swigCMemOwn = cMemoryOwn;
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         ~Size()
41         {
42             DisposeQueue.Instance.Add(this);
43         }
44
45         /// <summary>
46         /// Dispose
47         /// </summary>
48         public virtual void Dispose()
49         {
50             if (!Window.IsInstalled())
51             {
52                 DisposeQueue.Instance.Add(this);
53                 return;
54             }
55
56             lock (this)
57             {
58                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
59                 {
60                     if (swigCMemOwn)
61                     {
62                         swigCMemOwn = false;
63                         NDalicPINVOKE.delete_Vector3(swigCPtr);
64                     }
65                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
66                 }
67                 global::System.GC.SuppressFinalize(this);
68             }
69         }
70
71         /// <summary>
72         /// Addition operator for A+B
73         /// </summary>
74         /// <param name="arg1">Size, A</param>
75         /// <param name="arg2">Size to assign, B</param>
76         /// <returns>A Size containing the result of the addition</returns>
77         public static Size operator +(Size arg1, Size arg2)
78         {
79             return arg1.Add(arg2);
80         }
81
82         /// <summary>
83         /// Subtraction operator for A-B
84         /// </summary>
85         /// <param name="arg1">Size, A</param>
86         /// <param name="arg2">Size to subtract, B</param>
87         /// <returns>A Size containing the result of the subtraction</returns>
88         public static Size operator -(Size arg1, Size arg2)
89         {
90             return arg1.Subtract(arg2);
91         }
92
93         /// <summary>
94         /// Unary negation operator.
95         /// </summary>
96         /// <param name="arg1">Size for unary negation</param>
97         /// <returns>A Size containg the negation</returns>
98         public static Size operator -(Size arg1)
99         {
100             return arg1.Subtract();
101         }
102
103         /// <summary>
104         /// Multiplication operator.
105         /// </summary>
106         /// <param name="arg1">Size for multiplication</param>
107         /// <param name="arg2">The Size to multipl</param>
108         /// <returns>A Size containing the result of the multiplication</returns>
109         public static Size operator *(Size arg1, Size arg2)
110         {
111             return arg1.Multiply(arg2);
112         }
113
114         /// <summary>
115         /// Multiplication operator.
116         /// </summary>
117         /// <param name="arg1">Size for multiplication</param>
118         /// <param name="arg2">The float value to scale the Size</param>
119         /// <returns>A Size containing the result of the scaling</returns>
120         public static Size operator *(Size arg1, float arg2)
121         {
122             return arg1.Multiply(arg2);
123         }
124
125         /// <summary>
126         /// Division operator.
127         /// </summary>
128         /// <param name="arg1">Size for division</param>
129         /// <param name="arg2">The Size to divide</param>
130         /// <returns>A Size containing the result of the division></returns>
131         public static Size operator /(Size arg1, Size arg2)
132         {
133             return arg1.Divide(arg2);
134         }
135
136         /// <summary>
137         /// Division operator.
138         /// </summary>
139         /// <param name="arg1">Size for division</param>
140         /// <param name="arg2">The float value to scale the Size by</param>
141         /// <returns>A Size containing the result of the scaling</returns>
142         public static Size operator /(Size arg1, float arg2)
143         {
144             return arg1.Divide(arg2);
145         }
146
147         /// <summary>
148         /// Array subscript operator.
149         /// </summary>
150         /// <param name="index">Subscript index</param>
151         /// <returns>The float at the given index</returns>
152         public float this[uint index]
153         {
154             get
155             {
156                 return ValueOfIndex(index);
157             }
158         }
159
160         internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
161         {
162             Size ret = new Size(cPtr, false);
163             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164             return ret;
165         }
166
167         /// <summary>
168         /// Constructor.
169         /// </summary>
170         public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
171         {
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173         }
174
175         /// <summary>
176         /// Constructor.
177         /// </summary>
178         /// <param name="x">x (or width) component</param>
179         /// <param name="y">y (or height) component</param>
180         /// <param name="z">z (or depth) component</param>
181         public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
182         {
183             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184         }
185
186         /// <summary>
187         /// Constructor.
188         /// </summary>
189         /// <param name="size2d">Size2D with x (width) and y (height)</param>
190         public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
191         {
192             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193         }
194
195         /// <summary>
196         /// Zero constant, (0.0f, 0.0f, 0.0f).
197         /// </summary>
198         public static Size Zero
199         {
200             get
201             {
202                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
203                 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
204                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205                 return ret;
206             }
207         }
208
209         private Size Add(Size rhs)
210         {
211             Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         private Size Subtract(Size rhs)
217         {
218             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
219             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220             return ret;
221         }
222
223         private Size Multiply(Size rhs)
224         {
225             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227             return ret;
228         }
229
230         private Size Multiply(float rhs)
231         {
232             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             return ret;
235         }
236
237         private Size Divide(Size rhs)
238         {
239             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             return ret;
242         }
243
244         private Size Divide(float rhs)
245         {
246             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248             return ret;
249         }
250
251         private Size Subtract()
252         {
253             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
254             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255             return ret;
256         }
257
258         private float ValueOfIndex(uint index)
259         {
260             float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262             return ret;
263         }
264
265         /// <summary>
266         /// Check equality.<br>
267         /// Utilizes appropriate machine epsilon values.<br>
268         /// </summary>
269         /// <param name="rhs">The Size to test against</param>
270         /// <returns>True if the Sizes are equal</returns>
271         public bool EqualTo(Size rhs)
272         {
273             bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
274             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275             return ret;
276         }
277
278         /// <summary>
279         /// Check inequality.<br>
280         /// Utilizes appropriate machine epsilon values.<br>
281         /// </summary>
282         /// <param name="rhs">The Size to test against</param>
283         /// <returns>True if the Sizes are not equal</returns>
284         public bool NotEqualTo(Size rhs)
285         {
286             bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
287             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288             return ret;
289         }
290
291         /// <summary>
292         /// Width property for width component of Siz
293         /// </summary>
294         public float Width
295         {
296             set
297             {
298                 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
299                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             }
301             get
302             {
303                 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
304                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305                 return ret;
306             }
307         }
308
309         /// <summary>
310         /// Height property for height component of Size
311         /// </summary>
312         public float Height
313         {
314             set
315             {
316                 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
317                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318             }
319             get
320             {
321                 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
322                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323                 return ret;
324             }
325         }
326
327         /// <summary>
328         /// Depth property for depth component of Size
329         /// </summary>
330         public float Depth
331         {
332             set
333             {
334                 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
335                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336             }
337             get
338             {
339                 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
340                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341                 return ret;
342             }
343         }
344
345         /// <summary>
346         /// Type cast operator, Size to Vector3.
347         /// </summary>
348         /// <param name="size">Object of Size type</param>
349         public static implicit operator Vector3(Size size)
350         {
351             return new Vector3(size.Width, size.Height, size.Depth);
352         }
353
354         /// <summary>
355         /// Type cast operator, Vector3 to Size type.
356         /// </summary>
357         /// <param name="vec">Object of Vector3 type</param>
358         public static implicit operator Size(Vector3 vec)
359         {
360             return new Size(vec.Width, vec.Height, vec.Depth);
361         }
362
363     }
364
365 }
366