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 <eunkiki.hong@samsung.com>
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<SliderValueChangedEventArgs> sliderValueChangedHandler;
private EventHandler<SliderSlidingStartedEventArgs> sliderSlidingStartedHandler;
panGestureDetector = new PanGestureDetector();
panGestureDetector.Attach(this);
+ panGestureDetector.SetMaximumMotionEventAge(panGestureMotionEventAge);
panGestureDetector.Detected += OnPanGestureDetected;
this.Layout = new LinearLayout()
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();
{
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;
}
}
{
if (this.FocusableInTouch == false && editMode == false)
{
- isFocused = false;
+ isFocused = false;
}
PointStateType state = e.Touch.GetState(0);
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;
}
}
}
[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);
}
/// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="maximumAgeMilliSecond">Maximum age of motion events as milliseconds</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetMaximumMotionEventAge(uint maximumAgeMilliSecond)
+ {
+ Interop.PanGestureDetector.SetMaximumMotionEventAge(SwigCPtr, maximumAgeMilliSecond);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// <summary>
/// Retrieves the minimum number of touches required for the pan gesture to be detected.
/// </summary>
/// <returns>The minimum touches required</returns>
}
/// <summary>
+ /// Retrieves the maximum age for the pan gesture motion as milliseconds.
+ /// </summary>
+ /// <returns>The maximum age of motion events as milliseconds</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetMaximumMotionEventAge()
+ {
+ uint ret = Interop.PanGestureDetector.GetMaximumMotionEventAge(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ /// <summary>
/// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.<br />
/// 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.<br />
/// 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.