[NUI] Add RotationCompletedAcknowledgement APIs
authorWonsik Jung <sidein@samsung.com>
Fri, 17 Mar 2023 01:18:08 +0000 (10:18 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 20 Mar 2023 11:28:47 +0000 (20:28 +0900)
Add RotationCompletedAcknowledgement APIs in Window.
The APIs are SetNeedsRotationCompletedAcknowledgement and SendRotationCompletedAcknowledgement

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 a85b913..03d756b 100755 (executable)
@@ -307,6 +307,12 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetLastTouchEvent")]
             public static extern global::System.IntPtr GetLastTouchEvent(global::System.Runtime.InteropServices.HandleRef window);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SetNeedsRotationCompletedAcknowledgement")]
+            public static extern void SetNeedsRotationCompletedAcknowledgement(global::System.Runtime.InteropServices.HandleRef window, bool needAcknowledgement);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SendRotationCompletedAcknowledgement")]
+            public static extern void SendRotationCompletedAcknowledgement(global::System.Runtime.InteropServices.HandleRef window);
         }
     }
 }
index 5b02cd2..a016d14 100755 (executable)
@@ -1770,6 +1770,34 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the necessary for window rotation Acknowledgement.
+        /// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
+        ///
+        /// This function is supprot that application has the window rotation acknowledgement's control.
+        /// It means display server waits when application's rotation work is finished.
+        /// It is useful application has the other rendering engine which works asynchronous.
+        /// For instance, GlView.
+        /// </summary>
+        /// <param name="needAcknowledgement">the flag is true if window rotation acknowledge is sent.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
+        {
+            Interop.Window.SetNeedsRotationCompletedAcknowledgement(SwigCPtr, needAcknowledgement);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// send the Acknowledgement to complete window rotation.
+        /// For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SendRotationCompletedAcknowledgement()
+        {
+            Interop.Window.SendRotationCompletedAcknowledgement(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
         /// Add FrameUpdateCallback
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index 41fcd2a..f3fe59b 100644 (file)
@@ -18,12 +18,20 @@ namespace Tizen.NUI.Samples
 
         int addingInput;
         Timer tm;
+        bool manualRotation;
+        int rotationCount;
 
         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_NUM_6 = "6";
+        private const string KEY_NUM_7 = "7";
+        private const string KEY_NUM_8 = "8";
+        private const string KEY_NUM_9 = "9";
+        private const string KEY_NUM_0 = "0";
+
 
         void Initialize()
         {
@@ -65,6 +73,9 @@ namespace Tizen.NUI.Samples
             animation.Looping = true;
             animation.Play();
 
+            manualRotation = false;
+            rotationCount = 0;
+
             tm = new Timer(100);
             tm.Tick += Tm_Tick;
             tm.Start();
@@ -74,6 +85,16 @@ namespace Tizen.NUI.Samples
         {
             bool rotating = mainWin.IsWindowRotating();
             log.Fatal(tag, $"window is Rotating: {rotating}");
+            if(rotating && manualRotation)
+            {
+                rotationCount++;
+                if(rotationCount > 100)
+                {
+                  log.Fatal(tag, $"call SendRotationCompletedAcknowledgement");
+                  mainWin.SendRotationCompletedAcknowledgement();
+                  rotationCount = 0;
+                }
+            }
             return true;
         }
 
@@ -142,6 +163,22 @@ namespace Tizen.NUI.Samples
                     case KEY_NUM_5:
                         mainWin.SetMimimumSize(new Size2D(100, 100));
                         break;
+                    case KEY_NUM_6:
+                        if(manualRotation == false)
+                        {
+                            manualRotation = true;
+                            log.Fatal(tag, $"Enable manual rotation");
+                        }
+                        else
+                        {
+                            manualRotation = false;
+                            log.Fatal(tag, $"Disable manual rotation");
+                        }
+                        mainWin.SetNeedsRotationCompletedAcknowledgement(manualRotation);
+                        break;
+                    case KEY_NUM_7:
+                        mainWin.SetMimimumSize(new Size2D(100, 100));
+                        break;
 
                     default:
                         log.Fatal(tag, $"no test!");