[NUI] Change CommonUI APIs (#950)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Layer.cs
index b5c73a5..8c14142 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2018 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.
@@ -18,6 +18,7 @@ using System;
 using Tizen.NUI.BaseComponents;
 using System.ComponentModel;
 using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
 
 namespace Tizen.NUI
 {
@@ -29,14 +30,13 @@ namespace Tizen.NUI
     public class Layer : Container
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-        private global::System.IntPtr rootLayoutIntPtr;
-        private global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
+        private Window window;
 
         /// <summary>
         /// Creates a Layer object.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public Layer() : this(NDalicPINVOKE.Layer_New(), true)
+        public Layer() : this(Interop.Layer.Layer_New(), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             if (Window.Instance != null)
@@ -46,16 +46,9 @@ namespace Tizen.NUI
             }
         }
 
-        internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Layer_SWIGUpcast(cPtr), cMemoryOwn)
+        internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Layer.Layer_SWIGUpcast(cPtr), cMemoryOwn)
         {
             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-            // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to this Layer.
-            // Enables layouts added to the Layer to have a parent layout.  As parent layout is needed to store measure spec properties.
-            rootLayoutIntPtr = NDalicManualPINVOKE.Window_NewRootLayout();
-            // Store HandleRef used by Add()
-            rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
-            // Add the root layout created above to this layer.
-            NDalicPINVOKE.Actor_Add( swigCPtr, rootLayoutCPtr );
         }
 
         /// <summary>
@@ -65,11 +58,6 @@ namespace Tizen.NUI
         public enum LayerBehavior
         {
             /// <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
@@ -80,7 +68,14 @@ namespace Tizen.NUI
             /// traversal, the actors would interleave).<br />
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
-            LayerUI = Layer2D,
+            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
@@ -136,21 +131,21 @@ namespace Tizen.NUI
             {
                 if (ClippingEnabled)
                 {
-                    Rectangle ret = new Rectangle(NDalicPINVOKE.Layer_GetClippingBox(swigCPtr), true);
+                    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.Instance.Size;
+                    Size2D windowSize = window?.Size;
                     Rectangle ret = new Rectangle(0, 0, windowSize.Width, windowSize.Height);
                     return ret;
                 }
             }
             set
             {
-                NDalicPINVOKE.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
+                Interop.Layer.Layer_SetClippingBox__SWIG_1(swigCPtr, Rectangle.getCPtr(value));
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 ClippingEnabled = true;
             }
@@ -241,17 +236,31 @@ namespace Tizen.NUI
         {
             get
             {
-                bool ret = NDalicPINVOKE.Layer_IsClipping(swigCPtr);
+                bool ret = Interop.Layer.Layer_IsClipping(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 return ret;
             }
             set
             {
-                NDalicPINVOKE.Layer_SetClipping(swigCPtr, value);
+                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.
 
         /// <summary>
@@ -274,17 +283,11 @@ namespace Tizen.NUI
                 {
                     child.InternalParent = this;
                 }
-                // If adding a View then set layout required flag
-                if( child.GetType() == typeof(View) )
-                {
-                    Log.Info("NUI", "Add child[" + child.Name + "] LayoutingRequired set as pure view\n");
-                    child.LayoutingRequired = true;
-                }
-
-                NDalicPINVOKE.Actor_Add( rootLayoutCPtr , View.getCPtr(child));
+                Interop.Actor.Actor_Add( swigCPtr , View.getCPtr(child));
                 if (NDalicPINVOKE.SWIGPendingException.Pending)
                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 Children.Add(child);
+                BindableObject.SetInheritedBindingContext(child, this?.BindingContext);
             }
         }
 
@@ -296,7 +299,7 @@ namespace Tizen.NUI
         /// <since_tizen> 4 </since_tizen>
         public override void Remove(View child)
         {
-            NDalicPINVOKE.Actor_Remove( rootLayoutCPtr, View.getCPtr(child));
+            Interop.Actor.Actor_Remove( swigCPtr, View.getCPtr(child));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
@@ -369,10 +372,31 @@ namespace Tizen.NUI
         public View FindChildById(uint id)
         {
             //to fix memory leak issue, match the handle count with native side.
-            IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
+            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;
-            NDalicPINVOKE.delete_BaseHandle(CPtr);
+            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;
+        }
+
+        internal override View FindCurrentChildById(uint id)
+        {
+            return FindChildById(id);
+        }
+
+        /// 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)
+        {
+            //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)
@@ -386,7 +410,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Raise()
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
             if (parentChildren != null)
             {
                 int currentIdx = parentChildren.IndexOf(this);
@@ -405,7 +429,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Lower()
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
             if (parentChildren != null)
             {
                 int currentIdx = parentChildren.IndexOf(this);
@@ -424,14 +448,14 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void RaiseToTop()
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
 
             if (parentChildren != null)
             {
                 parentChildren.Remove(this);
                 parentChildren.Add(this);
 
-                NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
+                Interop.Layer.Layer_RaiseToTop(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
         }
@@ -442,14 +466,14 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void LowerToBottom()
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
 
             if (parentChildren != null)
             {
                 parentChildren.Remove(this);
                 parentChildren.Insert(0, this);
 
-                NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
+                Interop.Layer.Layer_LowerToBottom(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
@@ -463,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();
         }
 
@@ -475,7 +499,7 @@ 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();
         }
 
@@ -484,23 +508,45 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        internal void SetAnchorPoint(Vector3 anchorPoint)
+        /// 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)
         {
-            NDalicPINVOKE.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
+            Interop.Actor.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
+        /// 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)
         {
-            NDalicPINVOKE.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
+            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.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
             if (parentChildren != null)
             {
                 int idx = parentChildren.IndexOf(this);
@@ -513,7 +559,7 @@ namespace Tizen.NUI
         }
         internal void RaiseAbove(Layer target)
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
             if (parentChildren != null)
             {
                 int currentIndex = parentChildren.IndexOf(this);
@@ -532,7 +578,7 @@ namespace Tizen.NUI
                     parentChildren.Remove(this);
                     parentChildren.Insert(targetIndex, this);
 
-                    NDalicPINVOKE.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
+                    Interop.Layer.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target));
                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
@@ -540,7 +586,7 @@ namespace Tizen.NUI
 
         internal void LowerBelow(Layer target)
         {
-            var parentChildren = Window.Instance.LayersChildren;
+            var parentChildren = window?.LayersChildren;
 
             if (parentChildren != null)
             {
@@ -561,7 +607,7 @@ namespace Tizen.NUI
                     parentChildren.Remove(this);
                     parentChildren.Insert(targetIndex, this);
 
-                    NDalicPINVOKE.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
+                    Interop.Layer.Layer_MoveBelow(swigCPtr, Layer.getCPtr(target));
                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
@@ -569,32 +615,32 @@ namespace Tizen.NUI
 
         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;
         }
@@ -611,7 +657,7 @@ namespace Tizen.NUI
 
         internal string GetName()
         {
-            string ret = NDalicPINVOKE.Actor_GetName(swigCPtr);
+            string ret = Interop.Actor.Actor_GetName(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
@@ -619,11 +665,16 @@ namespace Tizen.NUI
 
         internal void SetName(string name)
         {
-            NDalicPINVOKE.Actor_SetName(swigCPtr, name);
+            Interop.Actor.Actor_SetName(swigCPtr, name);
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        internal void SetWindow(Window win)
+        {
+            window = win;
+        }
+
         /// <summary>
         /// Dispose.
         /// </summary>
@@ -651,7 +702,7 @@ namespace Tizen.NUI
                 if (swigCMemOwn)
                 {
                     swigCMemOwn = false;
-                    NDalicPINVOKE.delete_Layer(swigCPtr);
+                    Interop.Layer.delete_Layer(swigCPtr);
                 }
                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
             }
@@ -662,20 +713,20 @@ namespace Tizen.NUI
 
         private void SetBehavior(LayerBehavior behavior)
         {
-            NDalicPINVOKE.Layer_SetBehavior(swigCPtr, (int)behavior);
+            Interop.Layer.Layer_SetBehavior(swigCPtr, (int)behavior);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
         private LayerBehavior GetBehavior()
         {
-            Layer.LayerBehavior ret = (Layer.LayerBehavior)NDalicPINVOKE.Layer_GetBehavior(swigCPtr);
+            Layer.LayerBehavior ret = (Layer.LayerBehavior)Interop.Layer.Layer_GetBehavior(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
 
         internal class Property
         {
-            internal static readonly int BEHAVIOR = NDalicPINVOKE.Layer_Property_BEHAVIOR_get();
+            internal static readonly int BEHAVIOR = Interop.Layer.Layer_Property_BEHAVIOR_get();
         }
     }
 }
\ No newline at end of file