-
Notifications
You must be signed in to change notification settings - Fork 29k
Use Device specific gesture configuration for scroll views #87604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Device specific gesture configuration for scroll views #87604
Conversation
…ter into gesture_settings_impl
I don't really want to hit everything at once, but making this optional for the sake of backwards compat - maybe we can migrate to this over time. @goderbauer for thoughts? |
…ter into gesture_settings_impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In every place where null is passed over the real device value a comment would be good explaining why we want the framework fallback rather than the device-provided value.
switch (kind) { | ||
case PointerDeviceKind.mouse: | ||
return kPrecisePointerPanSlop; | ||
case PointerDeviceKind.stylus: | ||
case PointerDeviceKind.invertedStylus: | ||
case PointerDeviceKind.unknown: | ||
case PointerDeviceKind.touch: | ||
return kPanSlop; | ||
return deviceTouchSlop != null ? (2 * deviceTouchSlop) : kPanSlop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 2x?
switch (kind) { | ||
case PointerDeviceKind.mouse: | ||
return kPrecisePointerPanSlop; | ||
case PointerDeviceKind.stylus: | ||
case PointerDeviceKind.invertedStylus: | ||
case PointerDeviceKind.unknown: | ||
case PointerDeviceKind.touch: | ||
return kPanSlop; | ||
return deviceTouchSlop != null ? (2 * deviceTouchSlop) : kPanSlop; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the scaleSlop below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what to do with the scale slop right now.
@@ -249,7 +249,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer { | |||
if (pressure > startPressure) { | |||
_state = _ForceState.started; | |||
resolve(GestureDisposition.accepted); | |||
} else if (event.delta.distanceSquared > computeHitSlop(event.kind)) { | |||
} else if (event.delta.distanceSquared > computeHitSlop(event.kind, null)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why null over gestureSettings.touchSlop?
@@ -497,17 +504,17 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer { | |||
|
|||
@override | |||
MultiDragPointerState createNewPointerState(PointerDownEvent event) { | |||
return _VerticalPointerState(event.position, event.kind); | |||
return _VerticalPointerState(event.position, event.kind, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why null?
@@ -2099,28 +2099,28 @@ class PointerCancelEvent extends PointerEvent with _PointerEventDescription, _Co | |||
} | |||
|
|||
/// Determine the appropriate hit slop pixels based on the [kind] of pointer. | |||
double computeHitSlop(PointerDeviceKind kind) { | |||
double computeHitSlop(PointerDeviceKind kind, double? deviceTouchSlop) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these just take a DeviceGestureSettings obj and the method can pick the appropriate value from it?
@@ -244,6 +246,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { | |||
event: event, | |||
entry: GestureBinding.instance!.gestureArena.add(event.pointer, this), | |||
doubleTapMinTime: kDoubleTapMinTime, | |||
touchSlop: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why null?
@@ -879,6 +885,7 @@ class SerialTapGestureRecognizer extends GestureRecognizer { | |||
invokeCallback<void>('onSerialTapDown', () => onSerialTapDown!(details)); | |||
} | |||
final _TapTracker tracker = _TapTracker( | |||
touchSlop: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
final double? touchSlop; | ||
|
||
/// The touch slop value for pan gestures, in logical pixels, or `null` if it | ||
/// was not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is no way to actually set it independently? Maybe document that it's either null or 2* touchSlop if touchSlop is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. In the future we could support setting it separately if need be.
@@ -104,6 +105,7 @@ class MediaQueryData { | |||
this.disableAnimations = false, | |||
this.boldText = false, | |||
this.navigationMode = NavigationMode.traditional, | |||
this.gestureSettings = const DeviceGestureSettings(touchSlop: 16.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use kTouchSlop instead of hard-coding 16?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fixes #87322
Wires up the window specific GestureSettings into a dpr transformed DeviceGestureSettings. This can be configured on the base GestureDetector, and then each gesture detector can choose which (if any) configuration it wants to use.