Merge "DALi C# binding - Write pure C# Color & Position classes and use typemaps...
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / Size.cs
1 namespace Dali {
2   namespace CSharp {
3     using System;
4
5     public class Size {
6       public float[] v;
7
8       /**
9        * @brief default constructor
10        *
11        * @since 1.0.0
12        */
13       public Size()
14       {
15         v = new float[2];
16       }
17
18       /**
19        * @brief constructor
20        *
21        * @since 1.0.0
22        * @param [in] a Width value .
23        * @param [in] b Height value.
24        */
25       public Size(float a, float b):this()
26       {
27         v[0] = a;
28         v[1] = b;
29       }
30
31       /**
32        * @brief constructor with vector2 class object
33        *
34        * @since 1.0.0
35        * @param [in] o The Vector2 with Width, Height values.
36        */
37       public Size(Vector2 o)
38         : this(o.x, o.y)
39       {
40       }
41
42       /**
43        * @brief Copy constructor
44        *
45        * @since 1.0.0
46        * @param [in] o The Size having Width & Y.
47        */
48       public Size(Size a)
49         : this(a.v[0], a.v[1])
50       {
51       }
52
53       ///< name "W", type float (Size Width value)
54       //@since 1.0.0
55       public float W
56       {
57         get { return v[0]; }
58         set { v[0] = value; }
59       }
60
61       ///< name "H", type float (Size Height value)
62       //@since 1.0.0
63       public float H
64       {
65         get { return v[1]; }
66         set { v[1] = value; }
67       }
68
69       /**
70        * @brief operator+
71        *
72        * @since 1.0.0
73        * @param [in] l The Size to add.
74        * @param [in] r The Size to add
75        * @return A reference to this
76        */
77       public static Size operator +(Size l, Size r)
78       {
79         return new Size(l.W + r.W, l.H + r.H);
80       }
81
82       /**
83        * @brief operator-
84        *
85        * @since 1.0.0
86        * @param [in] l The Size to substract.
87        * @param [in] r The Size to substract
88        * @return A reference to this
89        */
90       public static Size operator -(Size l, Size r)
91       {
92         return new Size(l.W - r.W, l.H - r.H);
93       }
94
95       /**
96        * @brief operator*
97        *
98        * @since 1.0.0
99        * @param [in] a The Size to multiply
100        * @param [in] b The Size to multiply
101        * @return A reference to this
102        */
103       public static Size operator *(Size a, double b)
104       {
105         return new Size((float)(a.W * b), (float)(a.H * b));
106       }
107
108       /**
109        * @brief operator/
110        *
111        * @since 1.0.0
112        * @param [in] a The Size to divide.
113        * @param [in] b The Size to divide
114        * @return float of the size division
115        */
116       public static float operator /(Size a, Size b)
117       {
118         return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H));
119       }
120
121       /**
122        * @brief Equals
123        *
124        * @since 1.0.0
125        * @param [in] obj The Size object to compare.
126        * @return bool, whether object equal or not
127        */
128       public override bool Equals(object obj)
129       {
130         Size that = obj as Size;
131         if (that == null)
132         {
133           return false;
134         }
135         return this.W == that.W && this.H == that.H;
136       }
137
138
139       /**
140        * @brief Clone
141        *
142        * @since 1.0.0
143        * @return returns a copy of Size object
144        */
145       public Size Clone()
146       {
147         Size copy = new Size(W, H);
148         return copy;
149       }
150     }
151   }
152 }