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 Container base class
42 /// Adds a child view to this layer.
44 /// <seealso cref="Container::Add()">
46 public override void Add(View child)
48 NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
49 if (NDalicPINVOKE.SWIGPendingException.Pending)
50 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 /// Removes a child View from this layer. If the view was not a child of this layer, this is a no-op.
56 /// <seealso cref="Container::Add()">
58 public override void Remove(View child)
60 NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
61 if (NDalicPINVOKE.SWIGPendingException.Pending)
62 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66 /// Retrieves child view by index.
68 /// <pre>The View has been initialized.</pre>
69 /// <param name="index">The index of the child to retrieve</param>
70 /// <returns>The view for the given index or empty handle if children not initialized</returns>
71 public override View GetChildAt(uint index)
73 System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
75 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
77 if (NDalicPINVOKE.SWIGPendingException.Pending)
78 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 protected override Container GetParent()
89 protected override uint GetChildCount()
91 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
92 if (NDalicPINVOKE.SWIGPendingException.Pending)
93 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 protected override void Dispose(DisposeTypes type)
104 if(type == DisposeTypes.Explicit)
107 //Release your own managed resources here.
108 //You should release all of your own disposable objects here.
111 //Release your own unmanaged resources here.
112 //You should not access any managed member here except static instance.
113 //because the execution order of Finalizes is non-deterministic.
115 if (swigCPtr.Handle != global::System.IntPtr.Zero)
120 NDalicPINVOKE.delete_Layer(swigCPtr);
122 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
129 internal class Property
131 internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
135 /// Creates a Layer object.
137 public Layer() : this(NDalicPINVOKE.Layer_New(), true)
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 if(Window.Instance != null)
142 this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
143 this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
146 internal void SetAnchorPoint(Vector3 anchorPoint)
148 NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
149 if (NDalicPINVOKE.SWIGPendingException.Pending)
150 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
154 NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
155 if (NDalicPINVOKE.SWIGPendingException.Pending)
156 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 [Obsolete("Please do not use! this will be deprecated")]
162 public new static Layer DownCast(BaseHandle handle)
164 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 /// Search through this layer's hierarchy for an view with the given unique ID.
172 /// <pre>This layer(the parent) has been initialized.</pre>
173 /// <remarks>The actor itself is also considered in the search.</remarks>
174 /// <param name="child">The id of the child to find</param>
175 /// <returns> A handle to the view if found, or an empty handle if not. </returns>
176 public View FindChildById(uint id)
178 IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
179 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
181 if (NDalicPINVOKE.SWIGPendingException.Pending)
182 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 /// Queries the depth of the layer.<br>
188 /// 0 is the bottom most layer, higher number is on top.<br>
198 internal uint GetDepth()
200 uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 /// Increments the depth of the layer.
210 NDalicPINVOKE.Layer_Raise(swigCPtr);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Decrements the depth of the layer.
219 NDalicPINVOKE.Layer_Lower(swigCPtr);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 internal void RaiseAbove(Layer target)
225 NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 internal void LowerBelow(Layer target)
231 NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 /// Raises the layer to the top.
238 public void RaiseToTop()
240 NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 /// Lowers the layer to the bottom.
247 public void LowerToBottom()
249 NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// Moves the layer directly above the given layer.<br>
255 /// After the call, this layers depth will be immediately above target.<br>
257 /// <param name="target">Layer to get on top of</param>
258 public void MoveAbove(Layer target)
260 NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 /// Moves the layer directly below the given layer.<br>
266 /// After the call, this layers depth will be immediately below target.<br>
268 /// <param name="target">Layer to get below of</param>
269 public void MoveBelow(Layer target)
271 NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 private void SetBehavior(LayerBehavior behavior)
277 NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 private LayerBehavior GetBehavior()
283 Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
290 NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294 internal void SetTouchConsumed(bool consume)
296 NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 internal bool IsTouchConsumed()
302 bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 internal void SetHoverConsumed(bool consume)
309 NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 internal bool IsHoverConsumed()
315 bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 /// Enumeration for the behavior of the layer.
323 public enum LayerBehavior
330 internal enum TreeDepthMultiplier
332 TREE_DEPTH_MULTIPLIER = 10000
336 /// Layer Behavior, type String(Layer.LayerBehavior)
338 public Layer.LayerBehavior Behavior
342 return GetBehavior();
351 /// Internal only property to Enable/Disable Clipping, type Boolean.
352 /// By default this is false, i.e. the viewport of the Layer is the entire window.
354 internal bool ClippingEnabled
358 bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
365 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 /// Sets the Viewport (in window coordinates), type Rectangle.
371 /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
373 public Rectangle Viewport
377 if( ClippingEnabled )
379 Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 // Clipping not enabled so return the window size
386 Size2D windowSize = Window.Instance.Size;
387 Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
393 NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 ClippingEnabled = true;
400 /// Retrieves and sets the Layer's opacity.<br>
407 GetProperty(View.Property.OPACITY).Get(out temp);
412 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
417 /// Retrieves and sets the Layer's visibility.
419 public bool Visibility
424 GetProperty(View.Property.VISIBLE).Get(out temp);
429 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
434 /// Get the number of children held by the layer.
436 public uint ChildCount
440 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
441 if (NDalicPINVOKE.SWIGPendingException.Pending)
442 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 /// Gets/Sets the Layer's name.
462 internal string GetName()
464 string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
465 if (NDalicPINVOKE.SWIGPendingException.Pending)
466 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470 internal void SetName(string name)
472 NDalicPINVOKE.Actor_SetName(swigCPtr, name);
473 if (NDalicPINVOKE.SWIGPendingException.Pending)
474 throw NDalicPINVOKE.SWIGPendingException.Retrieve();