[NUI] Supports key event of repeat and delay of each way.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / Window.cs
index dc80b3f..2cd8307 100755 (executable)
@@ -41,6 +41,9 @@ namespace Tizen.NUI
         private string windowTitle;
         private List<Layer> childLayers = new List<Layer>();
         private LayoutController localController;
+        private Key internalLastKeyEvent;
+        private Touch internalLastTouchEvent;
+        private Timer internalHoverTimer;
 
         static internal bool IsSupportedMultiWindow()
         {
@@ -563,6 +566,24 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// Gets or sets whether the window will update partial area or full area.
+        /// If this value is true, window will update and render partial area.
+        /// If false, full area updated.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool PartialUpdate
+        {
+            get
+            {
+                return IsPartialUpdate();
+            }
+            set
+            {
+                SetPartialUpdate(value);
+            }
+        }
+
         internal static Vector4 DEFAULT_BACKGROUND_COLOR
         {
             get
@@ -1005,7 +1026,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void KeepRendering(float durationSeconds)
         {
-            Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
+            Interop.Window.KeepRendering(SwigCPtr, durationSeconds);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
@@ -1099,6 +1120,62 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the keyboard repeat information of horizontal way.
+        /// </summary>
+        /// <param name="rate">The key repeat rate value in seconds.</param>
+        /// <param name="delay">The key repeat delay value in seconds.</param>
+        /// <returns>True if setting the keyboard repeat succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool SetKeyboardHorizentalRepeatInfo(float rate, float delay)
+        {
+            bool ret = Interop.Window.SetKeyboardHorizentalRepeatInfo(rate, delay);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Gets the keyboard repeat information of horizontal way.
+        /// </summary>
+        /// <param name="rate">The key repeat rate value in seconds.</param>
+        /// <param name="delay">The key repeat delay value in seconds.</param>
+        /// <returns>True if setting the keyboard repeat succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool GetKeyboardHorizentalRepeatInfo(out float rate, out float delay)
+        {
+            bool ret = Interop.Window.GetKeyboardHorizentalRepeatInfo(out rate, out delay);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Sets the keyboard repeat information of vertical way.
+        /// </summary>
+        /// <param name="rate">The key repeat rate value in seconds.</param>
+        /// <param name="delay">The key repeat delay value in seconds.</param>
+        /// <returns>True if setting the keyboard repeat succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool SetKeyboardVerticalRepeatInfo(float rate, float delay)
+        {
+            bool ret = Interop.Window.SetKeyboardVerticalRepeatInfo(rate, delay);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Gets the keyboard repeat information of vertical way.
+        /// </summary>
+        /// <param name="rate">The key repeat rate value in seconds.</param>
+        /// <param name="delay">The key repeat delay value in seconds.</param>
+        /// <returns>True if setting the keyboard repeat succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool GetKeyboardVerticalRepeatInfo(out float rate, out float delay)
+        {
+            bool ret = Interop.Window.GetKeyboardVerticalRepeatInfo(out rate, out delay);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Adds a layer to the stage.
         /// </summary>
         /// <param name="layer">Layer to add.</param>
@@ -1132,6 +1209,36 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Feeds a hover event into the window. <br />
+        /// This is feed after a default time of 48 ms. You can also set this time.
+        /// </summary>
+        /// <param name="time">The time of how much later it will be feed (default is 48ms)</param>
+        /// <remarks>If you want to do FeedHover after the UI is updated, it is recommended to set the time to at least 16ms. This will be a good time waiting for the UI to update.<br />
+        /// and LazyFeedHover called within the set time are ignored. Only the last request becomes a FeedHover.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void LazyFeedHover(uint time = 48)
+        {
+            if (internalHoverTimer == null)
+            {
+                internalHoverTimer = new Timer(time);
+                internalHoverTimer.Tick += (s, e) =>
+                {
+                    FeedHover();
+                    internalHoverTimer?.Stop();
+                    internalHoverTimer?.Dispose();
+                    internalHoverTimer = null;
+                    return false;
+                };
+                internalHoverTimer.Start();
+            }
+            else
+            {
+                internalHoverTimer.Start();
+            }
+        }
+
+        /// <summary>
         /// Feeds a touch point into the window.
         /// </summary>
         /// <param name="touchPoint">The touch point to feed.</param>
@@ -1153,6 +1260,27 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Feeds a hover event into the window.
+        /// </summary>
+        /// <param name="touchPoint">The touch point to feed hover event. If null is entered, the feed hover event is generated with the last inputed touch point.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal void FeedHover(TouchPoint touchPoint = null)
+        {
+            if (touchPoint == null)
+            {
+                using Touch touch = GetLastTouchEvent();
+                if (touch == null || touch.GetPointCount() < 1)
+                {
+                    return;
+                }
+                using Vector2 screenPosition = touch.GetScreenPosition(0);
+                touchPoint = new TouchPoint(touch.GetDeviceId(0), TouchPoint.StateType.Motion, screenPosition.X, screenPosition.Y);
+            }
+            Interop.Window.FeedHoverEvent(SwigCPtr, TouchPoint.getCPtr(touchPoint));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
         /// Allows at least one more render, even when paused.
         /// The window should be shown, not minimised.
         /// </summary>
@@ -1383,7 +1511,7 @@ namespace Tizen.NUI
 
             if (isBorderWindow)
             {
-                Interop.Actor.Add(GetBorderWindowRootLayer().SwigCPtr, layer.SwigCPtr);
+                Interop.Actor.Add(GetRootLayer().SwigCPtr, layer.SwigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
             }
             else
@@ -1583,6 +1711,27 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Set the window use partial update or not.
+        /// </summary>
+        /// <param name="enabled">If window enable partial update or disable.</param>
+        internal void SetPartialUpdate(bool enabled)
+        {
+            Interop.Window.SetPartialUpdateEnabled(SwigCPtr, enabled);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Returns whether the window is enabled partial update or not.
+        /// </summary>
+        /// <returns>True if the window is enabled partial update, false otherwise.</returns>
+        internal bool IsPartialUpdate()
+        {
+            bool ret = Interop.Window.IsPartialUpdateEnabled(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Enables the floating mode of window.
         /// The floating mode is to support window is moved or resized by display server.
         /// For example, if the video-player window sets the floating mode,
@@ -1599,6 +1748,18 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Returns whether the window is floating mode or not.
+        /// </summary>
+        /// <returns>True if the window is enabled floating mode, false otherwise.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsFloatingModeEnabled()
+        {
+            bool ret = Interop.Window.IsFloatingModeEnabled(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Requests to display server for the window is moved by display server.
         /// It can be work with setting window floating mode.
         /// </summary>
@@ -1656,6 +1817,70 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the pointer constraints lock.
+        /// </summary>
+        /// <returns>True if PointerConstraintsLock succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool PointerConstraintsLock()
+        {
+            bool ret = Interop.Window.PointerConstraintsLock(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Sets the pointer constraints unlock.
+        /// </summary>
+        /// <returns>True if PointerConstraintsUnlock succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool PointerConstraintsUnlock()
+        {
+            bool ret = Interop.Window.PointerConstraintsUnlock(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Sets the locked pointer region.
+        /// </summary>
+        /// <param name="x">The x position.</param>
+        /// <param name="y">The y position.</param>
+        /// <param name="width">The width.</param>
+        /// <param name="height">The height.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void LockedPointerRegionSet(int x, int y, int width, int height)
+        {
+            Interop.Window.LockedPointerRegionSet(SwigCPtr, x, y, width, height);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Sets the locked pointer cursor position hintset
+        /// </summary>
+        /// <param name="x">The x position.</param>
+        /// <param name="y">The y position.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void LockedPointerCursorPositionHintSet(int x, int y)
+        {
+            Interop.Window.LockedPointerCursorPositionHintSet(SwigCPtr, x, y);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Sets the pointer warp. The pointer moves to the set coordinates.
+        /// </summary>
+        /// <param name="x">The x position.</param>
+        /// <param name="y">The y position.</param>
+        /// <returns>True if PointerWarp succeeds.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool PointerWarp(int x, int y)
+        {
+            bool ret = Interop.Window.PointerWarp(SwigCPtr, x, y);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <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.
@@ -1849,9 +2074,13 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public Key GetLastKeyEvent()
         {
-            Key ret = new Key(Interop.Window.GetLastKeyEvent(SwigCPtr), false);
+            if(internalLastKeyEvent == null)
+            {
+                internalLastKeyEvent = new Key();
+            }
+            Interop.Window.InternalRetrievingLastKeyEvent(SwigCPtr, internalLastKeyEvent.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
+            return internalLastKeyEvent;
         }
 
         /// <summary>
@@ -1861,9 +2090,13 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public Touch GetLastTouchEvent()
         {
-            Touch ret = new Touch(Interop.Window.GetLastTouchEvent(SwigCPtr), false);
+            if(internalLastTouchEvent == null)
+            {
+                internalLastTouchEvent = new Touch();
+            }
+            Interop.Window.InternalRetrievingLastTouchEvent(SwigCPtr, internalLastTouchEvent.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
+            return internalLastTouchEvent;
         }
 
         /// <summary>
@@ -1947,6 +2180,15 @@ namespace Tizen.NUI
                 childLayers.Clear();
 
                 localController?.Dispose();
+
+                internalLastKeyEvent?.Dispose();
+                internalLastKeyEvent = null;
+                internalLastTouchEvent?.Dispose();
+                internalLastTouchEvent = null;
+
+                internalHoverTimer?.Stop();
+                internalHoverTimer?.Dispose();
+                internalHoverTimer = null;
             }