[NUI] Change CommonUI APIs (#950)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Layer.cs
index d4d784a..8c14142 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -17,6 +17,8 @@
 using System;
 using Tizen.NUI.BaseComponents;
 using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
 
 namespace Tizen.NUI
 {
@@ -28,15 +30,235 @@ namespace Tizen.NUI
     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
+        }
+
+        internal enum TreeDepthMultiplier
+        {
+            TREE_DEPTH_MULTIPLIER = 10000
+        }
+
+        /// <summary>
+        /// Layer behavior, type String (Layer.LayerBehavior).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public Layer.LayerBehavior Behavior
+        {
+            get
+            {
+                return GetBehavior();
+            }
+            set
+            {
+                SetBehavior(value);
+            }
+        }
+
+        /// <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
+        {
+            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 and sets the layer's opacity.<br />
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public float Opacity
+        {
+            get
+            {
+                float temp = 0.0f;
+                GetProperty(View.Property.OPACITY).Get(out temp);
+                return temp;
+            }
+            set
+            {
+                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 the number of children held by the layer.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public new uint ChildCount
+        {
+            get
+            {
+                return Convert.ToUInt32(Children.Count);
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the layer's name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string Name
+        {
+            get
+            {
+                return GetName();
+            }
+            set
+            {
+                SetName(value);
+            }
+        }
+
+        /// <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
+        {
+            get
+            {
+                return GetDepth();
+            }
+        }
+
+        /// <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
+            {
+                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();
+            }
+        }
+
+        /// 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;
+            }
         }
 
         /// From the Container base class.
@@ -49,11 +271,24 @@ namespace Tizen.NUI
         /// <since_tizen> 4 </since_tizen>
         public override void Add(View child)
         {
-            NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            Container oldParent = child.GetParent();
 
-            Children.Add(child);
+            if (oldParent != this)
+            {
+                if (oldParent != null)
+                {
+                    oldParent.Remove(child);
+                }
+                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);
+            }
         }
 
         /// <summary>
@@ -64,11 +299,12 @@ namespace Tizen.NUI
         /// <since_tizen> 4 </since_tizen>
         public override void Remove(View child)
         {
-            NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
+            Interop.Actor.Actor_Remove( swigCPtr, View.getCPtr(child));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             Children.Remove(child);
+            child.InternalParent = null;
         }
 
         /// <summary>
@@ -90,7 +326,6 @@ namespace Tizen.NUI
             }
         }
 
-
         /// <summary>
         /// Get parent of the layer.
         /// </summary>
@@ -112,85 +347,16 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Dispose.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        protected override void Dispose(DisposeTypes type)
-        {
-            if(disposed)
-            {
-                return;
-            }
-
-            if(type == DisposeTypes.Explicit)
-            {
-                //Called by User
-                //Release your own managed resources here.
-                //You should release all of your own disposable objects here.
-            }
-
-            //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)
-            {
-                if (swigCMemOwn)
-                {
-                    swigCMemOwn = false;
-                    NDalicPINVOKE.delete_Layer(swigCPtr);
-                }
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-            }
-
-            base.Dispose(type);
-
-        }
-
-
-        internal class Property
-        {
-            internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
-        }
-
-        /// <summary>
-        /// Creates a Layer object.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        public Layer() : this(NDalicPINVOKE.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 void SetAnchorPoint(Vector3 anchorPoint)
-        {
-            NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
-        internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
-        {
-            NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
-
-
-        /// <summary>
         /// Downcasts a handle to layer handle.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// Please do not use! this will be deprecated!
         /// Instead please use as keyword.
-        [Obsolete("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;
         }
@@ -205,31 +371,36 @@ namespace Tizen.NUI
         /// <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;
         }
 
@@ -239,30 +410,36 @@ namespace Tizen.NUI
         /// <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)
-        {
-            NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
-
-        internal void LowerBelow(Layer target)
+        public void Lower()
         {
-            NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
-            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)
+                {
+                    var low = parentChildren[currentIdx - 1];
+                    LowerBelow(low);
+                }
+            }
         }
 
         /// <summary>
@@ -271,8 +448,16 @@ namespace Tizen.NUI
         /// <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>
@@ -281,8 +466,17 @@ namespace Tizen.NUI
         /// <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>
@@ -293,7 +487,7 @@ namespace Tizen.NUI
         /// <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();
         }
 
@@ -305,250 +499,234 @@ namespace Tizen.NUI
         /// <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