[NUI] Add Obsolete attributes for EditorBrowsable apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / 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 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     // Please do not use! This will be changed to internal class.
24     /// <summary>
25     /// A three-dimensional size.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     [Obsolete("Please do not use! This will be deprecated! Please use Size2D instead!")]
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class Size : global::System.IDisposable
31     {
32         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33         /// <summary>swigCMemOwn.</summary>
34         /// <since_tizen> 3 </since_tizen>
35         protected bool swigCMemOwn;
36
37         internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
38         {
39             swigCMemOwn = cMemoryOwn;
40             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41         }
42
43         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
44         {
45             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46         }
47
48         //A Flag to check who called Dispose(). (By User or DisposeQueue)
49         private bool isDisposeQueued = false;
50         /// <summary>
51         /// A Flat to check if it is already disposed.
52         /// </summary>
53         /// <since_tizen> 3 </since_tizen>
54         protected bool disposed = false;
55
56         /// <summary>
57         /// Dispose.
58         /// </summary>
59         ~Size()
60         {
61             if (!isDisposeQueued)
62             {
63                 isDisposeQueued = true;
64                 DisposeQueue.Instance.Add(this);
65             }
66         }
67
68         /// <summary>
69         /// Dispose.
70         /// </summary>
71         /// <since_tizen> 3 </since_tizen>
72         public void Dispose()
73         {
74             //Throw excpetion if Dispose() is called in separate thread.
75             if (!Window.IsInstalled())
76             {
77                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
78             }
79
80             if (isDisposeQueued)
81             {
82                 Dispose(DisposeTypes.Implicit);
83             }
84             else
85             {
86                 Dispose(DisposeTypes.Explicit);
87                 System.GC.SuppressFinalize(this);
88             }
89         }
90
91         /// <summary>
92         /// Dispose.
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         protected virtual void Dispose(DisposeTypes type)
96         {
97             if (disposed)
98             {
99                 return;
100             }
101
102             if (type == DisposeTypes.Explicit)
103             {
104                 //Called by User
105                 //Release your own managed resources here.
106                 //You should release all of your own disposable objects here.
107
108             }
109
110             //Release your own unmanaged resources here.
111             //You should not access any managed member here except static instance.
112             //because the execution order of Finalizes is non-deterministic.
113
114             if (swigCPtr.Handle != global::System.IntPtr.Zero)
115             {
116                 if (swigCMemOwn)
117                 {
118                     swigCMemOwn = false;
119                     NDalicPINVOKE.delete_Vector3(swigCPtr);
120                 }
121                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
122             }
123
124             disposed = true;
125         }
126
127         /// <summary>
128         /// The addition operator for A+B.
129         /// </summary>
130         /// <param name="arg1">Size to assign A.</param>
131         /// <param name="arg2">Size to assign B.</param>
132         /// <returns>A size containing the result of the addition.</returns>
133         /// <since_tizen> 3 </since_tizen>
134         public static Size operator +(Size arg1, Size arg2)
135         {
136             return arg1.Add(arg2);
137         }
138
139         /// <summary>
140         /// The subtraction operator for A-B.
141         /// </summary>
142         /// <param name="arg1">Size to subtract A.</param>
143         /// <param name="arg2">Size to subtract B.</param>
144         /// <returns>The size containing the result of the subtraction.</returns>
145         /// <since_tizen> 3 </since_tizen>
146         public static Size operator -(Size arg1, Size arg2)
147         {
148             return arg1.Subtract(arg2);
149         }
150
151         /// <summary>
152         /// The unary negation operator.
153         /// </summary>
154         /// <param name="arg1">Size for unary negation.</param>
155         /// <returns>A size containing the negation.</returns>
156         /// <since_tizen> 3 </since_tizen>
157         public static Size operator -(Size arg1)
158         {
159             return arg1.Subtract();
160         }
161
162         /// <summary>
163         /// The multiplication operator.
164         /// </summary>
165         /// <param name="arg1">Size for multiplication.</param>
166         /// <param name="arg2">The size to multiply.</param>
167         /// <returns>A size containing the result of the multiplication.</returns>
168         /// <since_tizen> 3 </since_tizen>
169         public static Size operator *(Size arg1, Size arg2)
170         {
171             return arg1.Multiply(arg2);
172         }
173
174         /// <summary>
175         /// The multiplication operator.
176         /// </summary>
177         /// <param name="arg1">Size for multiplication.</param>
178         /// <param name="arg2">The float value to scale the size.</param>
179         /// <returns>A size containing the result of the scaling.</returns>
180         /// <since_tizen> 3 </since_tizen>
181         public static Size operator *(Size arg1, float arg2)
182         {
183             return arg1.Multiply(arg2);
184         }
185
186         /// <summary>
187         /// The division operator.
188         /// </summary>
189         /// <param name="arg1">Size for division.</param>
190         /// <param name="arg2">The size to divide.</param>
191         /// <returns>A size containing the result of the division.</returns>
192         /// <since_tizen> 3 </since_tizen>
193         public static Size operator /(Size arg1, Size arg2)
194         {
195             return arg1.Divide(arg2);
196         }
197
198         /// <summary>
199         /// The division operator.
200         /// </summary>
201         /// <param name="arg1">Size for division.</param>
202         /// <param name="arg2">The float value to scale the size by.</param>
203         /// <returns>A Size containing the result of the scaling.</returns>
204         /// <since_tizen> 3 </since_tizen>
205         public static Size operator /(Size arg1, float arg2)
206         {
207             return arg1.Divide(arg2);
208         }
209
210         /// <summary>
211         /// The array subscript operator.
212         /// </summary>
213         /// <param name="index">Subscript index.</param>
214         /// <returns>The float at the given index.</returns>
215         /// <since_tizen> 3 </since_tizen>
216         public float this[uint index]
217         {
218             get
219             {
220                 return ValueOfIndex(index);
221             }
222         }
223
224         internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
225         {
226             Size ret = new Size(cPtr, false);
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228             return ret;
229         }
230
231         /// <summary>
232         /// The constructor.
233         /// </summary>
234         /// <since_tizen> 3 </since_tizen>
235         public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
236         {
237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238         }
239
240         /// <summary>
241         /// The constructor.
242         /// </summary>
243         /// <param name="x">The x (or width) component.</param>
244         /// <param name="y">The y (or height) component.</param>
245         /// <param name="z">The z (or depth) component.</param>
246         /// <since_tizen> 3 </since_tizen>
247         public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
248         {
249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250         }
251
252         /// <summary>
253         /// The constructor.
254         /// </summary>
255         /// <param name="size2d">Size2D with x (width) and y (height).</param>
256         /// <since_tizen> 3 </since_tizen>
257         public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
258         {
259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260         }
261
262         /// <summary>
263         /// The Zero constant, (0.0f, 0.0f, 0.0f).
264         /// </summary>
265         /// <since_tizen> 3 </since_tizen>
266         public static Size Zero
267         {
268             get
269             {
270                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
271                 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
272                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273                 return ret;
274             }
275         }
276
277         private Size Add(Size rhs)
278         {
279             Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
280             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281             return ret;
282         }
283
284         private Size Subtract(Size rhs)
285         {
286             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
287             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288             return ret;
289         }
290
291         private Size Multiply(Size rhs)
292         {
293             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295             return ret;
296         }
297
298         private Size Multiply(float rhs)
299         {
300             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302             return ret;
303         }
304
305         private Size Divide(Size rhs)
306         {
307             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309             return ret;
310         }
311
312         private Size Divide(float rhs)
313         {
314             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316             return ret;
317         }
318
319         private Size Subtract()
320         {
321             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323             return ret;
324         }
325
326         private float ValueOfIndex(uint index)
327         {
328             float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330             return ret;
331         }
332
333         /// <summary>
334         /// Checks equality.<br />
335         /// Utilizes appropriate machine epsilon values.<br />
336         /// </summary>
337         /// <param name="rhs">The size to test against.</param>
338         /// <returns>True if the sizes are equal.</returns>
339         /// <since_tizen> 3 </since_tizen>
340         public bool EqualTo(Size rhs)
341         {
342             bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
343             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344             return ret;
345         }
346
347         /// <summary>
348         /// Checks inequality.<br />
349         /// Utilizes appropriate machine epsilon values.<br />
350         /// </summary>
351         /// <param name="rhs">The size to test against.</param>
352         /// <returns>True if the sizes are not equal.</returns>
353         /// <since_tizen> 3 </since_tizen>
354         public bool NotEqualTo(Size rhs)
355         {
356             bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
357             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358             return ret;
359         }
360
361         /// <summary>
362         /// The Width property for the width component of size
363         /// </summary>
364         /// <since_tizen> 3 </since_tizen>
365         public float Width
366         {
367             set
368             {
369                 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
370                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371             }
372             get
373             {
374                 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
375                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376                 return ret;
377             }
378         }
379
380         /// <summary>
381         /// The Height property for the height component of size.
382         /// </summary>
383         /// <since_tizen> 3 </since_tizen>
384         public float Height
385         {
386             set
387             {
388                 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
389                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390             }
391             get
392             {
393                 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
394                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395                 return ret;
396             }
397         }
398
399         /// <summary>
400         /// The Depth property for the depth component of size.
401         /// </summary>
402         /// <since_tizen> 3 </since_tizen>
403         public float Depth
404         {
405             set
406             {
407                 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
408                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409             }
410             get
411             {
412                 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
413                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414                 return ret;
415             }
416         }
417
418         /// <summary>
419         /// The type cast operator, Size to Vector3.
420         /// </summary>
421         /// <param name="size">The object of size type.</param>
422         /// <since_tizen> 3 </since_tizen>
423         public static implicit operator Vector3(Size size)
424         {
425             return new Vector3(size.Width, size.Height, size.Depth);
426         }
427
428         /// <summary>
429         /// The type cast operator, Vector3 to Size type.
430         /// </summary>
431         /// <param name="vec">The object of Vector3 type.</param>
432         /// <since_tizen> 3 </since_tizen>
433         public static implicit operator Size(Vector3 vec)
434         {
435             return new Size(vec.Width, vec.Height, vec.Depth);
436         }
437
438     }
439
440 }
441