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.
20 using Tizen.NUI.BaseComponents;
23 /// Layers provide a mechanism for overlaying groups of actors on top of each other.
25 public class Layer : Container
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 /// From the Container base class.
42 /// Adds a child view to this layer.
44 /// <seealso cref="Container.Add">
46 /// <since_tizen> 4 </since_tizen>
47 public override void Add(View child)
49 NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
50 if (NDalicPINVOKE.SWIGPendingException.Pending)
51 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55 /// Removes a child view from this layer. If the view was not a child of this layer, this is a no-op.
57 /// <seealso cref="Container.Remove">
59 /// <since_tizen> 4 </since_tizen>
60 public override void Remove(View child)
62 NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
63 if (NDalicPINVOKE.SWIGPendingException.Pending)
64 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68 /// Retrieves a child view by the index.
70 /// <pre>The view has been initialized.</pre>
71 /// <param name="index">The index of the child to retrieve.</param>
72 /// <returns>The view for the given index or empty handle if children not initialized.</returns>
73 /// <since_tizen> 4 </since_tizen>
74 public override View GetChildAt(uint index)
76 System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
78 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
80 if (NDalicPINVOKE.SWIGPendingException.Pending)
81 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87 protected override Container GetParent()
92 protected override uint GetChildCount()
94 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
95 if (NDalicPINVOKE.SWIGPendingException.Pending)
96 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100 protected override void Dispose(DisposeTypes type)
107 if(type == DisposeTypes.Explicit)
110 //Release your own managed resources here.
111 //You should release all of your own disposable objects here.
114 //Release your own unmanaged resources here.
115 //You should not access any managed member here except static instance.
116 //because the execution order of Finalizes is non-deterministic.
118 if (swigCPtr.Handle != global::System.IntPtr.Zero)
123 NDalicPINVOKE.delete_Layer(swigCPtr);
125 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
132 internal class Property
134 internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
138 /// Creates a Layer object.
140 /// <since_tizen> 3 </since_tizen>
141 public Layer() : this(NDalicPINVOKE.Layer_New(), true)
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144 if(Window.Instance != null)
146 this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
147 this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
150 internal void SetAnchorPoint(Vector3 anchorPoint)
152 NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
153 if (NDalicPINVOKE.SWIGPendingException.Pending)
154 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
158 NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
159 if (NDalicPINVOKE.SWIGPendingException.Pending)
160 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 [Obsolete("Please do not use! this will be deprecated")]
166 public static Layer DownCast(BaseHandle handle)
168 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Search through this layer's hierarchy for a view with the given unique ID.
176 /// <pre>This layer (the parent) has been initialized.</pre>
177 /// <remarks>The actor itself is also considered in the search.</remarks>
178 /// <param name="id">The id of the child to find</param>
179 /// <returns> A handle to the view if found, or an empty handle if not. </returns>
180 /// <since_tizen> 3 </since_tizen>
181 public View FindChildById(uint id)
183 IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
184 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
186 if (NDalicPINVOKE.SWIGPendingException.Pending)
187 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// Queries the depth of the layer.<br>
193 /// 0 is the bottommost layer, higher number is on the top.<br>
195 /// <since_tizen> 3 </since_tizen>
204 internal uint GetDepth()
206 uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 /// Increments the depth of the layer.
214 /// <since_tizen> 3 </since_tizen>
217 NDalicPINVOKE.Layer_Raise(swigCPtr);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 /// Decrements the depth of the layer.
224 /// <since_tizen> 3 </since_tizen>
227 NDalicPINVOKE.Layer_Lower(swigCPtr);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 internal void RaiseAbove(Layer target)
233 NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 internal void LowerBelow(Layer target)
239 NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 /// Raises the layer to the top.
246 /// <since_tizen> 3 </since_tizen>
247 public void RaiseToTop()
249 NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// Lowers the layer to the bottom.
256 /// <since_tizen> 3 </since_tizen>
257 public void LowerToBottom()
259 NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// Moves the layer directly above the given layer.<br>
265 /// After the call, this layer's depth will be immediately above target.<br>
267 /// <param name="target">The layer to get on top of.</param>
268 /// <since_tizen> 3 </since_tizen>
269 public void MoveAbove(Layer target)
271 NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 /// Moves the layer directly below the given layer.<br>
277 /// After the call, this layer's depth will be immediately below target.<br>
279 /// <param name="target">The layer to get below of.</param>
280 /// <since_tizen> 3 </since_tizen>
281 public void MoveBelow(Layer target)
283 NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 private void SetBehavior(LayerBehavior behavior)
289 NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293 private LayerBehavior GetBehavior()
295 Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
302 NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 internal void SetTouchConsumed(bool consume)
308 NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 internal bool IsTouchConsumed()
314 bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 internal void SetHoverConsumed(bool consume)
321 NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 internal bool IsHoverConsumed()
327 bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// Enumeration for the behavior of the layer.
335 /// <since_tizen> 3 </since_tizen>
336 public enum LayerBehavior
343 internal enum TreeDepthMultiplier
345 TREE_DEPTH_MULTIPLIER = 10000
349 /// Layer behavior, type String (Layer.LayerBehavior).
351 /// <since_tizen> 3 </since_tizen>
352 public Layer.LayerBehavior Behavior
356 return GetBehavior();
365 /// Internal only property to enable or disable clipping, type boolean.
366 /// By default, this is false, i.e., the viewport of the layer is the entire window.
368 internal bool ClippingEnabled
372 bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 /// Sets the viewport (in window coordinates), type rectangle.
385 /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
387 /// <since_tizen> 4 </since_tizen>
388 public Rectangle Viewport
392 if( ClippingEnabled )
394 Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 // Clipping not enabled so return the window size
401 Size2D windowSize = Window.Instance.Size;
402 Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
408 NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
410 ClippingEnabled = true;
415 /// Retrieves and sets the layer's opacity.<br>
417 /// <since_tizen> 3 </since_tizen>
423 GetProperty(View.Property.OPACITY).Get(out temp);
428 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
433 /// Retrieves and sets the layer's visibility.
435 /// <since_tizen> 3 </since_tizen>
436 public bool Visibility
441 GetProperty(View.Property.VISIBLE).Get(out temp);
446 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
451 /// Get the number of children held by the layer.
453 /// <since_tizen> 3 </since_tizen>
454 public new uint ChildCount
458 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
459 if (NDalicPINVOKE.SWIGPendingException.Pending)
460 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 /// Gets or sets the layer's name.
468 /// <since_tizen> 3 </since_tizen>
481 internal string GetName()
483 string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
484 if (NDalicPINVOKE.SWIGPendingException.Pending)
485 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 internal void SetName(string name)
491 NDalicPINVOKE.Actor_SetName(swigCPtr, name);
492 if (NDalicPINVOKE.SWIGPendingException.Pending)
493 throw NDalicPINVOKE.SWIGPendingException.Retrieve();