[NUI] Supports new native window position data type.
authorWonsik Jung <sidein@samsung.com>
Tue, 4 Oct 2022 01:18:14 +0000 (10:18 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 4 Oct 2022 11:26:36 +0000 (20:26 +0900)
Previous native window data type can not support negative window coordinates.
New native window position data type support that.

src/Tizen.NUI/src/internal/Interop/Interop.WindowIntPair.cs [new file with mode: 0644]
src/Tizen.NUI/src/internal/Window/WindowIntPair.cs [new file with mode: 0644]
src/Tizen.NUI/src/internal/Window/WindowMovedSignal.cs
src/Tizen.NUI/src/public/Window/Window.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowIntPair.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowIntPair.cs
new file mode 100644 (file)
index 0000000..2937a58
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright(c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+         internal static partial class IntPair
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_IntPair__SWIG_0")]
+            public static extern global::System.IntPtr NewIntPair();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_IntPair__SWIG_1")]
+            public static extern global::System.IntPtr NewIntPair(int x, int y);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_IntPair_SetX")]
+            public static extern void SetX(global::System.Runtime.InteropServices.HandleRef handle, int x);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_IntPair_GetX")]
+            public static extern int GetX(global::System.Runtime.InteropServices.HandleRef handle);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_IntPair_SetY")]
+            public static extern void SetY(global::System.Runtime.InteropServices.HandleRef handle, int y);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_IntPair_GetY")]
+            public static extern int GetY(global::System.Runtime.InteropServices.HandleRef handle);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_IntPair")]
+            public static extern void DeleteIntPair(global::System.Runtime.InteropServices.HandleRef handle);
+       }
+    }
+}
diff --git a/src/Tizen.NUI/src/internal/Window/WindowIntPair.cs b/src/Tizen.NUI/src/internal/Window/WindowIntPair.cs
new file mode 100644 (file)
index 0000000..74dcd02
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright(c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+    /// <summary>
+    /// Simple class for window position pairs of  integers.
+    /// Use this for integer position with window coordinates.
+    /// </summary>
+    internal class IntPair : Disposable
+    {
+        internal IntPair(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.IntPair.DeleteIntPair(swigCPtr);
+        }
+
+        /// <summary>
+        /// Default constructor for the(0, 0) tuple.
+        /// </summary>
+        public IntPair() : this(Interop.IntPair.NewIntPair(), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Default constructor for the(0, 0) tuple.
+        /// </summary>
+        /// <param name="x">The X dimension of the tuple.</param>
+        /// <param name="y">The Y dimension of the tuple.</param>
+        public IntPair(int x, int y) : this(Interop.IntPair.NewIntPair(x, y), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Sets the x dimension.
+        /// </summary>
+        /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
+        public void SetX(int x)
+        {
+            Interop.IntPair.SetX(SwigCPtr, x);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Get the x dimension.
+        /// </summary>
+        /// <return>
+        /// The x dimension stored in this 2-tuple.
+        /// </return>
+        public int GetX()
+        {
+            int ret = Interop.IntPair.GetX(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Sets the y dimension.
+        /// </summary>
+        /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
+        public void SetY(int y)
+        {
+            Interop.IntPair.SetY(SwigCPtr, y);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Get the y dimension.
+        /// </summary>
+        /// <return>
+        /// The y dimension stored in this 2-tuple.
+        /// </return>
+        public int GetY()
+        {
+            int ret = Interop.IntPair.GetY(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+    }
+}
index a6bf9ad138a71a7312f55770c3abcb1efa5df042..e74202be5ebdfcaf29fee5cc71a3f63fe5f4b668 100644 (file)
@@ -62,9 +62,9 @@ namespace Tizen.NUI
             }
         }
 
-        public bool Emit(Window window, Rectangle positionSize)
+        public bool Emit(Window window, Position2D position)
         {
-            bool ret = Interop.WindowMovedSignal.Emit(SwigCPtr, Window.getCPtr(window), Rectangle.getCPtr(positionSize));
+            bool ret = Interop.WindowMovedSignal.Emit(SwigCPtr, Window.getCPtr(window), Position2D.getCPtr(position));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
index 448cceb54e9c6091b51d0f92d22a40c2ab4df158..f0e9568bed56d9a130cdcae864623b5422ace812 100755 (executable)
@@ -1569,8 +1569,8 @@ private void TestWindowKeyEventHandler(object o, Window.KeyEventArgs e)
             {
                 throw new ArgumentNullException(nameof(position));
             }
-            var val = new Uint16Pair((uint)position.X, (uint)position.Y);
-            Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
+            var val = new IntPair(position.X, position.Y);
+            Interop.Window.SetPosition(SwigCPtr, IntPair.getCPtr(val));
             val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             // Setting Position of the window should request a relayout of the tree.
@@ -1578,8 +1578,8 @@ private void TestWindowKeyEventHandler(object o, Window.KeyEventArgs e)
 
         internal Position2D GetPosition()
         {
-            var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
-            Position2D ret = new Position2D(val.GetX(), val.GetY());
+            var val = new IntPair(Interop.Window.GetPosition(SwigCPtr), true);
+            Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
             val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
index 11965879d16593f76ba17fddbbc5e5867e8110bb..d26eaa15b0dd8ce2c280f89cde3ab66e38b13dd7 100755 (executable)
@@ -12,6 +12,16 @@ namespace Tizen.NUI.Samples
   public class BorderWindowTest : IExample
   {
     string tag = "NUITEST";
+    private const string KEY_BACK = "XF86Back";
+    private const string KEY_ESCAPE = "Escape";
+    private const string KEY_NUM_1 = "1";
+    private const string KEY_NUM_2 = "2";
+    private const string KEY_NUM_3 = "3";
+    private const string KEY_NUM_4 = "4";
+    private const string KEY_NUM_5 = "5";
+    private const string KEY_PARENT_ABOVE = "6";
+    private const string KEY_PARENT_BELOW = "7";
+
     private Window win;
     private Window subWindowOne = null;
     private Window subWindowTwo = null;
@@ -269,6 +279,49 @@ namespace Tizen.NUI.Samples
     }
 
 
+    private void OnKeyEvent(object sender, Window.KeyEventArgs e)
+    {
+        if (e.Key.State == Key.StateType.Down)
+        {
+            log.Debug(tag, $"key down! key={e.Key.KeyPressedName}");
+
+            switch (e.Key.KeyPressedName)
+            {
+                case KEY_BACK:
+                case KEY_ESCAPE:
+                    break;
+
+                case KEY_NUM_1:
+                    subWindowOne.WindowPosition = new Position2D(10, 20);
+                    break;
+
+                case KEY_NUM_2:
+                    subWindowOne.WindowPosition = new Position2D(-10, 20);
+                    break;
+
+                case KEY_NUM_3:
+
+                    break;
+
+                case KEY_NUM_4:
+                    break;
+
+                case KEY_NUM_5:
+                    break;
+
+                case KEY_PARENT_ABOVE:
+                    break;
+
+                case KEY_PARENT_BELOW:
+                    break;
+
+                default:
+                    log.Debug(tag, $"no test!");
+                    break;
+            }
+        }
+    }
+
     private void OnWindowMoved(object sender, WindowMovedEventArgs e)
     {
         Position2D position = e.WindowPosition;
@@ -305,6 +358,7 @@ namespace Tizen.NUI.Samples
         animation.Looping = true;
         animation.Play();
 
+        subWindowOne.KeyEvent += OnKeyEvent;
         subWindowOne.Moved += OnWindowMoved;
       }
       else