[NUI] Make internal API for calculate screen position and extents.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewPublicMethods.cs
index 801ed1c..1dc3ffd 100755 (executable)
@@ -54,14 +54,11 @@ namespace Tizen.NUI.BaseComponents
                                                  AlphaFunction.BuiltinFunctions? alphaFunction = null,
                                                  object initialValue = null)
         {
-            Tizen.NUI.PropertyMap background = Background;
-
-            if (background.Empty())
+            if (IsBackgroundEmpty())
             {
                 // If there is no background yet, ensure there is a transparent
                 // color visual
                 BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
-                background = Background;
             }
             return AnimateColor("background", destinationValue, startTime, endTime, alphaFunction, initialValue);
         }
@@ -220,11 +217,30 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Retrieves a child view as Animatable by index.
+        /// </summary>
+        /// <param name="index">The index of the Animatable to find.</param>
+        /// <returns>A handle to the view as Animatable if found, or an empty handle if not.</returns>
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Animatable GetChildAnimatableAt(uint index)
+        {
+            if (index < Children.Count)
+            {
+                return Children[Convert.ToInt32(index)] as Animatable;
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
         /// Retrieves the number of children held by the view.
         /// </summary>
         /// <seealso cref="Container.GetChildCount" />
         /// <since_tizen> 4 </since_tizen>
-        [Obsolete("Deprecated in API9, will be removed in API11. Please use ChildCount property instead!")]
+        [Obsolete("This has been deprecated in API9 and will be removed in API11. Use ChildCount property instead.")]
         public override uint GetChildCount()
         {
             return Convert.ToUInt32(Children.Count);
@@ -265,7 +281,7 @@ namespace Tizen.NUI.BaseComponents
         /// </summary>
         /// <param name="styleName">A string matching a style described in a stylesheet.</param>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, will be removed in API11. Please use StyleName property instead!")]
+        [Obsolete("This has been deprecated in API9 and will be removed in API11. Use StyleName property instead.")]
         public void SetStyleName(string styleName)
         {
             Interop.View.SetStyleName(SwigCPtr, styleName);
@@ -277,7 +293,7 @@ namespace Tizen.NUI.BaseComponents
         /// </summary>
         /// <returns>A string matching a style, or an empty string.</returns>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, will be removed in API11. Please use StyleName property instead!")]
+        [Obsolete("This has been deprecated in API9 and will be removed in API11. Use StyleName property instead.")]
         public string GetStyleName()
         {
             string ret = Interop.View.GetStyleName(SwigCPtr);
@@ -450,6 +466,36 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Search through this view's hierarchy for a view as Animatable with the given name.
+        /// The view itself is also considered in the search.
+        /// </summary>
+        /// <pre>The view has been initialized.</pre>
+        /// <param name="childName">The name of the Animatable to find.</param>
+        /// <returns>A handle to the view as Animatable if found, or an empty handle if not.</returns>
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Animatable FindChildAnimatableByName(string childName)
+        {
+            //to fix memory leak issue, match the handle count with native side.
+            IntPtr cPtr = Interop.Actor.FindChildByName(SwigCPtr, childName);
+            Animatable ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animatable;
+            if(ret == null)
+            {
+                // Register new camera into Registry.
+                ret = new Animatable(cPtr, true);
+            }
+            else
+            {
+                // We found matched NUI camera. Reduce cPtr reference count.
+                HandleRef handle = new HandleRef(this, cPtr);
+                Interop.Actor.DeleteActor(handle);
+                handle = new HandleRef(null, IntPtr.Zero);
+            }
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Converts screen coordinates into the view's coordinate system using the default camera.
         /// </summary>
         /// <pre>The view has been initialized.</pre>
@@ -534,7 +580,7 @@ namespace Tizen.NUI.BaseComponents
         /// </summary>
         /// <param name="padding">Padding for the view.</param>
         /// <since_tizen> 3 </since_tizen>
-        // [Obsolete("Deprecated in API9, will be removed in API11. Please use Padding property instead!")]
+        // [Obsolete("This has been deprecated in API9 and will be removed in API11. Use Padding property instead.")]
         public void SetPadding(PaddingType padding)
         {
             Interop.Actor.SetPadding(SwigCPtr, PaddingType.getCPtr(padding));
@@ -547,7 +593,7 @@ namespace Tizen.NUI.BaseComponents
         /// </summary>
         /// <param name="paddingOut">the value of padding for the view</param>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, will be removed in API11. Please use Padding property instead!")]
+        [Obsolete("This has been deprecated in API9 and will be removed in API11. Use Padding property instead.")]
         public void GetPadding(PaddingType paddingOut)
         {
             Interop.Actor.GetPadding(SwigCPtr, PaddingType.getCPtr(paddingOut));
@@ -638,6 +684,24 @@ namespace Tizen.NUI.BaseComponents
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// Rotate the view look at specific position.
+        /// It will change the view's orientation property.
+        /// </summary>
+        /// <remark>Target position should be setup by world coordinates.</remark>
+        /// <param name="target">The target world position to look at.</param>
+        /// <param name="up">The up vector after target look at. If it is null, up vector become +Y axis</param>
+        /// <param name="localForward">The forward vector of view when it's orientation is not applied. If it is null, localForward vector become +Z axis</param>
+        /// <param name="localUp">The up vector of view when it's orientation is not applied. If it is null, localUp vector become +Y axis</param>
+        /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void LookAt(Vector3 target, Vector3 up = null, Vector3 localForward = null, Vector3 localUp = null)
+        {
+            Interop.ActorInternal.LookAt(SwigCPtr, Vector3.getCPtr(target), Vector3.getCPtr(up), Vector3.getCPtr(localForward), Vector3.getCPtr(localUp));
+            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 SetColorMode(ColorMode colorMode)
@@ -678,7 +742,7 @@ namespace Tizen.NUI.BaseComponents
         /// <param name="id">The ID of the View to find</param>
         /// <returns>A View if found or a null if not</returns>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        [Obsolete("This will be removed at API11! please use FindDescendantByID(uint id) instead!")]
+        [Obsolete("This will be removed at API11. Use FindDescendantByID(uint id) instead.")]
         public View FindChildByID(uint id)
         {
             IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
@@ -878,5 +942,72 @@ namespace Tizen.NUI.BaseComponents
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// Register custom HitTest function for this view.
+        /// </summary>
+        /// <seealso cref="View.HitTest" />
+        /// <remarks>
+        /// This is a hidden API(inhouse API) only for internal purpose.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected void RegisterHitTestCallback()
+        {
+            if (hitTestResultDataCallback == null)
+            {
+                hitTestResultDataCallback = OnHitTestResult;
+                Interop.ActorSignal.HitTestResultConnect(SwigCPtr, hitTestResultDataCallback.ToHandleRef(this));
+                NDalicPINVOKE.ThrowExceptionIfExistsDebug();
+            }
+        }
+
+        /// <summary>
+        /// Unregister custom HitTest function.
+        /// </summary>
+        /// <remarks>
+        /// This is a hidden API(inhouse API) only for internal purpose.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected void UnregisterHitTestCallback()
+        {
+            if (hitTestResultDataCallback != null)
+            {
+                Interop.ActorSignal.HitTestResultDisconnect(SwigCPtr, hitTestResultDataCallback.ToHandleRef(this));
+                NDalicPINVOKE.ThrowExceptionIfExistsDebug();
+                hitTestResultDataCallback = null;
+            }
+        }
+
+        /// <summary>
+        /// Calculate the screen position of the view.<br />
+        /// </summary>
+        /// <remarks>
+        /// This is a hidden API(inhouse API) only for internal purpose.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Vector2 CalculateScreenPosition()
+        {
+            Vector2 ret = new Vector2(Interop.Actor.CalculateScreenPosition(SwigCPtr), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Calculate the screen position and size of the view.<br />
+        /// </summary>
+        /// <remarks>
+        /// The float type Rectangle class is not ready yet.
+        /// Therefore, it transmits data in Vector4 class.
+        /// This type should later be changed to the appropriate data type.
+        /// </remarks>
+        /// <remarks>
+        /// This is a hidden API(inhouse API) only for internal purpose.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Vector4 CalculateScreenPositionSize()
+        {
+            Vector4 ret = new Vector4(Interop.Actor.CalculateScreenExtents(SwigCPtr), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
     }
 }