Merge "[Multimedia] Updated the doc-comments to fix the grammar errors."
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Layer.cs
index 6bef8bf..f4aaa35 100755 (executable)
@@ -22,7 +22,7 @@ namespace Tizen.NUI
     /// <summary>
     /// Layers provide a mechanism for overlaying groups of actors on top of each other.
     /// </summary>
-    public class Layer : Animatable
+    public class Layer : Container
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
@@ -36,6 +36,64 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
+        /// from Container base class
+
+        /// <summary>
+        /// Adds a child view to this layer.
+        /// </summary>
+        /// <seealso cref="Container::Add()">
+        /// </seealso>
+        public override void Add(View child)
+        {
+            NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <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::Add()">
+        /// </seealso>
+        public override void Remove(View child)
+        {
+            NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Retrieves child view by index.
+        /// </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>
+        public override View GetChildAt(uint index)
+        {
+            System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
+
+            View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+            return ret ?? null;
+        }
+
+
+        protected override Container GetParent()
+        {
+            return null;
+        }
+
+        protected override uint GetChildCount()
+        {
+            uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         protected override void Dispose(DisposeTypes type)
         {
             if(disposed)
@@ -59,10 +117,6 @@ namespace Tizen.NUI
                 if (swigCMemOwn)
                 {
                     swigCMemOwn = false;
-
-                    //Unreference this instance from Registry.
-                    Registry.Unregister(this);
-
                     NDalicPINVOKE.delete_Layer(swigCPtr);
                 }
                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
@@ -107,7 +161,7 @@ namespace Tizen.NUI
         [Obsolete("Please do not use! this will be deprecated")]
         public new static Layer DownCast(BaseHandle handle)
         {
-            Layer ret = new Layer(NDalicPINVOKE.Layer_DownCast(BaseHandle.getCPtr(handle)), true);
+            Layer ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as Layer;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -121,36 +175,12 @@ namespace Tizen.NUI
         /// <returns> A handle to the view if found, or an empty handle if not. </returns>
         public View FindChildById(uint id)
         {
-            View ret = new View(NDalicPINVOKE.Actor_FindChildById(swigCPtr, id), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        /// <summary>
-        /// Adds a child view to this layer.
-        /// </summary>
-        /// <pre>This layer(the parent) has been initialized. The child view has been initialized. The child view is not the same as the parent layer.</pre>
-        /// <post>The child will be referenced by its parent. This means that the child will be kept alive, even if the handle passed into this method is reset or destroyed.</post>
-        /// <remarks>If the child already has a parent, it will be removed from old parent and reparented to this layer. This may change child's position, color, scale etc as it now inherits them from this layer.</remarks>
-        /// <param name="child">The child</param>
-        public void Add(View child)
-        {
-            NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
+            IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id);
+            View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
 
-        /// <summary>
-        /// Removes a child View from this layer. If the view was not a child of this layer, this is a no-op.
-        /// </summary>
-        /// <pre>This layer(the parent) has been initialized. The child view is not the same as the parent view.</pre>
-        /// <param name="child">The child</param>
-        public void Remove(View child)
-        {
-            NDalicPINVOKE.Actor_Remove(swigCPtr, View.getCPtr(child));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
         }
 
         /// <summary>
@@ -288,24 +318,6 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Retrieves child view by index.
-        /// </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>
-        public View GetChildAt(uint index)
-        {
-            System.IntPtr cPtr = NDalicPINVOKE.Actor_GetChildAt(swigCPtr, index);
-
-            View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
-
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
-            return ret ?? null;
-        }
-
-        /// <summary>
         /// Enumeration for the behavior of the layer.
         /// </summary>
         public enum LayerBehavior
@@ -336,6 +348,55 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Internal only property to Enable/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 = 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();
+            }
+        }
+
+        /// <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>
+        public Rectangle Viewport
+        {
+            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;
+            }
+        }
+
+        /// <summary>
         /// Retrieves and sets the Layer's opacity.<br>
         /// </summary>
         public float Opacity
@@ -412,5 +473,6 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
+
     }
 }