2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 using Tizen.NUI.BaseComponents;
24 /// Layers provide a mechanism for overlaying groups of actors on top of each other.
26 public class Layer : Container
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 /// From the Container base class.
43 /// Adds a child view to this layer.
45 /// <seealso cref="Container.Add">
47 /// <since_tizen> 4 </since_tizen>
48 public override void Add(View child)
50 NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
51 if (NDalicPINVOKE.SWIGPendingException.Pending)
52 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 /// Removes a child view from this layer. If the view was not a child of this layer, this is a no-op.
58 /// <seealso cref="Container.Remove">
60 /// <since_tizen> 4 </since_tizen>
61 public override void Remove(View child)
63 NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
64 if (NDalicPINVOKE.SWIGPendingException.Pending)
65 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 /// Retrieves a child view by the index.
71 /// <pre>The view has been initialized.</pre>
72 /// <param name="index">The index of the child to retrieve.</param>
73 /// <returns>The view for the given index or empty handle if children not initialized.</returns>
74 /// <since_tizen> 4 </since_tizen>
75 public override View GetChildAt(uint index)
77 System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
79 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
81 if (NDalicPINVOKE.SWIGPendingException.Pending)
82 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// Get parent of the layer.
90 /// <returns>The view's container</returns>
91 /// <since_tizen> 3 </since_tizen>
92 protected override Container GetParent()
98 /// Get the child count of the layer.
100 /// <returns>The child count of the layer.</returns>
101 /// <since_tizen> 3 </since_tizen>
102 protected override uint GetChildCount()
104 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
105 if (NDalicPINVOKE.SWIGPendingException.Pending)
106 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// <since_tizen> 3 </since_tizen>
114 protected override void Dispose(DisposeTypes type)
121 if(type == DisposeTypes.Explicit)
124 //Release your own managed resources here.
125 //You should release all of your own disposable objects here.
128 //Release your own unmanaged resources here.
129 //You should not access any managed member here except static instance.
130 //because the execution order of Finalizes is non-deterministic.
132 if (swigCPtr.Handle != global::System.IntPtr.Zero)
137 NDalicPINVOKE.delete_Layer(swigCPtr);
139 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
146 internal class Property
148 internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
152 /// Creates a Layer object.
154 /// <since_tizen> 3 </since_tizen>
155 public Layer() : this(NDalicPINVOKE.Layer_New(), true)
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 if(Window.Instance != null)
160 this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
161 this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
164 internal void SetAnchorPoint(Vector3 anchorPoint)
166 NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
167 if (NDalicPINVOKE.SWIGPendingException.Pending)
168 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
172 NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
173 if (NDalicPINVOKE.SWIGPendingException.Pending)
174 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// [Obsolete("Please do not use! this will be deprecated")]
181 /// <since_tizen> 3 </since_tizen>
182 [Obsolete("Please do not use! this will be deprecated")]
183 public static Layer DownCast(BaseHandle handle)
185 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Search through this layer's hierarchy for a view with the given unique ID.
193 /// <pre>This layer (the parent) has been initialized.</pre>
194 /// <remarks>The actor itself is also considered in the search.</remarks>
195 /// <param name="id">The id of the child to find</param>
196 /// <returns> A handle to the view if found, or an empty handle if not. </returns>
197 /// <since_tizen> 3 </since_tizen>
198 public View FindChildById(uint id)
200 IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
201 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
203 if (NDalicPINVOKE.SWIGPendingException.Pending)
204 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209 /// Queries the depth of the layer.<br />
210 /// 0 is the bottommost layer, higher number is on the top.<br />
212 /// <since_tizen> 3 </since_tizen>
221 internal uint GetDepth()
223 uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 /// Increments the depth of the layer.
231 /// <since_tizen> 3 </since_tizen>
234 NDalicPINVOKE.Layer_Raise(swigCPtr);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 /// Decrements the depth of the layer.
241 /// <since_tizen> 3 </since_tizen>
244 NDalicPINVOKE.Layer_Lower(swigCPtr);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248 internal void RaiseAbove(Layer target)
250 NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 internal void LowerBelow(Layer target)
256 NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// Raises the layer to the top.
263 /// <since_tizen> 3 </since_tizen>
264 public void RaiseToTop()
266 NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 /// Lowers the layer to the bottom.
273 /// <since_tizen> 3 </since_tizen>
274 public void LowerToBottom()
276 NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 /// Moves the layer directly above the given layer.<br />
282 /// After the call, this layer's depth will be immediately above target.<br />
284 /// <param name="target">The layer to get on top of.</param>
285 /// <since_tizen> 3 </since_tizen>
286 public void MoveAbove(Layer target)
288 NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293 /// Moves the layer directly below the given layer.<br />
294 /// After the call, this layer's depth will be immediately below target.<br />
296 /// <param name="target">The layer to get below of.</param>
297 /// <since_tizen> 3 </since_tizen>
298 public void MoveBelow(Layer target)
300 NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 private void SetBehavior(LayerBehavior behavior)
306 NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 private LayerBehavior GetBehavior()
312 Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
319 NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 internal void SetTouchConsumed(bool consume)
325 NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 internal bool IsTouchConsumed()
331 bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 internal void SetHoverConsumed(bool consume)
338 NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342 internal bool IsHoverConsumed()
344 bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 /// Enumeration for the behavior of the layer.
352 /// <since_tizen> 3 </since_tizen>
353 public enum LayerBehavior
356 /// UI control rendering mode.
358 /// <since_tizen> 3 </since_tizen>
361 /// UI control rendering mode (default mode).
362 /// This mode is designed for UI controls that can overlap. In this
363 /// mode renderer order will be respective to the tree hierarchy of
365 /// The rendering order is depth first, so for the following actor tree,
366 /// A will be drawn first, then B, D, E, then C, F. This ensures that
367 /// overlapping actors are drawn as expected (whereas, with breadth first
368 /// traversal, the actors would interleave).<br />
370 /// <since_tizen> 3 </since_tizen>
373 /// Layer will use depth test.
374 /// This mode is designed for a 3 dimensional scene where actors in front
375 /// of other actors will obscure them, i.e. the actors are sorted by the
376 /// distance from the camera.<br />
377 /// When using this mode, a depth test will be used. A depth clear will
378 /// happen for each layer, which means actors in a layer "above" other
379 /// layers will be rendered in front of actors in those layers regardless
380 /// of their Z positions (see Layer::Raise() and Layer::Lower()).<br />
381 /// Opaque renderers are drawn first and write to the depth buffer. Then
382 /// transparent renderers are drawn with depth test enabled but depth
383 /// write switched off. Transparent renderers are drawn based on their
384 /// distance from the camera. A renderer's DEPTH_INDEX property is used to
385 /// offset the distance to the camera when ordering transparent renderers.
386 /// This is useful if you want to define the draw order of two or more
387 /// transparent renderers that are equal distance from the camera. Unlike
388 /// LAYER_UI, parent-child relationship does not affect rendering order at
391 /// <since_tizen> 3 </since_tizen>
395 internal enum TreeDepthMultiplier
397 TREE_DEPTH_MULTIPLIER = 10000
401 /// Layer behavior, type String (Layer.LayerBehavior).
403 /// <since_tizen> 3 </since_tizen>
404 public Layer.LayerBehavior Behavior
408 return GetBehavior();
417 /// Internal only property to enable or disable clipping, type boolean.
418 /// By default, this is false, i.e., the viewport of the layer is the entire window.
420 internal bool ClippingEnabled
424 bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
431 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 /// Sets the viewport (in window coordinates), type rectangle.
437 /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
439 /// <since_tizen> 4 </since_tizen>
440 public Rectangle Viewport
444 if( ClippingEnabled )
446 Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 // Clipping not enabled so return the window size
453 Size2D windowSize = Window.Instance.Size;
454 Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
460 NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 ClippingEnabled = true;
467 /// Retrieves and sets the layer's opacity.<br />
469 /// <since_tizen> 3 </since_tizen>
475 GetProperty(View.Property.OPACITY).Get(out temp);
480 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
485 /// Retrieves and sets the layer's visibility.
487 /// <since_tizen> 3 </since_tizen>
488 public bool Visibility
493 GetProperty(View.Property.VISIBLE).Get(out temp);
498 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
503 /// Get the number of children held by the layer.
505 /// <since_tizen> 3 </since_tizen>
506 public new uint ChildCount
510 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
511 if (NDalicPINVOKE.SWIGPendingException.Pending)
512 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 /// Gets or sets the layer's name.
520 /// <since_tizen> 3 </since_tizen>
533 internal string GetName()
535 string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
536 if (NDalicPINVOKE.SWIGPendingException.Pending)
537 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541 internal void SetName(string name)
543 NDalicPINVOKE.Actor_SetName(swigCPtr, name);
544 if (NDalicPINVOKE.SWIGPendingException.Pending)
545 throw NDalicPINVOKE.SWIGPendingException.Retrieve();