* Gesture recognizer cleanup
1) Make OneSequenceGestureRecognizer.addAllowedPointer()
call startTrackingPointer(), and change subclasses to
call super.addAllowedPointer() in place of manually
calling startTrackingPointer().
2) Fix addAllowedPointer overrides to take PointerDownEvent
where some were taking PointerEvent.
3) Add API documentation to OneSequenceGestureRecognizer
4) Make the following fields in OneSequenceGestureRecognizer
private with public getters instead of publicly writable:
`state`, `primaryPointer`, and `initialPosition`.
5) Clean up gesture recognizer state in
OneSequenceGestureRecognizer.didStopTrackingLastPointer.
Fixes#81883
This adds support for GestureDetector.onLongPressDown and
GestureDetector.onLongPressCancel, allowing callers to register
interest in the initial pointer contact that might turn into
a long-press (and the associated cancel event if the gesture
loses).
* fix PointerUpEvent conversion PointerMoveEvent needs to use the default buttons value.(#73286)
* feat PointerMoveEvent conversion adds test cases
* fix event conversion may modify the original buttons value.
* Update packages/flutter/lib/src/gestures/resampler.dart
Co-authored-by: David Reveman <dreveman@gmail.com>
Timer based pointer event resampling
This provides two improvements to pointer event resampling:
1. PostFrameCallbacks are used instead of scheduling frames. This
avoids unnecessary rendering work when resampling is used.
2. Resampling continues when frames are not produced. I.e. input
events keep being delivered at a fixed frequency even if frame
production is taking a long time.
This fixes#72924
Co-authored-by: David Reveman <reveman@google.com>
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
* Improve resampling of up and remove events.
This improves resampling of these events by searching
for them until the next approximate sample time.
Co-authored-by: David Reveman <reveman@google.com>
* PointerEvent.local* properties are calculated lazily; other properties are delegated to original.
* Transformed PointerEvent becomes a subclass of its original class.
* Unnamed constructors no longer accepts transform and origin.
This adds the neccessary synthetic move/hover events to
resampler, which is needed for position to not change as
part of a down, up, or remove event.
Co-authored-by: David Reveman <reveman@google.com>
We've gotten feedback that the VelocityTracker change was disruptive, though it did not break any of the flutter framework or customer tests. In order to make the change non-breaking, PointerDeviceKind parameter can be made optional.
Nevertheless, this parameter should be provided so that the existing touch handlers can use more accurate gestures on mouse/stylus inputs, so we can encourage this by deprecating the default constructor and pointing users towards the VelocityTracker.withKind constructor that takes a non-optional parameter
Currently the framework uses fairly large "hit slop" values to disambiguate taps from drags/pans. This makes sense on touch devices where the interaction is not very precise, on mice however it can feel as if the UI is lagging. This is immediately noticeable on our infra dashboard, where it takes almost half of a grid square of drag before the actual drag kicks in.
One potential solution is to always use smaller constants depending on whether the interaction is mouse or touch based. The only reasonable choice is to use the pointer device kind and not target platform - same platform can have different input sources. This requires exposing the pointer device kind in a few new places in several of the gesture detectors, and using the enum to compute the correct hit slop from an expanded set of constants.
This almost works, however there are a few places (notably ListViews) which uses the touch hit slop as a default value in scroll physics. It does not seem like it will be easy to disambiguate a user provided scroll physics constant from the default and/or adjust it somehow - this might require significant changes to scroll physics which I have left out of this PR.
This PR does not adjust:
kTouchSlop used in scroll_physics.dart's minFlingDistance
kTouchSlop used in PrimaryPointerGestureRecognizer/LongPressGestureRecognizer