Revert "[Tizen] keep old APIs to avoid build error"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Layer.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.\r
2 *\r
3 * Licensed under the Apache License, Version 2.0 (the "License");\r
4 * you may not use this file except in compliance with the License.\r
5 * You may obtain a copy of the License at\r
6 *\r
7 * http://www.apache.org/licenses/LICENSE-2.0\r
8 *\r
9 * Unless required by applicable law or agreed to in writing, software\r
10 * distributed under the License is distributed on an "AS IS" BASIS,\r
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 * See the License for the specific language governing permissions and\r
13 * limitations under the License.\r
14 *\r
15 */\r
16 \r
17 namespace Tizen.NUI\r
18 {\r
19     using Tizen.NUI.BaseComponents;\r
20 \r
21     /// <summary>\r
22     /// Layers provide a mechanism for overlaying groups of actors on top of each other.\r
23     /// </summary>\r
24     public class Layer : Animatable\r
25     {\r
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;\r
27 \r
28         internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)\r
29         {\r
30             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);\r
31         }\r
32 \r
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)\r
34         {\r
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;\r
36         }\r
37 \r
38         protected override void Dispose(DisposeTypes type)\r
39         {\r
40             if (disposed)\r
41             {\r
42                 return;\r
43             }\r
44 \r
45             if (type == DisposeTypes.Explicit)\r
46             {\r
47                 //Called by User\r
48                 //Release your own managed resources here.\r
49                 //You should release all of your own disposable objects here.\r
50             }\r
51 \r
52             //Release your own unmanaged resources here.\r
53             //You should not access any managed member here except static instance.\r
54             //because the execution order of Finalizes is non-deterministic.\r
55 \r
56             if (swigCPtr.Handle != global::System.IntPtr.Zero)\r
57             {\r
58                 if (swigCMemOwn)\r
59                 {\r
60                     swigCMemOwn = false;\r
61                     NDalicPINVOKE.delete_Layer(swigCPtr);\r
62                 }\r
63                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);\r
64             }\r
65 \r
66             base.Dispose(type);\r
67         }\r
68 \r
69 \r
70         internal class Property\r
71         {\r
72             internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();\r
73         }\r
74 \r
75         /// <summary>\r
76         /// Creates a Layer object.\r
77         /// </summary>\r
78         public Layer() : this(NDalicPINVOKE.Layer_New(), true)\r
79         {\r
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
81 \r
82         }\r
83         /// <summary>
84         /// this method will be changed as internal method on later release
85         /// </summary>
86         public new static Layer DownCast(BaseHandle handle)\r
87         {\r
88             Layer ret = new Layer(NDalicPINVOKE.Layer_DownCast(BaseHandle.getCPtr(handle)), true);\r
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
90             return ret;\r
91         }\r
92 \r
93         /// <summary>\r
94         /// Search through this layer's hierarchy for an view with the given unique ID.\r
95         /// </summary>\r
96         /// <pre>This layer(the parent) has been initialized.</pre>\r
97         /// <remarks>The actor itself is also considered in the search.</remarks>\r
98         /// <param name="child">The id of the child to find</param>\r
99         /// <returns> A handle to the view if found, or an empty handle if not. </returns>\r
100         public View FindChildById(uint id)\r
101         {\r
102             View ret = new View(NDalicPINVOKE.Actor_FindChildById(swigCPtr, id), true);\r
103             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
104                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
105             return ret;\r
106         }\r
107 \r
108         /// <summary>\r
109         /// Adds a child view to this layer.\r
110         /// </summary>\r
111         /// <pre>This layer(the parent) has been initialized. The child view has been initialized. The child view is not the same as the parent layer.</pre>\r
112         /// <post>The child will be referenced by its parent. This means that the child will be kept alive, even if the handle passed into this method is reset or destroyed.</post>\r
113         /// <remarks>If the child already has a parent, it will be removed from old parent and reparented to this layer. This may change child's position, color, scale etc as it now inherits them from this layer.</remarks>\r
114         /// <param name="child">The child</param>\r
115         public void Add(View child)\r
116         {\r
117             NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));\r
118             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
119                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
120         }\r
121 \r
122         /// <summary>\r
123         /// Removes a child View from this layer. If the view was not a child of this layer, this is a no-op.\r
124         /// </summary>\r
125         /// <pre>This layer(the parent) has been initialized. The child view is not the same as the parent view.</pre>\r
126         /// <param name="child">The child</param>\r
127         public void Remove(View child)\r
128         {\r
129             NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));\r
130             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
131                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
132         }\r
133 \r
134         /// <summary>\r
135         /// Queries the depth of the layer.<br>\r
136         /// 0 is the bottom most layer, higher number is on top.<br>\r
137         /// </summary>\r
138         public uint Depth\r
139         {\r
140             get\r
141             {\r
142                 return GetDepth();\r
143             }\r
144         }\r
145 \r
146         internal uint GetDepth()\r
147         {\r
148             uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);\r
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
150             return ret;\r
151         }\r
152 \r
153         /// <summary>\r
154         /// Increments the depth of the layer.\r
155         /// </summary>\r
156         public void Raise()\r
157         {\r
158             NDalicPINVOKE.Layer_Raise(swigCPtr);\r
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
160         }\r
161 \r
162         /// <summary>\r
163         /// Decrements the depth of the layer.\r
164         /// </summary>\r
165         public void Lower()\r
166         {\r
167             NDalicPINVOKE.Layer_Lower(swigCPtr);\r
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
169         }\r
170 \r
171         internal void RaiseAbove(Layer target)\r
172         {\r
173             NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));\r
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
175         }\r
176 \r
177         internal void LowerBelow(Layer target)\r
178         {\r
179             NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));\r
180             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
181         }\r
182 \r
183         /// <summary>\r
184         /// Raises the layer to the top.\r
185         /// </summary>\r
186         public void RaiseToTop()\r
187         {\r
188             NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);\r
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
190         }\r
191 \r
192         /// <summary>\r
193         /// Lowers the layer to the bottom.\r
194         /// </summary>\r
195         public void LowerToBottom()\r
196         {\r
197             NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);\r
198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
199         }\r
200 \r
201         /// <summary>\r
202         /// Moves the layer directly above the given layer.<br>\r
203         /// After the call, this layers depth will be immediately above target.<br>\r
204         /// </summary>\r
205         /// <param name="target">Layer to get on top of</param>\r
206         public void MoveAbove(Layer target)\r
207         {\r
208             NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));\r
209             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
210         }\r
211 \r
212         /// <summary>\r
213         /// Moves the layer directly below the given layer.<br>\r
214         /// After the call, this layers depth will be immediately below target.<br>\r
215         /// </summary>\r
216         /// <param name="target">Layer to get below of</param>\r
217         public void MoveBelow(Layer target)\r
218         {\r
219             NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));\r
220             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
221         }\r
222 \r
223         private void SetBehavior(LayerBehavior behavior)\r
224         {\r
225             NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);\r
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
227         }\r
228 \r
229         private LayerBehavior GetBehavior()\r
230         {\r
231             Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);\r
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
233             return ret;\r
234         }\r
235 \r
236         internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)\r
237         {\r
238             NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));\r
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
240         }\r
241 \r
242         internal void SetTouchConsumed(bool consume)\r
243         {\r
244             NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);\r
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
246         }\r
247 \r
248         internal bool IsTouchConsumed()\r
249         {\r
250             bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);\r
251             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
252             return ret;\r
253         }\r
254 \r
255         internal void SetHoverConsumed(bool consume)\r
256         {\r
257             NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);\r
258             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
259         }\r
260 \r
261         internal bool IsHoverConsumed()\r
262         {\r
263             bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);\r
264             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
265             return ret;\r
266         }\r
267 \r
268         /// <summary>\r
269         /// Retrieves child view by index.\r
270         /// </summary>\r
271         /// <pre>The View has been initialized.</pre>\r
272         /// <param name="index">The index of the child to retrieve</param>\r
273         /// <returns>The view for the given index or empty handle if children not initialized</returns>\r
274         public View GetChildAt(uint index)\r
275         {\r
276             System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);\r
277             cPtr = NDalicPINVOKE.View_SWIGUpcast(cPtr);\r
278             cPtr = NDalicPINVOKE.Handle_SWIGUpcast(cPtr);\r
279 \r
280             BaseHandle ret = new BaseHandle(cPtr, false);\r
281 \r
282             View temp = ViewRegistry.GetViewFromBaseHandle(ret);\r
283 \r
284             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
285                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
286 \r
287             return temp ?? null;\r
288         }\r
289 \r
290         /// <summary>\r
291         /// Enumeration for the behavior of the layer.\r
292         /// </summary>\r
293         public enum LayerBehavior\r
294         {\r
295             Layer2D,\r
296             LayerUI = Layer2D,\r
297             Layer3D\r
298         }\r
299 \r
300         internal enum TreeDepthMultiplier\r
301         {\r
302             TREE_DEPTH_MULTIPLIER = 10000\r
303         }\r
304 \r
305         /// <summary>\r
306         /// Layer Behavior, type String(Layer.LayerBehavior)\r
307         /// </summary>\r
308         public Layer.LayerBehavior Behavior\r
309         {\r
310             get\r
311             {\r
312                 return GetBehavior();\r
313             }\r
314             set\r
315             {\r
316                 SetBehavior(value);\r
317             }\r
318         }\r
319 \r
320         /// <summary>\r
321         /// Retrieves and sets the Layer's opacity.<br>\r
322         /// </summary>\r
323         public float Opacity\r
324         {\r
325             get\r
326             {\r
327                 float temp = 0.0f;\r
328                 GetProperty(View.Property.OPACITY).Get(out temp);\r
329                 return temp;\r
330             }\r
331             set\r
332             {\r
333                 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));\r
334             }\r
335         }\r
336 \r
337         /// <summary>\r
338         /// Retrieves and sets the Layer's visibility.\r
339         /// </summary>\r
340         public bool Visibility\r
341         {\r
342             get\r
343             {\r
344                 bool temp = false;\r
345                 GetProperty(View.Property.VISIBLE).Get(out temp);\r
346                 return temp;\r
347             }\r
348             set\r
349             {\r
350                 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));\r
351             }\r
352         }\r
353 \r
354         /// <summary>\r
355         /// Get the number of children held by the layer.\r
356         /// </summary>\r
357         public uint ChildCount\r
358         {\r
359             get\r
360             {\r
361                 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);\r
362                 if (NDalicPINVOKE.SWIGPendingException.Pending)\r
363                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
364                 return ret;\r
365             }\r
366         }\r
367 \r
368         /// <summary>\r
369         /// Gets/Sets the Layer's name.\r
370         /// </summary>\r
371         public string Name\r
372         {\r
373             get\r
374             {\r
375                 return GetName();\r
376             }\r
377             set\r
378             {\r
379                 SetName(value);\r
380             }\r
381         }\r
382 \r
383         internal string GetName()\r
384         {\r
385             string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);\r
386             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
387                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
388             return ret;\r
389         }\r
390 \r
391         internal void SetName(string name)\r
392         {\r
393             NDalicPINVOKE.Actor_SetName(swigCPtr, name);\r
394             if (NDalicPINVOKE.SWIGPendingException.Pending)\r
395                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
396         }\r
397     }\r
398 }\r