1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using Tizen.NUI.BaseComponents;
22 /// Layers provide a mechanism for overlaying groups of actors on top of each other.
24 public class Layer : Animatable
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
52 //Release your own unmanaged resources here.
53 //You should not access any managed member here except static instance.
54 //because the execution order of Finalizes is non-deterministic.
56 if (swigCPtr.Handle != global::System.IntPtr.Zero)
61 NDalicPINVOKE.delete_Layer(swigCPtr);
63 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70 internal class Property
72 internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
76 /// Creates a Layer object.
78 public Layer() : this(NDalicPINVOKE.Layer_New(), true)
80 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 /// Downcasts a handle to Layer handle.<br>
85 /// If handle points to a Layer, the downcast produces valid handle.<br>
86 /// If not, the returned handle is left uninitialized.<br>
88 /// <param name="handle">Handle to an object</param>
89 /// <returns>Handle to a Layer or an uninitialized handle</returns>
90 internal new static Layer DownCast(BaseHandle handle)
92 Layer ret = new Layer(NDalicPINVOKE.Layer_DownCast(BaseHandle.getCPtr(handle)), true);
93 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 /// Search through this layer's hierarchy for an view with the given unique ID.
100 /// <pre>This layer(the parent) has been initialized.</pre>
101 /// <remarks>The actor itself is also considered in the search.</remarks>
102 /// <param name="child">The id of the child to find</param>
103 /// <returns> A handle to the view if found, or an empty handle if not. </returns>
104 public View FindChildById(uint id)
106 View ret = new View(NDalicPINVOKE.Actor_FindChildById(swigCPtr, id), true);
107 if (NDalicPINVOKE.SWIGPendingException.Pending)
108 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// Adds a child view to this layer.
115 /// <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>
116 /// <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>
117 /// <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>
118 /// <param name="child">The child</param>
119 public void Add(View child)
121 NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
122 if (NDalicPINVOKE.SWIGPendingException.Pending)
123 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 /// Removes a child View from this layer. If the view was not a child of this layer, this is a no-op.
129 /// <pre>This layer(the parent) has been initialized. The child view is not the same as the parent view.</pre>
130 /// <param name="child">The child</param>
131 public void Remove(View child)
133 NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
134 if (NDalicPINVOKE.SWIGPendingException.Pending)
135 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 /// Queries the depth of the layer.<br>
140 /// 0 is the bottom most layer, higher number is on top.<br>
150 internal uint GetDepth()
152 uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 /// Increments the depth of the layer.
162 NDalicPINVOKE.Layer_Raise(swigCPtr);
163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// Decrements the depth of the layer.
171 NDalicPINVOKE.Layer_Lower(swigCPtr);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 internal void RaiseAbove(Layer target)
177 NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 internal void LowerBelow(Layer target)
183 NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 /// Raises the layer to the top.
190 public void RaiseToTop()
192 NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// Lowers the layer to the bottom.
199 public void LowerToBottom()
201 NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 /// Moves the layer directly above the given layer.<br>
207 /// After the call, this layers depth will be immediately above target.<br>
209 /// <param name="target">Layer to get on top of</param>
210 public void MoveAbove(Layer target)
212 NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Moves the layer directly below the given layer.<br>
218 /// After the call, this layers depth will be immediately below target.<br>
220 /// <param name="target">Layer to get below of</param>
221 public void MoveBelow(Layer target)
223 NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 private void SetBehavior(LayerBehavior behavior)
229 NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 private LayerBehavior GetBehavior()
235 Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240 internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
242 NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
243 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 internal void SetTouchConsumed(bool consume)
248 NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 internal bool IsTouchConsumed()
254 bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
255 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259 internal void SetHoverConsumed(bool consume)
261 NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 internal bool IsHoverConsumed()
267 bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 /// Retrieves child view by index.
275 /// <pre>The View has been initialized.</pre>
276 /// <param name="index">The index of the child to retrieve</param>
277 /// <returns>The view for the given index or empty handle if children not initialized</returns>
278 public View GetChildAt(uint index)
280 System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
281 cPtr = NDalicPINVOKE.View_SWIGUpcast(cPtr);
282 cPtr = NDalicPINVOKE.Handle_SWIGUpcast(cPtr);
284 BaseHandle ret = new BaseHandle(cPtr, false);
286 View temp = ViewRegistry.GetViewFromBaseHandle(ret);
288 if (NDalicPINVOKE.SWIGPendingException.Pending)
289 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 /// Enumeration for the behavior of the layer.
297 public enum LayerBehavior
304 internal enum TreeDepthMultiplier
306 TREE_DEPTH_MULTIPLIER = 10000
310 /// Layer Behavior, type String(Layer.LayerBehavior)
312 public Layer.LayerBehavior Behavior
316 return GetBehavior();
325 /// Retrieves and sets the Layer's opacity.<br>
332 GetProperty(View.Property.OPACITY).Get(out temp);
337 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
342 /// Retrieves and sets the Layer's visibility.
344 public bool Visibility
349 GetProperty(View.Property.VISIBLE).Get(out temp);
354 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
359 /// Get the number of children held by the layer.
361 public uint ChildCount
365 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
366 if (NDalicPINVOKE.SWIGPendingException.Pending)
367 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 /// Gets/Sets the Layer's name.
\r
387 internal string GetName()
\r
389 string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
\r
390 if (NDalicPINVOKE.SWIGPendingException.Pending)
\r
391 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
\r
395 internal void SetName(string name)
\r
397 NDalicPINVOKE.Actor_SetName(swigCPtr, name);
\r
398 if (NDalicPINVOKE.SWIGPendingException.Pending)
\r
399 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
\r