Merge "Dali C#: Common Interface Define related changes" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / Size.cs
1 namespace Dali
2 {
3   using System;
4
5   public class Size
6   {
7     private float width;
8     private float height;
9
10     /**
11      * @brief constructor
12      *
13      * @since 1.0.0
14      * @param [in] a Width value .
15      * @param [in] b Height value.
16      */
17     public Size(float a, float b)
18     {
19       width = a;
20       height = b;
21     }
22     /**
23      * @brief default constructor
24      *
25      * @since 1.0.0
26      */
27     public Size()
28     {
29       width = 0.0f;
30       height = 0.0f;
31     }
32
33     /**
34      * @brief constructor with base class object
35      *
36      * @since 1.0.0
37      * @param [in] o The Vector2 with Width, Height values.
38      */
39     public Size(Vector2 o)
40     {
41       width = o.X;
42       height = o.Y;
43     }
44
45     /**
46      * @brief Copy constructor
47      *
48      * @since 1.0.0
49      * @param [in] o The Size having Width & Y.
50      */
51     public Size(Size a)
52     {
53       width = a.width;
54       height = a.height;
55     }
56
57     ///< name "W", type float (Size Width value)
58     //@since 1.0.0
59     public float W
60     {
61       get { return width; }
62       set { width = value; }
63     }
64
65     ///< name "H", type float (Size Height value)
66     //@since 1.0.0
67     public float H
68     {
69       get { return height; }
70       set { height = value; }
71     }
72
73     public float Width
74     {
75       get { return width; }
76       set { width = value; }
77     }
78
79     public float Height
80     {
81       get { return height; }
82       set { height = value; }
83     }
84
85     /**
86      * @brief operator+
87      *
88      * @since 1.0.0
89      * @param [in] l The Size to add.
90      * @param [in] r The Size to add
91      * @return A reference to this
92      */
93     public static Size operator +(Size l, Size r)
94     {
95       return new Size(l.W + r.W, l.H + r.H);
96     }
97
98     /**
99      * @brief operator-
100      *
101      * @since 1.0.0
102      * @param [in] l The Size to substract.
103      * @param [in] r The Size to substract
104      * @return A reference to this
105      */
106     public static Size operator -(Size l, Size r)
107     {
108       return new Size(l.W - r.W, l.H - r.H);
109     }
110
111     /**
112      * @brief operator*
113      *
114      * @since 1.0.0
115      * @param [in] a The Size to multiply
116      * @param [in] b The constant to multiply of type double.
117      * @return A reference to this
118      */
119     public static Size operator *(Size a, double b)
120     {
121       return new Size((float)(a.W * b), (float)(a.H * b));
122     }
123
124     /**
125      * @brief operator/
126      *
127      * @since 1.0.0
128      * @param [in] a The Size to divide.
129      * @param [in] b The Size to divide
130      * @return float of the size division
131      */
132     public static float operator /(Size a, Size b)
133     {
134       return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H));
135     }
136
137     /**
138      * @brief Operator ==
139      *
140      * @since 1.0.0
141      * @param [in] a The Size object to compare.
142      * @param [in] b The Size object to compare.
143      * @return bool, whether Size are equal or not
144      */
145     public static bool operator == (Size a, Size b)
146     {
147       return a.W == b.W && a.H == b.H ;
148     }
149
150     /**
151      * @brief Operator !=
152      *
153      * @since 1.0.0
154      * @param [in] a The Size object to compare.
155      * @param [in] b The Size object to compare.
156      * @return bool, whether Size are equal or not
157      */
158     public static bool operator != (Size a, Size b)
159     {
160       return a.W != b.W || a.H != b.H;
161     }
162
163     /**
164      * @brief GetHashCode
165      *
166      * @since 1.0.0
167      * @return int, hascode of Size
168      */
169     public override int GetHashCode()
170     {
171       return (int)(W + H);
172     }
173
174     /**
175      * @brief Clone
176      *
177      * @since 1.0.0
178      * @return returns a copy of Size object
179      */
180     public Size Clone()
181     {
182       Size copy = new Size(W, H);
183       return copy;
184     }
185
186     // User-defined conversion from Position to Vector2
187     public static implicit operator Vector2(Size size)
188     {
189       return new Vector2(size.width, size.height);
190     }
191
192     public static implicit operator Size(Vector2 vec)
193     {
194       return new Size(vec.X, vec.Y);
195     }
196   }
197
198   public class Size3D
199   {
200     private float width;
201     private float height;
202     private float depth;
203
204     public Size3D(float a, float b, float c)
205     {
206       width = a;
207       height = b;
208       depth = c;
209     }
210
211     public Size3D()
212     {
213       width = 0.0f;
214       height = 0.0f;
215       depth = 0.0f;
216     }
217
218     public Size3D(Vector3 o)
219     {
220       width = o.X;
221       height = o.Y;
222       depth = o.Z;
223     }
224
225     public Size3D(Vector2 o)
226     {
227       width = o.X;
228       height = o.Y;
229       depth = 0.0f;
230     }
231
232     public Size3D(Size3D a)
233     {
234       width = a.width;
235       height = a.height;
236       depth = a.depth;
237     }
238
239     public float W
240     {
241       get { return width; }
242       set { width = value; }
243     }
244
245     public float H
246     {
247       get { return height; }
248       set { height = value; }
249     }
250
251     public float D
252     {
253       get { return depth; }
254       set { depth = value; }
255     }
256
257     public float Width
258     {
259       get { return width; }
260       set { width = value; }
261     }
262
263     public float Height
264     {
265       get { return height; }
266       set { height = value; }
267     }
268
269     public float Depth
270     {
271       get { return depth; }
272       set { depth = value; }
273     }
274
275     public float X
276     {
277       get { return width; }
278       set { width = value; }
279     }
280
281     public float Y
282     {
283       get { return height; }
284       set { height = value; }
285     }
286
287     public float Z
288     {
289       get { return depth; }
290       set { depth = value; }
291     }
292
293     // User-defined conversion from Position to Vector3
294     public static implicit operator Vector3(Size3D size)
295     {
296       return new Vector3(size.width, size.height, size.depth);
297     }
298
299     public static implicit operator Size3D(Vector3 vec)
300     {
301       return new Size3D(vec.X, vec.Y, vec.Z);
302     }
303
304   }
305
306 }