/*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*
*/
+using System;
+using Tizen.NUI.BaseComponents;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
- using System;
- using Tizen.NUI.BaseComponents;
/// <summary>
/// Layers provide a mechanism for overlaying groups of actors on top of each other.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class Layer : Container
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private Window window;
- internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
+ /// <summary>
+ /// Creates a Layer object.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public Layer() : this(Interop.Layer.Layer_New(), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ if (Window.Instance != null)
+ {
+ this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
+ this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
+ }
+ }
+
+ internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Layer.Layer_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
+ /// <summary>
+ /// Enumeration for the behavior of the layer.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum LayerBehavior
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ /// <summary>
+ /// UI control rendering mode (default mode).
+ /// This mode is designed for UI controls that can overlap. In this
+ /// mode renderer order will be respective to the tree hierarchy of
+ /// Actors.<br />
+ /// The rendering order is depth first, so for the following actor tree,
+ /// A will be drawn first, then B, D, E, then C, F. This ensures that
+ /// overlapping actors are drawn as expected (whereas, with breadth first
+ /// traversal, the actors would interleave).<br />
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ LayerUI,
+
+ /// <summary>
+ /// UI control rendering mode.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Layer2D = LayerUI,
+
+ /// <summary>
+ /// Layer will use depth test.
+ /// This mode is designed for a 3 dimensional scene where actors in front
+ /// of other actors will obscure them, i.e. the actors are sorted by the
+ /// distance from the camera.<br />
+ /// When using this mode, a depth test will be used. A depth clear will
+ /// happen for each layer, which means actors in a layer "above" other
+ /// layers will be rendered in front of actors in those layers regardless
+ /// of their Z positions (see Layer::Raise() and Layer::Lower()).<br />
+ /// Opaque renderers are drawn first and write to the depth buffer. Then
+ /// transparent renderers are drawn with depth test enabled but depth
+ /// write switched off. Transparent renderers are drawn based on their
+ /// distance from the camera. A renderer's DEPTH_INDEX property is used to
+ /// offset the distance to the camera when ordering transparent renderers.
+ /// This is useful if you want to define the draw order of two or more
+ /// transparent renderers that are equal distance from the camera. Unlike
+ /// LAYER_UI, parent-child relationship does not affect rendering order at
+ /// all.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Layer3D
}
- /// From the Container base class.
+ internal enum TreeDepthMultiplier
+ {
+ TREE_DEPTH_MULTIPLIER = 10000
+ }
/// <summary>
- /// Adds a child view to this layer.
+ /// Layer behavior, type String (Layer.LayerBehavior).
/// </summary>
- /// <seealso cref="Container.Add">
- /// </seealso>
- /// <since_tizen> 4 </since_tizen>
- public override void Add(View child)
+ /// <since_tizen> 3 </since_tizen>
+ public Layer.LayerBehavior Behavior
{
- NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- Children.Add(child);
+ get
+ {
+ return GetBehavior();
+ }
+ set
+ {
+ SetBehavior(value);
+ }
}
/// <summary>
- /// Removes a child view from this layer. If the view was not a child of this layer, this is a no-op.
+ /// Sets the viewport (in window coordinates), type rectangle.
+ /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
/// </summary>
- /// <seealso cref="Container.Remove">
- /// </seealso>
/// <since_tizen> 4 </since_tizen>
- public override void Remove(View child)
+ public Rectangle Viewport
{
- NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- Children.Remove(child);
+ get
+ {
+ if (ClippingEnabled)
+ {
+ Rectangle ret = new Rectangle(Interop.Layer.Layer_GetClippingBox(swigCPtr), true);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ else
+ {
+ // Clipping not enabled so return the window size
+ Size2D windowSize = window?.Size;
+ Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
+ return ret;
+ }
+ }
+ set
+ {
+ Interop.Layer.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ ClippingEnabled = true;
+ }
}
/// <summary>
- /// Retrieves a child view by the index.
+ /// Retrieves and sets the layer's opacity.<br />
/// </summary>
- /// <pre>The view has been initialized.</pre>
- /// <param name="index">The index of the child to retrieve.</param>
- /// <returns>The view for the given index or empty handle if children not initialized.</returns>
- /// <since_tizen> 4 </since_tizen>
- public override View GetChildAt(uint index)
+ /// <since_tizen> 3 </since_tizen>
+ public float Opacity
{
- if (index < Children.Count)
+ get
{
- return Children[Convert.ToInt32(index)];
+ float temp = 0.0f;
+ GetProperty(View.Property.OPACITY).Get(out temp);
+ return temp;
}
- else
+ set
{
- return null;
+ SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
}
}
+ /// <summary>
+ /// Retrieves and sets the layer's visibility.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public bool Visibility
+ {
+ get
+ {
+ bool temp = false;
+ GetProperty(View.Property.VISIBLE).Get(out temp);
+ return temp;
+ }
+ set
+ {
+ SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
+ }
+ }
/// <summary>
- /// Get parent of the layer.
+ /// Get the number of children held by the layer.
/// </summary>
- /// <returns>The view's container</returns>
/// <since_tizen> 3 </since_tizen>
- public override Container GetParent()
+ public new uint ChildCount
{
- return null;
+ get
+ {
+ return Convert.ToUInt32(Children.Count);
+ }
}
/// <summary>
- /// Get the child count of the layer.
+ /// Gets or sets the layer's name.
/// </summary>
- /// <returns>The child count of the layer.</returns>
/// <since_tizen> 3 </since_tizen>
- public override uint GetChildCount()
+ public string Name
{
- return Convert.ToUInt32(Children.Count);
+ get
+ {
+ return GetName();
+ }
+ set
+ {
+ SetName(value);
+ }
}
/// <summary>
- /// Dispose.
+ /// Queries the depth of the layer.<br />
+ /// 0 is the bottommost layer, higher number is on the top.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
- protected override void Dispose(DisposeTypes type)
+ public uint Depth
{
- if(disposed)
+ get
{
- return;
+ return GetDepth();
}
+ }
- if(type == DisposeTypes.Explicit)
+ /// <summary>
+ /// Internal only property to enable or disable clipping, type boolean.
+ /// By default, this is false, i.e., the viewport of the layer is the entire window.
+ /// </summary>
+ internal bool ClippingEnabled
+ {
+ get
{
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
+ bool ret = Interop.Layer.Layer_IsClipping(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ set
+ {
+ Interop.Layer.Layer_SetClipping(swigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ }
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ResourceDictionary XamlResources
+ {
+ get
+ {
+ return Application.Current.XamlResources;
+ }
+ set
+ {
+ Application.Current.XamlResources = value;
+ }
+ }
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ /// From the Container base class.
+
+ /// <summary>
+ /// Adds a child view to this layer.
+ /// </summary>
+ /// <seealso cref="Container.Add">
+ /// </seealso>
+ /// <since_tizen> 4 </since_tizen>
+ public override void Add(View child)
+ {
+ Container oldParent = child.GetParent();
+
+ if (oldParent != this)
{
- if (swigCMemOwn)
+ if (oldParent != null)
{
- swigCMemOwn = false;
- NDalicPINVOKE.delete_Layer(swigCPtr);
+ oldParent.Remove(child);
}
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ else
+ {
+ child.InternalParent = this;
+ }
+ Interop.Actor.Actor_Add( swigCPtr , View.getCPtr(child));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ Children.Add(child);
+ BindableObject.SetInheritedBindingContext(child, this?.BindingContext);
}
-
- base.Dispose(type);
-
}
-
- internal class Property
+ /// <summary>
+ /// Removes a child view from this layer. If the view was not a child of this layer, this is a no-op.
+ /// </summary>
+ /// <seealso cref="Container.Remove">
+ /// </seealso>
+ /// <since_tizen> 4 </since_tizen>
+ public override void Remove(View child)
{
- internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
+ Interop.Actor.Actor_Remove( swigCPtr, View.getCPtr(child));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ Children.Remove(child);
+ child.InternalParent = null;
}
/// <summary>
- /// Creates a Layer object.
+ /// Retrieves a child view by the index.
/// </summary>
- /// <since_tizen> 3 </since_tizen>
- public Layer() : this(NDalicPINVOKE.Layer_New(), true)
+ /// <pre>The view has been initialized.</pre>
+ /// <param name="index">The index of the child to retrieve.</param>
+ /// <returns>The view for the given index or empty handle if children not initialized.</returns>
+ /// <since_tizen> 4 </since_tizen>
+ public override View GetChildAt(uint index)
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if(Window.Instance != null)
+ if (index < Children.Count)
{
- this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
- this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
+ return Children[Convert.ToInt32(index)];
+ }
+ else
+ {
+ return null;
}
}
- internal void SetAnchorPoint(Vector3 anchorPoint)
+
+ /// <summary>
+ /// Get parent of the layer.
+ /// </summary>
+ /// <returns>The view's container</returns>
+ /// <since_tizen> 4 </since_tizen>
+ public override Container GetParent()
{
- NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return null;
}
- internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
+
+ /// <summary>
+ /// Get the child count of the layer.
+ /// </summary>
+ /// <returns>The child count of the layer.</returns>
+ /// <since_tizen> 4 </since_tizen>
+ public override uint GetChildCount()
{
- NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return Convert.ToUInt32(Children.Count);
}
-
/// <summary>
- /// [Obsolete("Please do not use! this will be deprecated")]
+ /// Downcasts a handle to layer handle.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- [Obsolete("Please do not use! this will be deprecated")]
+ /// Please do not use! this will be deprecated!
+ /// Instead please use as keyword.
+ [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead!")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static Layer DownCast(BaseHandle handle)
{
- Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
+ Layer ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// <since_tizen> 3 </since_tizen>
public View FindChildById(uint id)
{
- IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
+ //to fix memory leak issue, match the handle count with native side.
+ IntPtr cPtr = Interop.Actor.Actor_FindChildById(swigCPtr, id);
+ HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
+ Interop.BaseHandle.delete_BaseHandle(CPtr);
+ CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- /// <summary>
- /// Queries the depth of the layer.<br />
- /// 0 is the bottommost layer, higher number is on the top.<br />
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public uint Depth
+ internal override View FindCurrentChildById(uint id)
{
- get
- {
- return GetDepth();
- }
+ return FindChildById(id);
}
- internal uint GetDepth()
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View FindChildByName(string viewName)
{
- uint ret = NDalicPINVOKE.Layer_GetDepth(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ //to fix memory leak issue, match the handle count with native side.
+ IntPtr cPtr = Interop.Actor.Actor_FindChildByName(swigCPtr, viewName);
+ HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
+ Interop.BaseHandle.delete_BaseHandle(CPtr);
+ CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// <since_tizen> 3 </since_tizen>
public void Raise()
{
- NDalicPINVOKE.Layer_Raise(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ var parentChildren = window?.LayersChildren;
+ if (parentChildren != null)
+ {
+ int currentIdx = parentChildren.IndexOf(this);
+
+ if (currentIdx >= 0 && currentIdx < parentChildren.Count - 1)
+ {
+ var upper = parentChildren[currentIdx + 1];
+ RaiseAbove(upper);
+ }
+ }
}
/// <summary>
/// Decrements the depth of the layer.
/// </summary>
- /// <since_tizen> 3 </since_tizen>
- public void Lower()
- {
- NDalicPINVOKE.Layer_Lower(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void RaiseAbove(Layer target)
+ /// <since_tizen> 3 </since_tizen>
+ public void Lower()
{
- NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ var parentChildren = window?.LayersChildren;
+ if (parentChildren != null)
+ {
+ int currentIdx = parentChildren.IndexOf(this);
- internal void LowerBelow(Layer target)
- {
- NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ if (currentIdx > 0 && currentIdx < parentChildren.Count)
+ {
+ var low = parentChildren[currentIdx - 1];
+ LowerBelow(low);
+ }
+ }
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public void RaiseToTop()
{
- NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ var parentChildren = window?.LayersChildren;
+
+ if (parentChildren != null)
+ {
+ parentChildren.Remove(this);
+ parentChildren.Add(this);
+
+ Interop.Layer.Layer_RaiseToTop(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public void LowerToBottom()
{
- NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ var parentChildren = window?.LayersChildren;
+
+ if (parentChildren != null)
+ {
+ parentChildren.Remove(this);
+ parentChildren.Insert(0, this);
+
+ Interop.Layer.Layer_LowerToBottom(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public void MoveAbove(Layer target)
{
- NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
+ Interop.Layer.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <since_tizen> 3 </since_tizen>
public void MoveBelow(Layer target)
{
- NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
+ Interop.Layer.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- private void SetBehavior(LayerBehavior behavior)
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Layer obj)
{
- NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
- private LayerBehavior GetBehavior()
+ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetAnchorPoint(Vector3 anchorPoint)
{
- Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ Interop.Actor.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetSize(float width, float height)
+ {
+ Interop.ActorInternal.Actor_SetSize__SWIG_0(swigCPtr, width, height);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetParentOrigin(Vector3 parentOrigin)
+ {
+ Interop.ActorInternal.Actor_SetParentOrigin(swigCPtr, Vector3.getCPtr(parentOrigin));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
+ {
+ Interop.Actor.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal uint GetDepth()
+ {
+ var parentChildren = window?.LayersChildren;
+ if (parentChildren != null)
+ {
+ int idx = parentChildren.IndexOf(this);
+ if (idx >= 0)
+ {
+ return Convert.ToUInt32(idx); ;
+ }
+ }
+ return 0u;
+ }
+ internal void RaiseAbove(Layer target)
+ {
+ var parentChildren = window?.LayersChildren;
+ if (parentChildren != null)
+ {
+ int currentIndex = parentChildren.IndexOf(this);
+ int targetIndex = parentChildren.IndexOf(target);
+
+ if (currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
+
+ // If the currentIndex is less than the target index and the target has the same parent.
+ if (currentIndex < targetIndex)
+ {
+ parentChildren.Remove(this);
+ parentChildren.Insert(targetIndex, this);
+
+ Interop.Layer.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+ }
+
+ internal void LowerBelow(Layer target)
+ {
+ var parentChildren = window?.LayersChildren;
+
+ if (parentChildren != null)
+ {
+ int currentIndex = parentChildren.IndexOf(this);
+ int targetIndex = parentChildren.IndexOf(target);
+
+ if (currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
+
+ // If the currentIndex is not already the 0th index and the target has the same parent.
+ if ((currentIndex != 0) && (targetIndex != -1) &&
+ (currentIndex > targetIndex))
+ {
+ parentChildren.Remove(this);
+ parentChildren.Insert(targetIndex, this);
+
+ Interop.Layer.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
}
internal void SetSortFunction(SWIGTYPE_p_f_r_q_const__Dali__Vector3__float function)
{
- NDalicPINVOKE.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
+ Interop.Layer.Layer_SetSortFunction(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Vector3__float.getCPtr(function));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void SetTouchConsumed(bool consume)
{
- NDalicPINVOKE.Layer_SetTouchConsumed(swigCPtr, consume);
+ Interop.Layer.Layer_SetTouchConsumed(swigCPtr, consume);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal bool IsTouchConsumed()
{
- bool ret = NDalicPINVOKE.Layer_IsTouchConsumed(swigCPtr);
+ bool ret = Interop.Layer.Layer_IsTouchConsumed(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetHoverConsumed(bool consume)
{
- NDalicPINVOKE.Layer_SetHoverConsumed(swigCPtr, consume);
+ Interop.Layer.Layer_SetHoverConsumed(swigCPtr, consume);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal bool IsHoverConsumed()
{
- bool ret = NDalicPINVOKE.Layer_IsHoverConsumed(swigCPtr);
+ bool ret = Interop.Layer.Layer_IsHoverConsumed(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- /// <summary>
- /// Enumeration for the behavior of the layer.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public enum LayerBehavior
+ internal void AddViewToLayerList(View view)
{
- /// <summary>
- /// UI control rendering mode.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- Layer2D,
- /// <summary>
- /// UI control rendering mode (default mode).
- /// This mode is designed for UI controls that can overlap. In this
- /// mode renderer order will be respective to the tree hierarchy of
- /// Actors.<br />
- /// The rendering order is depth first, so for the following actor tree,
- /// A will be drawn first, then B, D, E, then C, F. This ensures that
- /// overlapping actors are drawn as expected (whereas, with breadth first
- /// traversal, the actors would interleave).<br />
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- LayerUI = Layer2D,
- /// <summary>
- /// Layer will use depth test.
- /// This mode is designed for a 3 dimensional scene where actors in front
- /// of other actors will obscure them, i.e. the actors are sorted by the
- /// distance from the camera.<br />
- /// When using this mode, a depth test will be used. A depth clear will
- /// happen for each layer, which means actors in a layer "above" other
- /// layers will be rendered in front of actors in those layers regardless
- /// of their Z positions (see Layer::Raise() and Layer::Lower()).<br />
- /// Opaque renderers are drawn first and write to the depth buffer. Then
- /// transparent renderers are drawn with depth test enabled but depth
- /// write switched off. Transparent renderers are drawn based on their
- /// distance from the camera. A renderer's DEPTH_INDEX property is used to
- /// offset the distance to the camera when ordering transparent renderers.
- /// This is useful if you want to define the draw order of two or more
- /// transparent renderers that are equal distance from the camera. Unlike
- /// LAYER_UI, parent-child relationship does not affect rendering order at
- /// all.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- Layer3D
+ Children.Add(view);
}
- internal enum TreeDepthMultiplier
+ internal void RemoveViewFromLayerList(View view)
{
- TREE_DEPTH_MULTIPLIER = 10000
+ Children.Remove(view);
}
- /// <summary>
- /// Layer behavior, type String (Layer.LayerBehavior).
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public Layer.LayerBehavior Behavior
+ internal string GetName()
{
- get
- {
- return GetBehavior();
- }
- set
- {
- SetBehavior(value);
- }
+ string ret = Interop.Actor.Actor_GetName(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
}
- /// <summary>
- /// Internal only property to enable or disable clipping, type boolean.
- /// By default, this is false, i.e., the viewport of the layer is the entire window.
- /// </summary>
- internal bool ClippingEnabled
+ internal void SetName(string name)
{
- get
- {
- bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- set
- {
- NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ Interop.Actor.Actor_SetName(swigCPtr, name);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- /// <summary>
- /// Sets the viewport (in window coordinates), type rectangle.
- /// The contents of the layer will not be visible outside this box, when ViewportEnabled is true.
- /// </summary>
- /// <since_tizen> 4 </since_tizen>
- public Rectangle Viewport
+ internal void SetWindow(Window win)
{
- get
- {
- if( ClippingEnabled )
- {
- Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- else
- {
- // Clipping not enabled so return the window size
- Size2D windowSize = Window.Instance.Size;
- Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
- return ret;
- }
- }
- set
- {
- NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- ClippingEnabled = true;
- }
+ window = win;
}
/// <summary>
- /// Retrieves and sets the layer's opacity.<br />
+ /// Dispose.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public float Opacity
+ protected override void Dispose(DisposeTypes type)
{
- get
- {
- float temp = 0.0f;
- GetProperty(View.Property.OPACITY).Get(out temp);
- return temp;
- }
- set
+ if (disposed)
{
- SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
+ return;
}
- }
- /// <summary>
- /// Retrieves and sets the layer's visibility.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public bool Visibility
- {
- get
- {
- bool temp = false;
- GetProperty(View.Property.VISIBLE).Get(out temp);
- return temp;
- }
- set
+ if (type == DisposeTypes.Explicit)
{
- SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
+ //Called by User
+ //Release your own managed resources here.
+ //You should release all of your own disposable objects here.
}
- }
- /// <summary>
- /// Get the number of children held by the layer.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public new uint ChildCount
- {
- get
+ //Release your own unmanaged resources here.
+ //You should not access any managed member here except static instance.
+ //because the execution order of Finalizes is non-deterministic.
+
+ if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
- return Convert.ToUInt32(Children.Count);
+ if (swigCMemOwn)
+ {
+ swigCMemOwn = false;
+ Interop.Layer.delete_Layer(swigCPtr);
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
+
+ base.Dispose(type);
+
}
- /// <summary>
- /// Gets or sets the layer's name.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- public string Name
+ private void SetBehavior(LayerBehavior behavior)
{
- get
- {
- return GetName();
- }
- set
- {
- SetName(value);
- }
+ Interop.Layer.Layer_SetBehavior(swigCPtr, (int)behavior);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal string GetName()
+ private LayerBehavior GetBehavior()
{
- string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ Layer.LayerBehavior ret = (Layer.LayerBehavior)Interop.Layer.Layer_GetBehavior(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- internal void SetName(string name)
+ internal class Property
{
- NDalicPINVOKE.Actor_SetName(swigCPtr, name);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ internal static readonly int BEHAVIOR = Interop.Layer.Layer_Property_BEHAVIOR_get();
}
-
}
}
\ No newline at end of file