[NUI] Introduce WindowLayoutType enum and SetLayout Method
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Thu, 23 Mar 2023 08:41:59 +0000 (17:41 +0900)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Wed, 5 Apr 2023 12:12:53 +0000 (21:12 +0900)
The new `SetLayout` method allows users to easily snap windows to specific positions and sizes.
This feature is allowing users to quickly arrange their windows in a convenient and efficient manner.

src/Tizen.NUI/src/internal/Interop/Interop.Window.cs
src/Tizen.NUI/src/public/Common/NUIConstants.cs
src/Tizen.NUI/src/public/Window/Window.cs

index 32933b3..d7b9acf 100755 (executable)
@@ -301,6 +301,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Set_Minimum_Size")]
             public static extern void SetMimimumSize(global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef size);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SetLayout")]
+            public static extern void SetLayout(global::System.Runtime.InteropServices.HandleRef window, uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_IsWindowRotating")]
             [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
             public static extern bool IsWindowRotating(global::System.Runtime.InteropServices.HandleRef window);
index ba073f7..0ece9f7 100755 (executable)
@@ -786,6 +786,70 @@ namespace Tizen.NUI
         Desktop        
     }
 
+    /// <summary>
+    /// An enum of window layout types.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum WindowLayoutType
+    {
+        /// <summary>
+        /// Window is placed on the left half of the screen
+        /// </summary>
+        LeftHalf,
+        /// <summary>
+        /// Window is placed on the right half of the screen
+        /// </summary>
+        RightHalf,
+        /// <summary>
+        /// Window is placed on the top half of the screen
+        /// </summary>
+        TopHalf,
+        /// <summary>
+        /// Window is placed on the bottom half of the screen
+        /// </summary>
+        BottomHalf,
+        /// <summary>
+        /// Window is placed on the upper-left quarter of the screen
+        /// </summary>
+        UpperLeftQuarter,
+        /// <summary>
+        /// Window is placed on the upper-right quarter of the screen
+        /// </summary>
+        UpperRightQuarter,
+        /// <summary>
+        /// Window is placed on the lower-left quarter of the screen
+        /// </summary>
+        LowerLeftQuarter,
+        /// <summary>
+        /// Window is placed on the lower-right quarter of the screen
+        /// </summary>
+        LowerRightQuarter,
+        /// <summary>
+        /// Window is placed on the left third of the screen horizontally
+        /// </summary>
+        LeftThird,
+        /// <summary>
+        /// Window is placed on the center third of the screen horizontally
+        /// </summary>
+        CenterThird,
+        /// <summary>
+        /// Window is placed on the right third of the screen horizontally
+        /// </summary>
+        RightThird,
+        /// <summary>
+        /// Window is placed on the top third of the screen vertically
+        /// </summary>
+        TopThird,
+        /// <summary>
+        /// Window is placed on the middle third of the screen vertically
+        /// </summary>
+        MiddleThird,
+        /// <summary>
+        /// Window is placed on the bottom third of the screen vertically
+        /// </summary>
+        BottomThird,
+    }
+
     /// <since_tizen> 3 </since_tizen>
     [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
     public enum DisposeTypes
index 0d1fea9..8e7f44f 100755 (executable)
@@ -1753,6 +1753,83 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the layout of the window.
+        /// </summary>
+        /// <param name="numCols">The number of columns in the layout.</param>
+        /// <param name="numRows">The number of rows in the layout.</param>
+        /// <param name="column">The column number of the window within the layout.</param>
+        /// <param name="row">The row number of the window within the layout.</param>
+        /// <param name="colSpan">The number of columns the window should span within the layout.</param>
+        /// <param name="rowSpan">The number of rows the window should span within the layout.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetLayout(uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan)
+        {
+            Interop.Window.SetLayout(SwigCPtr, numCols, numRows, column, row, colSpan, rowSpan);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+        }
+
+        /// <summary>
+        /// Sets the layout of the window.
+        /// </summary>
+        /// <param name="layoutType">The type of layout to set for the window.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetLayout(WindowLayoutType layoutType)
+        {
+            switch (layoutType)
+            {
+                case WindowLayoutType.LeftHalf:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 1, 0, 0, 1, 1);
+                    break;
+                case WindowLayoutType.RightHalf:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 1, 1, 0, 1, 1);
+                    break;
+
+                case WindowLayoutType.TopHalf:
+                    Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 0, 1, 1);
+                    break;
+                case WindowLayoutType.BottomHalf:
+                    Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 1, 1, 1);
+                    break;
+
+                case WindowLayoutType.UpperLeftQuarter:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 0, 1, 1);
+                    break;
+                case WindowLayoutType.UpperRightQuarter:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 0, 1, 1);
+                    break;
+                case WindowLayoutType.LowerLeftQuarter:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 1, 1, 1);
+                    break;
+                case WindowLayoutType.LowerRightQuarter:
+                    Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 1, 1, 1);
+                    break;
+
+                case WindowLayoutType.LeftThird:
+                    Interop.Window.SetLayout(SwigCPtr, 3, 1, 0, 0, 1, 1);
+                    break;
+                case WindowLayoutType.CenterThird:
+                    Interop.Window.SetLayout(SwigCPtr, 3, 1, 1, 0, 1, 1);
+                    break;
+                case WindowLayoutType.RightThird:
+                    Interop.Window.SetLayout(SwigCPtr, 3, 1, 2, 0, 1, 1);
+                    break;
+
+                case WindowLayoutType.TopThird:
+                    Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 0, 1, 1);
+                    break;
+                case WindowLayoutType.MiddleThird:
+                    Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 1, 1, 1);
+                    break;
+                case WindowLayoutType.BottomThird:
+                    Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 2, 1, 1);
+                    break;
+            }
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+        }
+
+        /// <summary>
         /// Query whether window is rotating or not.
         /// </summary>
         /// <returns>True if window is rotating, false otherwise.</returns>
@@ -1844,7 +1921,7 @@ namespace Tizen.NUI
             {
                 return;
             }
-            
+
             this.DisconnectNativeSignals();
 
             if (type == DisposeTypes.Explicit)