Skip to content
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

Open
josxha opened this issue Nov 3, 2023 · 7 comments · May be fixed by #1809
Open

[SPEC] Overhaul gesture system #1715

josxha opened this issue Nov 3, 2023 · 7 comments · May be fixed by #1809
Assignees
Labels
feature This issue requests a new feature P: 2 (soon™?) S: core Scoped to the core flutter_map functionality
Milestone

Comments

@josxha
Copy link
Contributor

josxha commented Nov 3, 2023

Request for comments

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

If feasible do the following changes:

More resources

@josxha josxha self-assigned this Nov 3, 2023
@josxha josxha changed the title Rewrite gesture system and fix bugs from #1529 Rewrite gesture system Nov 3, 2023
@josxha
Copy link
Contributor Author

josxha commented 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) {

@hobleyd

This comment was marked as off-topic.

@JaffaKetchup

This comment was marked as off-topic.

@hobleyd

This comment was marked as off-topic.

@JaffaKetchup

This comment was marked as off-topic.

@josxha

This comment was marked as outdated.

@JaffaKetchup
Copy link
Member

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.

@josxha josxha added this to the v7.0 milestone Dec 2, 2023
@josxha josxha changed the title Rewrite gesture system [REWRITE] Rewrite the gesture system Dec 10, 2023
@josxha 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
@JaffaKetchup JaffaKetchup added the S: core Scoped to the core flutter_map functionality label Dec 10, 2023
@josxha josxha changed the title [REWRITE] Rewrite the gesture system [SPEC] Rewrite the gesture system Dec 19, 2023
@JaffaKetchup 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 JaffaKetchup changed the title [SPEC] Rewrite the gesture system [SPEC] Overhaul gesture system Jan 15, 2024
@josxha josxha linked a pull request Jan 23, 2024 that will close this issue
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
Projects
Status: In progress
Status: In Progress
3 participants