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();
99 protected override void Dispose(DisposeTypes type)
106 if(type == DisposeTypes.Explicit)
109 //Release your own managed resources here.
110 //You should release all of your own disposable objects here.
113 //Release your own unmanaged resources here.
114 //You should not access any managed member here except static instance.
115 //because the execution order of Finalizes is non-deterministic.
117 if (swigCPtr.Handle != global::System.IntPtr.Zero)
122 NDalicPINVOKE.delete_Layer(swigCPtr);
124 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
131 internal class Property
133 internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
137 /// Creates a Layer object.
139 public Layer() : this(NDalicPINVOKE.Layer_New(), true)
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 if(Window.Instance != null)
144 this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
145 this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
148 internal void SetAnchorPoint(Vector3 anchorPoint)
150 NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
151 if (NDalicPINVOKE.SWIGPendingException.Pending)
152 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
156 NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
157 if (NDalicPINVOKE.SWIGPendingException.Pending)
158 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 [Obsolete("Please do not use! this will be deprecated")]
164 public new static Layer DownCast(BaseHandle handle)
166 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 /// Search through this layer's hierarchy for an view with the given unique ID.
174 /// <pre>This layer(the parent) has been initialized.</pre>
175 /// <remarks>The actor itself is also considered in the search.</remarks>
176 /// <param name="child">The id of the child to find</param>
177 /// <returns> A handle to the view if found, or an empty handle if not. </returns>
178 public View FindChildById(uint id)
180 IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
181 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
183 if (NDalicPINVOKE.SWIGPendingException.Pending)
184 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// Queries the depth of the layer.<br>
190 /// 0 is the bottom most layer, higher number is on top.<br>
200 internal uint GetDepth()
202 uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// Increments the depth of the layer.
212 NDalicPINVOKE.Layer_Raise(swigCPtr);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Decrements the depth of the layer.
221 NDalicPINVOKE.Layer_Lower(swigCPtr);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 internal void RaiseAbove(Layer target)
227 NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 internal void LowerBelow(Layer target)
233 NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 /// Raises the layer to the top.
240 public void RaiseToTop()
242 NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
243 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247 /// Lowers the layer to the bottom.
249 public void LowerToBottom()
251 NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 /// Moves the layer directly above the given layer.<br>
257 /// After the call, this layers depth will be immediately above target.<br>
259 /// <param name="target">Layer to get on top of</param>
260 public void MoveAbove(Layer target)
262 NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 /// Moves the layer directly below the given layer.<br>
268 /// After the call, this layers depth will be immediately below target.<br>
270 /// <param name="target">Layer to get below of</param>
271 public void MoveBelow(Layer target)
273 NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private void SetBehavior(LayerBehavior behavior)
279 NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 private LayerBehavior GetBehavior()
285 Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
292 NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 internal void SetTouchConsumed(bool consume)
298 NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 internal bool IsTouchConsumed()
304 bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 internal void SetHoverConsumed(bool consume)
311 NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315 internal bool IsHoverConsumed()
317 bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 /// Enumeration for the behavior of the layer.
325 public enum LayerBehavior
332 internal enum TreeDepthMultiplier
334 TREE_DEPTH_MULTIPLIER = 10000
338 /// Layer Behavior, type String(Layer.LayerBehavior)
340 public Layer.LayerBehavior Behavior
344 return GetBehavior();
353 /// Internal only property to Enable/Disable Clipping, type Boolean.
354 /// By default this is false, i.e. the viewport of the Layer is the entire window.
356 internal bool ClippingEnabled
360 bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372 /// Sets the Viewport (in window coordinates), type Rectangle.
373 /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
375 public Rectangle Viewport
379 if( ClippingEnabled )
381 Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 // Clipping not enabled so return the window size
388 Size2D windowSize = Window.Instance.Size;
389 Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
395 NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
396 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 ClippingEnabled = true;
402 /// Retrieves and sets the Layer's opacity.<br>
409 GetProperty(View.Property.OPACITY).Get(out temp);
414 SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
419 /// Retrieves and sets the Layer's visibility.
421 public bool Visibility
426 GetProperty(View.Property.VISIBLE).Get(out temp);
431 SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
438 /// Get the number of children held by the layer.
440 public uint ChildCount
444 uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
445 if (NDalicPINVOKE.SWIGPendingException.Pending)
446 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 /// Gets/Sets the Layer's name.
466 internal string GetName()
468 string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
469 if (NDalicPINVOKE.SWIGPendingException.Pending)
470 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 internal void SetName(string name)
476 NDalicPINVOKE.Actor_SetName(swigCPtr, name);
477 if (NDalicPINVOKE.SWIGPendingException.Pending)
478 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 >>>>>>> parent of a941a95... Revert "[Tizen] add Name in Layer, LineCount in TextLabel"