-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
[SPEC] Overhaul gesture system #1715
Labels
feature
This issue requests a new feature
P: 2 (soon™?)
S: core
Scoped to the core flutter_map functionality
Milestone
Comments
josxha
changed the title
Rewrite gesture system and fix bugs from #1529
Rewrite gesture system
Nov 3, 2023
Example implementation of the new `InteractiveFlags` class@immutable
class InteractiveFlags {
const InteractiveFlags._({
required this.drag,
required this.flingAnimation,
required this.pinchMove,
required this.pinchZoom,
required this.doubleTapZoom,
required this.doubleTapDragZoom,
required this.scrollWheelZoom,
required this.rotate,
});
const InteractiveFlags.all({
this.drag = true,
this.flingAnimation = true,
this.pinchMove = true,
this.pinchZoom = true,
this.doubleTapZoom = true,
this.doubleTapDragZoom = true,
this.scrollWheelZoom = true,
this.rotate = true,
});
const InteractiveFlags.none({
this.drag = false,
this.flingAnimation = false,
this.pinchMove = false,
this.pinchZoom = false,
this.doubleTapZoom = false,
this.doubleTapDragZoom = false,
this.scrollWheelZoom = false,
this.rotate = false,
});
/// Enable panning with a single finger or cursor
final bool drag;
/// Enable fling animation after panning if velocity is great enough.
final bool flingAnimation;
/// Enable panning with multiple fingers
final bool pinchMove;
/// Enable zooming with a multi-finger pinch gesture
final bool pinchZoom;
/// Enable zooming with a single-finger double tap gesture
final bool doubleTapZoom;
/// Enable zooming with a single-finger double-tap-drag gesture
///
/// The associated [MapEventSource] is [MapEventSource.doubleTapHold].
final bool doubleTapDragZoom;
/// Enable zooming with a mouse scroll wheel
final bool scrollWheelZoom;
/// Enable rotation with two-finger twist gesture
///
/// For controlling cursor/keyboard rotation, see
/// [InteractionOptions.cursorKeyboardRotationOptions].
final bool rotate;
bool hasMultiFinger() => pinchMove || pinchZoom || rotate;
/// This constructor gives wither functionality to the model
InteractiveFlags withFlag({
bool? pinchZoom,
bool? drag,
bool? flingAnimation,
bool? pinchMove,
bool? doubleTapZoom,
bool? doubleTapDragZoom,
bool? scrollWheelZoom,
bool? rotate,
}) =>
InteractiveFlags._(
pinchZoom: pinchZoom ?? this.pinchZoom,
drag: drag ?? this.drag,
flingAnimation: flingAnimation ?? this.flingAnimation,
pinchMove: pinchMove ?? this.pinchMove,
doubleTapZoom: doubleTapZoom ?? this.doubleTapZoom,
doubleTapDragZoom: doubleTapDragZoom ?? this.doubleTapDragZoom,
scrollWheelZoom: scrollWheelZoom ?? this.scrollWheelZoom,
rotate: rotate ?? this.rotate,
);
} This would make the following changes: final int flags;
// turns into
final InteractiveFlags flags;
flags: InteractiveFlags.all - InteractiveFlags.rotate,
// turns into
flags: InteractiveFlags.all(rotate: false),
if (InteractiveFlag.hasDoubleTapZoom(newOptions.flags)) {
// turns into
if (newOptions.flags.doubleTapZoom) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
I think the rough rule on scope of animations is I think the rough rule is we provide basic animations in response to gestures only. It's for plugins to provide animations for programmatic controls. |
This was referenced Dec 2, 2023
Closed
josxha
added
the
general
This issue is not a bug nor feature request, and is better suited for Discussions or Discord
label
Dec 10, 2023
josxha
changed the title
[REWRITE] Rewrite the gesture system
[SPEC] Rewrite the gesture system
Dec 19, 2023
JaffaKetchup
added
feature
This issue requests a new feature
P: 2 (soon™?)
and removed
general
This issue is not a bug nor feature request, and is better suited for Discussions or Discord
labels
Jan 15, 2024
JaffaKetchup
changed the title
[SPEC] Rewrite the gesture system
[SPEC] Overhaul gesture system
Jan 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature
This issue requests a new feature
P: 2 (soon™?)
S: core
Scoped to the core flutter_map functionality
Motivation
As mentioned by @JaffaKetchup in #1529 (comment), "much of the [gesture handling] code that does this was written in the first few releases, and has not been significantly changed since. [...] Gesture handling at this low-level often differs slightly between platforms, which means that manual testing succeeds on one platform, but a bug occurs on another."
Rewrite Proposals
Use boolean fields in InteractiveFlag and MultiFingerGesture. This simplifies internal usage, is more beginner friendly in our public API and has no performance penalty. I'll write some code examples in the next comment.[FEATURE] Add catch-allMapEventZoom
#1732If feasible do the following changes:
onPanUpdate
to detect pan events #1729More resources
The text was updated successfully, but these errors were encountered: