[NUI] Add Api for getting window from view
authorSunghyun Kim <scholb.kim@samsung.com>
Thu, 8 Jul 2021 07:15:06 +0000 (16:15 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 9 Jul 2021 10:39:50 +0000 (19:39 +0900)
In some case, The view needs to know which window it is added to.
we can using this api in this case.

src/Tizen.NUI/src/internal/Interop/Interop.Window.cs
src/Tizen.NUI/src/public/Window/Window.cs [changed mode: 0755->0644]

index be9907c..a2a87a1 100755 (executable)
@@ -246,7 +246,8 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_RequestResizeToServer")]
             public static extern void RequestResizeToServer(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
 
-
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetWindow")]
+            public static extern global::System.IntPtr Get(global::System.Runtime.InteropServices.HandleRef jarg1);
         }
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 376782b..2689d8b
@@ -59,6 +59,25 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// A helper method to get the current window where the view is added
+        /// </summary>
+        /// <param name="view">The View added to the window</param>
+        /// <returns>A Window.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        static public Window Get(View view)
+        {
+            if(view == null)
+            {
+                NUILog.Error("if there is no view, it can not get a window");
+                return null;
+            }
+
+            Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.Get(View.getCPtr(view))) as Window;
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Creates a new Window.<br />
         /// This creates an extra window in addition to the default main window<br />
         /// </summary>