Merge "Add LICENSE.BSD-3-Clause file" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-sharp / sharp / internal / Layer.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Dali
18 {
19
20     public class Layer : Animatable
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23
24         internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
25         {
26             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27         }
28
29         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
30         {
31             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
32         }
33
34         ~Layer()
35         {
36             DisposeQueue.Instance.Add(this);
37         }
38
39         public virtual void Dispose()
40         {
41             if (!Stage.IsInstalled())
42             {
43                 DisposeQueue.Instance.Add(this);
44                 return;
45             }
46
47             lock (this)
48             {
49                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
50                 {
51                     if (swigCMemOwn)
52                     {
53                         swigCMemOwn = false;
54                         NDalicPINVOKE.delete_Layer(swigCPtr);
55                     }
56                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
57                 }
58                 global::System.GC.SuppressFinalize(this);
59             }
60         }
61
62
63         public class Property : global::System.IDisposable
64         {
65             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
66             protected bool swigCMemOwn;
67
68             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
69             {
70                 swigCMemOwn = cMemoryOwn;
71                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
72             }
73
74             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
75             {
76                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
77             }
78
79             ~Property()
80             {
81                 Dispose();
82             }
83
84             public virtual void Dispose()
85             {
86                 lock (this)
87                 {
88                     if (swigCPtr.Handle != global::System.IntPtr.Zero)
89                     {
90                         if (swigCMemOwn)
91                         {
92                             swigCMemOwn = false;
93                             NDalicPINVOKE.delete_Layer_Property(swigCPtr);
94                         }
95                         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
96                     }
97                     global::System.GC.SuppressFinalize(this);
98                 }
99             }
100
101             public Property() : this(NDalicPINVOKE.new_Layer_Property(), true)
102             {
103                 if (NDalicPINVOKE.SWIGPendingException.Pending)
104                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105             }
106
107             public static readonly int CLIPPING_ENABLE = NDalicPINVOKE.Layer_Property_CLIPPING_ENABLE_get();
108             public static readonly int CLIPPING_BOX = NDalicPINVOKE.Layer_Property_CLIPPING_BOX_get();
109             public static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
110
111         }
112
113         public Layer() : this(NDalicPINVOKE.Layer_New(), true)
114         {
115             if (NDalicPINVOKE.SWIGPendingException.Pending)
116                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117
118         }
119
120         public new static Layer DownCast(BaseHandle handle)
121         {
122             Layer ret = new Layer(NDalicPINVOKE.Layer_DownCast(BaseHandle.getCPtr(handle)), true);
123             if (NDalicPINVOKE.SWIGPendingException.Pending)
124                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         public Layer(Layer copy) : this(NDalicPINVOKE.new_Layer__SWIG_1(Layer.getCPtr(copy)), true)
129         {
130             if (NDalicPINVOKE.SWIGPendingException.Pending)
131                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132         }
133
134         public Layer Assign(Layer rhs)
135         {
136             Layer ret = new Layer(NDalicPINVOKE.Layer_Assign(swigCPtr, Layer.getCPtr(rhs)), false);
137             if (NDalicPINVOKE.SWIGPendingException.Pending)
138                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139             return ret;
140         }
141
142         public View FindChildById(uint id)
143         {
144             View ret = new View(NDalicPINVOKE.Actor_FindChildById(swigCPtr, id), true);
145             if (NDalicPINVOKE.SWIGPendingException.Pending)
146                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             return ret;
148         }
149
150         public void Add(View child)
151         {
152             NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
153             if (NDalicPINVOKE.SWIGPendingException.Pending)
154                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155         }
156
157         public void Remove(View child)
158         {
159             NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
160             if (NDalicPINVOKE.SWIGPendingException.Pending)
161                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162         }
163
164         public uint GetDepth()
165         {
166             uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
167             if (NDalicPINVOKE.SWIGPendingException.Pending)
168                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169             return ret;
170         }
171
172         public void Raise()
173         {
174             NDalicPINVOKE.Layer_Raise(swigCPtr);
175             if (NDalicPINVOKE.SWIGPendingException.Pending)
176                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177         }
178
179         public void Lower()
180         {
181             NDalicPINVOKE.Layer_Lower(swigCPtr);
182             if (NDalicPINVOKE.SWIGPendingException.Pending)
183                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184         }
185
186         public void RaiseAbove(Layer target)
187         {
188             NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
189             if (NDalicPINVOKE.SWIGPendingException.Pending)
190                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191         }
192
193         public void LowerBelow(Layer target)
194         {
195             NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
196             if (NDalicPINVOKE.SWIGPendingException.Pending)
197                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198         }
199
200         public void RaiseToTop()
201         {
202             NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
203             if (NDalicPINVOKE.SWIGPendingException.Pending)
204                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205         }
206
207         public void LowerToBottom()
208         {
209             NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
210             if (NDalicPINVOKE.SWIGPendingException.Pending)
211                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212         }
213
214         public void MoveAbove(Layer target)
215         {
216             NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
217             if (NDalicPINVOKE.SWIGPendingException.Pending)
218                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219         }
220
221         public void MoveBelow(Layer target)
222         {
223             NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
224             if (NDalicPINVOKE.SWIGPendingException.Pending)
225                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226         }
227
228         public void SetBehavior(Layer.LayerBehavior behavior)
229         {
230             NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
231             if (NDalicPINVOKE.SWIGPendingException.Pending)
232                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233         }
234
235         public Layer.LayerBehavior GetBehavior()
236         {
237             Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
238             if (NDalicPINVOKE.SWIGPendingException.Pending)
239                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             return ret;
241         }
242
243         public void SetClipping(bool enabled)
244         {
245             NDalicPINVOKE.Layer_SetClipping(swigCPtr, enabled);
246             if (NDalicPINVOKE.SWIGPendingException.Pending)
247                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248         }
249
250         public bool IsClipping()
251         {
252             bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
253             if (NDalicPINVOKE.SWIGPendingException.Pending)
254                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255             return ret;
256         }
257
258         public void SetClippingBox(int x, int y, int width, int height)
259         {
260             NDalicPINVOKE.Layer_SetClippingBox__SWIG_0(swigCPtr, x, y, width, height);
261             if (NDalicPINVOKE.SWIGPendingException.Pending)
262                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263         }
264
265         public void SetClippingBox(Rectangle box)
266         {
267             NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(box));
268             if (NDalicPINVOKE.SWIGPendingException.Pending)
269                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270         }
271
272         public Rectangle GetClippingBox()
273         {
274             Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
275             if (NDalicPINVOKE.SWIGPendingException.Pending)
276                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277             return ret;
278         }
279
280         public void SetDepthTestDisabled(bool disable)
281         {
282             NDalicPINVOKE.Layer_SetDepthTestDisabled(swigCPtr, disable);
283             if (NDalicPINVOKE.SWIGPendingException.Pending)
284                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285         }
286
287         public bool IsDepthTestDisabled()
288         {
289             bool ret = NDalicPINVOKE.Layer_IsDepthTestDisabled(swigCPtr);
290             if (NDalicPINVOKE.SWIGPendingException.Pending)
291                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292             return ret;
293         }
294
295         public void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
296         {
297             NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
298             if (NDalicPINVOKE.SWIGPendingException.Pending)
299                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300         }
301
302         public void SetTouchConsumed(bool consume)
303         {
304             NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
305             if (NDalicPINVOKE.SWIGPendingException.Pending)
306                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307         }
308
309         public bool IsTouchConsumed()
310         {
311             bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
312             if (NDalicPINVOKE.SWIGPendingException.Pending)
313                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314             return ret;
315         }
316
317         public void SetHoverConsumed(bool consume)
318         {
319             NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
320             if (NDalicPINVOKE.SWIGPendingException.Pending)
321                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322         }
323
324         public bool IsHoverConsumed()
325         {
326             bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
327             if (NDalicPINVOKE.SWIGPendingException.Pending)
328                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329             return ret;
330         }
331
332         public enum LayerBehavior
333         {
334             LAYER_2D,
335             LAYER_UI = LAYER_2D,
336             LAYER_3D
337         }
338
339         public enum TreeDepthMultiplier
340         {
341             TREE_DEPTH_MULTIPLIER = 10000
342         }
343
344         public bool ClippingEnable
345         {
346             get
347             {
348                 bool temp = false;
349                 GetProperty(Layer.Property.CLIPPING_ENABLE).Get(ref temp);
350                 return temp;
351             }
352             set
353             {
354                 SetProperty(Layer.Property.CLIPPING_ENABLE, new Dali.Property.Value(value));
355             }
356         }
357
358         public Rectangle ClippingBox
359         {
360             get
361             {
362                 Rectangle temp = new Rectangle(0, 0, 0, 0);
363                 GetProperty(Layer.Property.CLIPPING_BOX).Get(temp);
364                 return temp;
365             }
366             set
367             {
368                 SetProperty(Layer.Property.CLIPPING_BOX, new Dali.Property.Value(value));
369             }
370         }
371
372         public Layer.LayerBehavior Behavior
373         {
374             get
375             {
376                 return GetBehavior();
377             }
378             set
379             {
380                 SetBehavior(value);
381             }
382         }
383
384     }
385
386 }