From d32fcffdc8fd26f7122e264334b0b40a0d480c1b Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:44:03 +0100 Subject: [PATCH] remove `MultiFingerGesture` non breaking commit --- lib/flutter_map.dart | 1 - lib/src/gestures/interactive_flag.dart | 10 +++++- lib/src/gestures/multi_finger_gesture.dart | 38 ---------------------- lib/src/map/options/interaction.dart | 7 ++-- lib/src/map/options/options.dart | 6 ++-- 5 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 lib/src/gestures/multi_finger_gesture.dart diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index c4576358b..e7b652fee 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -21,7 +21,6 @@ export 'package:flutter_map/src/geo/latlng_bounds.dart'; export 'package:flutter_map/src/gestures/interactive_flag.dart'; export 'package:flutter_map/src/gestures/latlng_tween.dart'; export 'package:flutter_map/src/gestures/map_events.dart'; -export 'package:flutter_map/src/gestures/multi_finger_gesture.dart'; export 'package:flutter_map/src/gestures/tap_position.dart'; export 'package:flutter_map/src/layer/attribution_layer/rich/animation.dart'; export 'package:flutter_map/src/layer/attribution_layer/rich/source.dart'; diff --git a/lib/src/gestures/interactive_flag.dart b/lib/src/gestures/interactive_flag.dart index 1caabc385..627511251 100644 --- a/lib/src/gestures/interactive_flag.dart +++ b/lib/src/gestures/interactive_flag.dart @@ -21,7 +21,8 @@ abstract class InteractiveFlag { doubleTapZoom | doubleTapDragZoom | scrollWheelZoom | - rotate; + rotate | + ctrlDragRotate; static const int none = 0; @@ -54,6 +55,10 @@ abstract class InteractiveFlag { /// [InteractionOptions.cursorKeyboardRotationOptions]. static const int rotate = 1 << 7; + /// Enable rotation by pressing the CTRL Key and drag the map with the cursor. + /// To change the key see [InteractionOptions.cursorKeyboardRotationOptions]. + static const int ctrlDragRotate = 1 << 8; + /// Flags pertaining to gestures which require multiple fingers. static const _multiFingerFlags = pinchMove | pinchZoom | rotate; @@ -93,4 +98,7 @@ abstract class InteractiveFlag { /// True if the [scrollWheelZoom] interactive flag is enabled. static bool hasScrollWheelZoom(int flags) => hasFlag(flags, scrollWheelZoom); + + /// True if the [ctrlDragRotate] interactive flag is enabled. + static bool hasCtrlDragRotate(int flags) => hasFlag(flags, ctrlDragRotate); } diff --git a/lib/src/gestures/multi_finger_gesture.dart b/lib/src/gestures/multi_finger_gesture.dart deleted file mode 100644 index 8ae1bcd29..000000000 --- a/lib/src/gestures/multi_finger_gesture.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:meta/meta.dart'; - -/// Use [MultiFingerGesture] to disable / enable certain gestures Use -/// [MultiFingerGesture.all] to enable all gestures, use -/// [MultiFingerGesture.none] to disable all gestures -/// -/// If you want mix gestures for example rotate and pinchZoom gestures then you -/// have two options A.) add you own flags: [MultiFingerGesture.rotate] | -/// [MultiFingerGesture.pinchZoom] B.) remove unnecessary flags from all: -/// [MultiFingerGesture.all] & ~[MultiFingerGesture.pinchMove] -@immutable -class MultiFingerGesture { - static const int all = pinchMove | pinchZoom | rotate; - static const int none = 0; - - /// enable move with two or more fingers - static const int pinchMove = 1 << 0; - - /// enable pinch zoom - static const int pinchZoom = 1 << 1; - - /// enable map rotate - static const int rotate = 1 << 2; - - /// Returns `true` if [leftFlags] has at least one member in [rightFlags] - /// (intersection) for example [leftFlags]= [MultiFingerGesture.pinchMove] | - /// [MultiFingerGesture.rotate] and [rightFlags]= [MultiFingerGesture.rotate] - /// returns true because both have [MultiFingerGesture.rotate] flag - static bool hasFlag(int leftFlags, int rightFlags) { - return leftFlags & rightFlags != 0; - } - - static bool hasPinchMove(int gestures) => hasFlag(gestures, pinchMove); - - static bool hasPinchZoom(int gestures) => hasFlag(gestures, pinchZoom); - - static bool hasRotate(int gestures) => hasFlag(gestures, rotate); -} diff --git a/lib/src/map/options/interaction.dart b/lib/src/map/options/interaction.dart index 7c055550c..b9a8e7130 100644 --- a/lib/src/map/options/interaction.dart +++ b/lib/src/map/options/interaction.dart @@ -1,5 +1,4 @@ import 'package:flutter_map/src/gestures/interactive_flag.dart'; -import 'package:flutter_map/src/gestures/multi_finger_gesture.dart'; import 'package:flutter_map/src/map/options/cursor_keyboard_rotation.dart'; import 'package:meta/meta.dart'; @@ -87,13 +86,13 @@ final class InteractionOptions { this.debugMultiFingerGestureWinner = false, this.enableMultiFingerGestureRace = false, this.rotationThreshold = 20.0, - this.rotationWinGestures = MultiFingerGesture.rotate, + this.rotationWinGestures = InteractiveFlag.rotate, this.pinchZoomThreshold = 0.5, this.pinchZoomWinGestures = - MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, + InteractiveFlag.pinchZoom | InteractiveFlag.pinchMove, this.pinchMoveThreshold = 40.0, this.pinchMoveWinGestures = - MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, + InteractiveFlag.pinchZoom | InteractiveFlag.pinchMove, this.enableScrollWheel = false, this.scrollWheelVelocity = 0.005, this.cursorKeyboardRotationOptions = const CursorKeyboardRotationOptions(), diff --git a/lib/src/map/options/options.dart b/lib/src/map/options/options.dart index b390d9335..152633bdd 100644 --- a/lib/src/map/options/options.dart +++ b/lib/src/map/options/options.dart @@ -280,13 +280,13 @@ class MapOptions { debugMultiFingerGestureWinner: _debugMultiFingerGestureWinner ?? false, enableMultiFingerGestureRace: _enableMultiFingerGestureRace ?? false, rotationThreshold: _rotationThreshold ?? 20.0, - rotationWinGestures: _rotationWinGestures ?? MultiFingerGesture.rotate, + rotationWinGestures: _rotationWinGestures ?? InteractiveFlag.rotate, pinchZoomThreshold: _pinchZoomThreshold ?? 0.5, pinchZoomWinGestures: _pinchZoomWinGestures ?? - MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, + InteractiveFlag.pinchZoom | InteractiveFlag.pinchMove, pinchMoveThreshold: _pinchMoveThreshold ?? 40.0, pinchMoveWinGestures: _pinchMoveWinGestures ?? - MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, + InteractiveFlag.pinchZoom | InteractiveFlag.pinchMove, enableScrollWheel: _enableScrollWheel ?? true, scrollWheelVelocity: _scrollWheelVelocity ?? 0.005, );