From: Eunki, Hong Date: Wed, 15 Jun 2022 13:25:04 +0000 (+0900) Subject: [NUI] Add maximum motion age of pan motion gesture X-Git-Tag: accepted/tizen/unified/20231205.024657~892 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=d5d4d59c5d56d9d1db3be8243472323f3724ef10;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add maximum motion age of pan motion gesture When event spend so long time, a lot of events are queued. Ecore cannot skip these event, so we make some heuristic threshold of discard motion events on pan gesture. Default age is UINT_MAX ms, (~= 49 days) Currently, we make maximum age as hard-coded value in NUI.Component.Slider.Internal Signed-off-by: Eunki, Hong --- diff --git a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs index 0ca4e3b..39734c3 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs @@ -85,6 +85,7 @@ namespace Tizen.NUI.Components private float discreteValue = 0; private PanGestureDetector panGestureDetector = null; + private readonly uint panGestureMotionEventAge = 16; // TODO : Can't we get this value from system configure? private float currentSlidedOffset; private EventHandler sliderValueChangedHandler; private EventHandler sliderSlidingStartedHandler; @@ -107,6 +108,7 @@ namespace Tizen.NUI.Components panGestureDetector = new PanGestureDetector(); panGestureDetector.Attach(this); + panGestureDetector.SetMaximumMotionEventAge(panGestureMotionEventAge); panGestureDetector.Detected += OnPanGestureDetected; this.Layout = new LinearLayout() @@ -403,6 +405,17 @@ namespace Tizen.NUI.Components if (e.PanGesture.State == Gesture.StateType.Finished) { + // Update as finished position value + if (direction == DirectionType.Horizontal) + { + CalculateCurrentValueByGesture(e.PanGesture.Displacement.X); + } + else if (direction == DirectionType.Vertical) + { + CalculateCurrentValueByGesture(-e.PanGesture.Displacement.Y); + } + UpdateValue(); + if (isValueShown) { valueIndicatorImage.Hide(); diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index ee33c57..95a830e 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -1749,26 +1749,21 @@ namespace Tizen.NUI.Components { currentSlidedOffset += offset; - if (currentSlidedOffset <= 0) + float resultValue = this.CurrentValue; + + int bgTrackLength = GetBgTrackLength(); + if (bgTrackLength != 0) { - this.CurrentValue = minValue; + resultValue = ((currentSlidedOffset / (float)bgTrackLength) * (float)(maxValue - minValue)) + minValue; } - else if (currentSlidedOffset >= GetBgTrackLength()) + + if (IsDiscrete) { - this.CurrentValue = maxValue; + this.CurrentValue = CalculateDiscreteValue(resultValue); } else { - int bgTrackLength = GetBgTrackLength(); - if (bgTrackLength != 0) - { - this.CurrentValue = ((currentSlidedOffset / (float)bgTrackLength) * (float)(maxValue - minValue)) + minValue; - } - } - - if (IsDiscrete) - { - this.CurrentValue = CalculateDiscreteValue(this.CurrentValue); + this.CurrentValue = resultValue; } } @@ -1822,7 +1817,7 @@ namespace Tizen.NUI.Components { if (this.FocusableInTouch == false && editMode == false) { - isFocused = false; + isFocused = false; } PointStateType state = e.Touch.GetState(0); @@ -1851,11 +1846,15 @@ namespace Tizen.NUI.Components if (bgTrackLength != 0) { - this.CurrentValue = ((currentSlidedOffset / (float)bgTrackLength) * (maxValue - minValue)) + minValue; + float resultValue = ((currentSlidedOffset / (float)bgTrackLength) * (maxValue - minValue)) + minValue; if (IsDiscrete) { - this.CurrentValue = CalculateDiscreteValue(this.CurrentValue); + this.CurrentValue = CalculateDiscreteValue(resultValue); + } + else + { + this.CurrentValue = resultValue; } } } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.PanGestureDetector.cs b/src/Tizen.NUI/src/internal/Interop/Interop.PanGestureDetector.cs index 5b6212f..cda834b 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.PanGestureDetector.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.PanGestureDetector.cs @@ -99,12 +99,18 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_SetMaximumTouchesRequired")] public static extern void SetMaximumTouchesRequired(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_SetMaximumMotionEventAge")] + public static extern void SetMaximumMotionEventAge(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_GetMinimumTouchesRequired")] public static extern uint GetMinimumTouchesRequired(global::System.Runtime.InteropServices.HandleRef jarg1); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_GetMaximumTouchesRequired")] public static extern uint GetMaximumTouchesRequired(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_GetMaximumMotionEventAge")] + public static extern uint GetMaximumMotionEventAge(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PanGestureDetector_AddAngle__SWIG_0")] public static extern void AddAngle(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); diff --git a/src/Tizen.NUI/src/public/Events/PanGestureDetector.cs b/src/Tizen.NUI/src/public/Events/PanGestureDetector.cs index bdf55b5..64422af 100755 --- a/src/Tizen.NUI/src/public/Events/PanGestureDetector.cs +++ b/src/Tizen.NUI/src/public/Events/PanGestureDetector.cs @@ -342,6 +342,18 @@ namespace Tizen.NUI } /// + /// Set a maximum duration of motion event that is able to live on the pan gesture event queue. + /// If duration exceed it, the motion event is discarded. + /// + /// Maximum age of motion events as milliseconds + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetMaximumMotionEventAge(uint maximumAgeMilliSecond) + { + Interop.PanGestureDetector.SetMaximumMotionEventAge(SwigCPtr, maximumAgeMilliSecond); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// /// Retrieves the minimum number of touches required for the pan gesture to be detected. /// /// The minimum touches required @@ -368,6 +380,18 @@ namespace Tizen.NUI } /// + /// Retrieves the maximum age for the pan gesture motion as milliseconds. + /// + /// The maximum age of motion events as milliseconds + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetMaximumMotionEventAge() + { + uint ret = Interop.PanGestureDetector.GetMaximumMotionEventAge(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// /// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.
/// If an angle of 0.0 degrees is specified and the threshold is 45 degrees then the acceptable direction range is from -45 to 45 degrees.
/// The angle added using this API is only checked when the gesture first starts, after that, this detector will emit the gesture regardless of what angle the pan is moving.