Combined Stage and Window class, and removed Stage class
[platform/core/uifw/dali-toolkit.git] / plugins / dali-sharp / sharp / 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 namespace Dali {
19
20 public class Size : global::System.IDisposable {
21   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
22   protected bool swigCMemOwn;
23
24   internal Size(global::System.IntPtr cPtr, bool cMemoryOwn) {
25     swigCMemOwn = cMemoryOwn;
26     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27   }
28
29   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj) {
30     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
31   }
32
33   ~Size() {
34     DisposeQueue.Instance.Add(this);
35   }
36
37   public virtual void Dispose() {
38     if (!Window.IsInstalled()) {
39       DisposeQueue.Instance.Add(this);
40       return;
41     }
42
43     lock(this) {
44       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
45         if (swigCMemOwn) {
46           swigCMemOwn = false;
47           NDalicPINVOKE.delete_Vector3(swigCPtr);
48         }
49         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
50       }
51       global::System.GC.SuppressFinalize(this);
52     }
53   }
54
55
56   public static Size operator+(Size arg1, Size arg2) {
57     return arg1.Add(arg2);
58   }
59
60   public static Size operator-(Size arg1, Size arg2) {
61     return arg1.Subtract(arg2);
62   }
63
64   public static Size operator-(Size arg1) {
65     return arg1.Subtract();
66   }
67
68   public static Size operator*(Size arg1, Size arg2) {
69     return arg1.Multiply(arg2);
70   }
71
72   public static Size operator*(Size arg1, float arg2) {
73     return arg1.Multiply(arg2);
74   }
75
76   public static Size operator/(Size arg1, Size arg2) {
77     return arg1.Divide(arg2);
78   }
79
80   public static Size operator/(Size arg1, float arg2) {
81     return arg1.Divide(arg2);
82   }
83
84   public float this[uint index]
85   {
86     get
87     {
88       return ValueOfIndex(index);
89     }
90   }
91
92   public static Size GetSizeFromPtr(global::System.IntPtr cPtr) {
93     Size ret = new Size(cPtr, false);
94     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95        return ret;
96   }
97
98
99   public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true) {
100     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101   }
102
103   public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true) {
104     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105   }
106
107   public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true) {
108     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109   }
110
111
112   public static Size Zero {
113     get {
114       global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
115       Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
116       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117       return ret;
118     }
119   }
120
121   private Size Add(Size rhs) {
122     Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
123     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124     return ret;
125   }
126
127   private Size Subtract(Size rhs) {
128     Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
129     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130     return ret;
131   }
132
133   private Size Multiply(Size rhs) {
134     Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
135     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136     return ret;
137   }
138
139   private Size Multiply(float rhs) {
140     Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
141     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142     return ret;
143   }
144
145   private Size Divide(Size rhs) {
146     Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
147     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148     return ret;
149   }
150
151   private Size Divide(float rhs) {
152     Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
153     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154     return ret;
155   }
156
157   private Size Subtract() {
158     Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
159     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160     return ret;
161   }
162
163   private float ValueOfIndex(uint index) {
164     float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
165     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166     return ret;
167   }
168
169   public bool EqualTo(Size rhs) {
170     bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
171     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172     return ret;
173   }
174
175   public bool NotEqualTo(Size rhs) {
176     bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
177     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178     return ret;
179   }
180
181
182   public float Width {
183     set {
184       NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
185       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186     }
187     get {
188       float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
189       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190       return ret;
191     }
192   }
193
194   public float Height {
195     set {
196       NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
197       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198     }
199     get {
200       float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
201       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202       return ret;
203     }
204   }
205
206   public float Depth {
207     set {
208       NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
209       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210     }
211     get {
212       float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
213       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214       return ret;
215     }
216   }
217
218
219   public static implicit operator Vector3(Size size)
220   {
221     return new Vector3(size.Width, size.Height, size.Depth);
222   }
223
224   public static implicit operator Size(Vector3 vec)
225   {
226     return new Size(vec.Width, vec.Height, vec.Depth);
227   }
228
229 }
230
231 }
232