[NUI] Add window Min/Max Feature
authorWonsik Jung <sidein@samsung.com>
Wed, 9 Mar 2022 17:37:13 +0000 (02:37 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Mar 2022 04:29:25 +0000 (13:29 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.Window.cs
src/Tizen.NUI/src/public/Window/Window.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs

index e6a862d..e6713b7 100755 (executable)
@@ -274,6 +274,18 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_ExcludeInputRegion")]
             public static extern void ExcludeInputRegion(global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef inputRegion);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Maximize")]
+            public static extern void Maximize(global::System.Runtime.InteropServices.HandleRef window, bool maximize);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_IsMaximized")]
+            public static extern bool IsMaximized(global::System.Runtime.InteropServices.HandleRef window);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Minimize")]
+            public static extern void Minimize(global::System.Runtime.InteropServices.HandleRef window, bool minimize);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_IsMinimized")]
+            public static extern bool IsMinimized(global::System.Runtime.InteropServices.HandleRef window);
         }
     }
 }
index 57546f7..f9ebf3b 100644 (file)
@@ -188,6 +188,8 @@ namespace Tizen.NUI
         /// </summary>
         [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
         [EditorBrowsable(EditorBrowsableState.Never)]
+        //  This is already deprecated, so suppress warning here.
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
         public enum EffectStates
         {
             /// <summary>
@@ -238,6 +240,8 @@ namespace Tizen.NUI
         /// </summary>
         [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
         [EditorBrowsable(EditorBrowsableState.Never)]
+        //  This is already deprecated, so suppress warning here.
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
         public enum EffectTypes
         {
             /// <summary>
@@ -1365,6 +1369,7 @@ namespace Tizen.NUI
             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            val.Dispose();
             return ret;
         }
 
@@ -1463,6 +1468,7 @@ namespace Tizen.NUI
             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            val.Dispose();
             return ret;
         }
 
@@ -1571,6 +1577,60 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Maximizes window's size.
+        /// If this function is called with true, window will be resized with screen size.
+        /// Otherwise window will be resized with previous size.
+        /// It is for the window's MAX button in window's border.
+        /// If window border is supported by display server, it is not necessary.
+        /// </summary>
+        /// <param name="max">If window is maximized or unmaximized.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Maximize(bool max)
+        {
+            Interop.Window.Maximize(SwigCPtr, max);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Returns whether the window is maximized or not.
+        /// </summary>
+        /// <returns>True if the window is maximized, false otherwise.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsMaximized()
+        {
+            bool ret = Interop.Window.IsMaximized(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Minimizes window's size.
+        /// If this function is called with true, window will be iconified.
+        /// Otherwise window will be activated.
+        /// It is for the window's MIN button in window border.
+        /// If window border is supported by display server, it is not necessary.
+        /// </summary>
+        /// <param name="min">If window is minimized or unminimized.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Minimize(bool min)
+        {
+            Interop.Window.Minimize(SwigCPtr, min);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Returns whether the window is minimized or not.
+        /// </summary>
+        /// <returns>True if the window is minimized, false otherwise.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsMinimized()
+        {
+            bool ret = Interop.Window.IsMinimized(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Add FrameUpdateCallback
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index f7f2fbf..9ff6f99 100644 (file)
@@ -17,6 +17,12 @@ namespace Tizen.NUI.Samples
 
         int addingInput;
 
+        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";
+
         void Initialize()
         {
             mainWin = NUIApplication.GetDefaultWindow();
@@ -93,8 +99,19 @@ namespace Tizen.NUI.Samples
                         //Exit();
                         break;
 
-                    case "1":
-                        log.Fatal(tag, $"pressed 1!");
+                    case KEY_NUM_1:
+                        log.Fatal(tag, $"pressed Key Num 1!");
+                        break;
+
+                    case KEY_NUM_2:
+                        mainWin.Maximize(true);
+                        break;
+
+                    case KEY_NUM_3:
+                        if(mainWin.IsMaximized())
+                        {
+                            mainWin.Maximize(false);
+                        }
                         break;
 
                     default: