[Tizen] Remove Visible propert in View.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / View.cs
index 9b7911f..acb9cd9 100755 (executable)
@@ -20,12 +20,10 @@ namespace Tizen.NUI.BaseComponents
     using System;
     using System.Runtime.InteropServices;
 
-
-
     /// <summary>
     /// View is the base class for all views.
     /// </summary>
-    public class View : Animatable //CustomActor => Animatable
+    public class View : Container
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
@@ -40,6 +38,89 @@ namespace Tizen.NUI.BaseComponents
             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 View.
+        /// </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 View. If the view was not a child of this view, this is a no-op.
+        /// </summary>
+        /// <seealso cref="Container::Remove()">
+        /// </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>
+        /// <seealso cref="Container::GetChildAt()">
+        /// </seealso>
+        public override View GetChildAt(uint index)
+        {
+            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>
+        /// Retrieves the number of children held by the view.
+        /// </summary>
+        /// <seealso cref="Container::GetChildCount()">
+        /// </seealso>
+        protected override uint GetChildCount()
+        {
+            uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Get the Views parent
+        /// </summary>
+        /// <seealso cref="Container::GetParent()">
+
+        protected override Container GetParent()
+        {
+            Container ret;
+            IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr);
+
+            BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr);
+
+            if(basehandle is Layer)
+            {
+                ret = basehandle as Layer;
+            }
+            else
+            {
+                ret = basehandle as View;
+            }
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        ///
+
         // you can override it to clean-up your own resources.
         protected override void Dispose(DisposeTypes type)
         {
@@ -59,6 +140,86 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_onRelayoutEventCallback != null)
+            {
+                this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+            }
+
+            if (_offWindowEventCallback != null)
+            {
+                this.OffWindowSignal().Disconnect(_offWindowEventCallback);
+            }
+
+            if (_onWindowEventCallback != null)
+            {
+                this.OnWindowSignal().Disconnect(_onWindowEventCallback);
+            }
+
+            if (_wheelEventCallback != null)
+            {
+                this.WheelEventSignal().Disconnect(_wheelEventCallback);
+            }
+
+            if (_hoverEventCallback != null)
+            {
+                this.HoveredSignal().Disconnect(_hoverEventCallback);
+            }
+
+            if (_touchDataCallback != null)
+            {
+                this.TouchSignal().Disconnect(_touchDataCallback);
+            }
+
+            if (_ResourcesLoadedCallback != null)
+            {
+                this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
+            }
+
+            if (_offWindowEventCallback != null)
+            {
+                this.OffWindowSignal().Disconnect(_offWindowEventCallback);
+            }
+
+            if (_onWindowEventCallback != null)
+            {
+                this.OnWindowSignal().Disconnect(_onWindowEventCallback);
+            }
+
+            if (_wheelEventCallback != null)
+            {
+                this.WheelEventSignal().Disconnect(_wheelEventCallback);
+            }
+
+            if (_hoverEventCallback != null)
+            {
+                this.HoveredSignal().Disconnect(_hoverEventCallback);
+            }
+
+            if (_touchDataCallback != null)
+            {
+                this.TouchSignal().Disconnect(_touchDataCallback);
+            }
+
+            if (_onRelayoutEventCallback != null)
+            {
+                this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+            }
+
+            if (_keyCallback != null)
+            {
+                this.KeyEventSignal().Disconnect(_keyCallback);
+            }
+
+            if (_keyInputFocusLostCallback != null)
+            {
+                this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
+            }
+
+            if (_keyInputFocusGainedCallback != null)
+            {
+                this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
@@ -827,7 +988,7 @@ namespace Tizen.NUI.BaseComponents
         /// </summary>
         /// <param name="handle">Handle to an object</param>
         /// <returns>A handle to a View or an uninitialized handle</returns>
-        [Obsolete("Please do not use! this will be deprecated, instead please us as keyword.")]
+        [Obsolete("Please do not use! this will be deprecated, instead please use as keyword.")]
         public new static View DownCast(BaseHandle handle)
         {
             View ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as View;
@@ -835,7 +996,7 @@ namespace Tizen.NUI.BaseComponents
             return ret;
         }
 
-        [Obsolete("Please do not use! this will be deprecated, instead please us as keyword.")]
+        [Obsolete("Please do not use! this will be deprecated, instead please use as keyword.")]
         public static T DownCast<T>(View view) where T : View
         {
             T ret = Registry.GetManagedBaseHandleFromNativePtr(view) as T;
@@ -850,9 +1011,10 @@ namespace Tizen.NUI.BaseComponents
         {
             View view = null;
 
-            if (Parent)
+            if (Parent is View)
             {
-                view = Parent.FindChildById(id);
+                View parentView = Parent as View;
+                view = parentView.FindChildById(id);
             }
 
             if (!view)
@@ -1710,7 +1872,8 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        public bool Visibility
+        [Obsolete("Please do not use! this will be deprecated. Please use Visibility instead.")]
+        public bool Visible
         {
             get
             {
@@ -1860,7 +2023,13 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        [Obsolete("Please do not use! this will be internal property")]
+        /// <summary>
+        /// Returns the natural size of the view.
+        /// </summary>
+        /// <remarks>
+        /// Deriving classes stipulate the natural size and by default a view has a ZERO natural size.
+        /// </remarks>
+        [Obsolete("Please do not use! this will be deprecated, please use NaturalSize2D instead")]
         public Vector3 NaturalSize
         {
             get
@@ -1873,6 +2042,24 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Returns the natural size (Size2D) of the view.
+        /// </summary>
+        /// <remarks>
+        /// Deriving classes stipulate the natural size and by default a view has a ZERO natural size.
+        /// </remarks>
+        public Size2D NaturalSize2D
+        {
+            get
+            {
+                Vector3 temp = new Vector3(NDalicPINVOKE.Actor_GetNaturalSize(swigCPtr), true);
+                if (NDalicPINVOKE.SWIGPendingException.Pending)
+                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+                return new Size2D((int)temp.Width, (int)temp.Height);
+            }
+        }
+
+        /// <summary>
         /// Shows the View.
         /// </summary>
         /// <remarks>
@@ -2030,32 +2217,6 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Adds a child view to this View.
-        /// </summary>
-        /// <pre>This View(the parent) has been initialized. The child view has been initialized. The child view is not the same as the parent view.</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 view. This may change child's position, color, scale etc as it now inherits them from this view.</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();
-        }
-
-        /// <summary>
-        /// Removes a child View from this View. If the view was not a child of this view, this is a no-op.
-        /// </summary>
-        /// <pre>This View(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();
-        }
-
-        /// <summary>
         /// Removes a View from its Parent View / Layer. If the View has no parent, this method does nothing.
         /// </summary>
         /// <pre>The (child) View has been initialized. </pre>
@@ -2067,36 +2228,6 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Retrieves the number of children held by the view.
-        /// </summary>
-        /// <pre>The View has been initialized.</pre>
-        /// <returns>The number of children</returns>
-        internal uint GetChildCount()
-        {
-            uint ret = NDalicPINVOKE.Actor_GetChildCount(swigCPtr);
-            if (NDalicPINVOKE.SWIGPendingException.Pending)
-                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        /// <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)
-        {
-            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>
         /// Search through this view's hierarchy for an view with the given name.
         /// The view itself is also considered in the search.
         /// </summary>
@@ -2125,7 +2256,7 @@ namespace Tizen.NUI.BaseComponents
             return ret;
         }
 
-        internal View GetParent()
+        /*internal View GetParent()
         {
             View ret;
             IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr);
@@ -2144,6 +2275,26 @@ namespace Tizen.NUI.BaseComponents
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
+        }*/
+
+        internal View GetParent()
+        {
+            View ret;
+            IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr);
+
+            BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr);
+
+            if(basehandle is Layer)
+            {
+                View ret2 = new View(cPtr,false);
+                return ret2;
+            }
+
+            ret = basehandle as View;
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending)
+                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
         }
 
         internal void SetParentOrigin(Vector3 origin)
@@ -3188,18 +3339,14 @@ namespace Tizen.NUI.BaseComponents
         /// If an view is not visible, then the view and its children will not be rendered.
         /// This is regardless of the individual visibility values of the children i.e.an view will only be rendered if all of its parents have visibility set to true.
         /// </remarks>
-        public bool Visible
+        public bool Visibility
         {
             get
             {
                 bool temp = false;
                 GetProperty(View.Property.VISIBLE).Get(out temp);
                 return temp;
-            }/* only get is required : removed
-            set
-            {
-                SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
-            }*/
+            }
         }
 
         /// <summary>
@@ -3243,17 +3390,6 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Get the number of children held by the view.
-        /// </summary>
-        public uint ChildCount
-        {
-            get
-            {
-                return GetChildCount();
-            }
-        }
-
-        /// <summary>
         /// Gets the View's ID.
         /// Readonly
         /// </summary>
@@ -3761,7 +3897,7 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        [Obsolete("Please do not use! this will be deprecated")]
+        [Obsolete("Please do not use! this will be deprecated, please use Size2D instead")]
         public Size Size
         {
             get