From 64dfd00e403a7feca1ea146b4cdb7ae313f144db Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Wed, 2 Aug 2023 17:37:39 +0200 Subject: [PATCH] Fix ruler moving speed when zoomed, closes #480 --- app/lib/handlers/hand.dart | 9 ++++++--- app/pubspec.lock | 16 ++++++++-------- app/pubspec.yaml | 6 +++--- .../metadata/android/en-US/changelogs/70.txt | 3 ++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/lib/handlers/hand.dart b/app/lib/handlers/hand.dart index 71581467d54a..4683cee369e9 100644 --- a/app/lib/handlers/hand.dart +++ b/app/lib/handlers/hand.dart @@ -442,12 +442,14 @@ class HandHandler extends Handler { } double? _rulerRotation; + Offset? _rulerPosition; @override bool onScaleStart(ScaleStartDetails details, EventContext context) { final viewport = context.getCameraViewport(); if (viewport.tool.hitRuler(details.localFocalPoint, viewport.toSize())) { _rulerRotation = 0; + _rulerPosition = details.localFocalPoint; return true; } final cameraTransform = context.getCameraTransform(); @@ -483,12 +485,13 @@ class HandHandler extends Handler { toolState = toolState.copyWith( rulerPosition: toolState.rulerPosition + Point( - details.focalPointDelta.dx, - details.focalPointDelta.dy, + details.localFocalPoint.dx - _rulerPosition!.dx, + details.localFocalPoint.dy - _rulerPosition!.dy, ), rulerAngle: angle, ); _rulerRotation = currentRotation; + _rulerPosition = details.localFocalPoint; context .getCurrentIndexCubit() .updateTool(state.data, state.page, state.assetService, toolState); @@ -500,7 +503,7 @@ class HandHandler extends Handler { final currentIndex = context.getCurrentIndex(); final globalPos = context.getCameraTransform().localToGlobal(details.localFocalPoint); - if (_rulerRotation != null) { + if (_rulerRotation != null && _rulerPosition != null) { _handleRuler(details, context); return; } diff --git a/app/pubspec.lock b/app/pubspec.lock index 7031b0a3a8bf..0ede5feef437 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -252,10 +252,10 @@ packages: dependency: "direct main" description: name: connectivity_plus - sha256: "8599ae9edca5ff96163fca3e36f8e481ea917d1e71cdad912c084b5579913f34" + sha256: "77a180d6938f78ca7d2382d2240eb626c0f6a735d0bfdce227d8ffb80f95c48b" url: "https://pub.dev" source: hosted - version: "4.0.1" + version: "4.0.2" connectivity_plus_platform_interface: dependency: transitive description: @@ -765,10 +765,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: ceb027f6bc6a60674a233b4a90a7658af1aebdea833da0b5b53c1e9821a78c7b + sha256: "6ff267fcd9d48cb61c8df74a82680e8b82e940231bb5f68356672fde0397334a" url: "https://pub.dev" source: hosted - version: "4.0.2" + version: "4.1.0" package_info_plus_platform_interface: dependency: transitive description: @@ -1007,18 +1007,18 @@ packages: dependency: "direct main" description: name: share_plus - sha256: ed3fcea4f789ed95913328e629c0c53e69e80e08b6c24542f1b3576046c614e8 + sha256: "6cec740fa0943a826951223e76218df002804adb588235a8910dc3d6b0654e11" url: "https://pub.dev" source: hosted - version: "7.0.2" + version: "7.1.0" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface - sha256: "0c6e61471bd71b04a138b8b588fa388e66d8b005e6f2deda63371c5c505a0981" + sha256: "357412af4178d8e11d14f41723f80f12caea54cf0d5cd29af9dcdab85d58aea7" url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.3.0" shared_preferences: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 8e1b9cbd17c3..ef552d66f5a2 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -38,8 +38,8 @@ dependencies: url: https://github.com/CodeDoctorDE/phosphor-flutter ref: f370dd2c25d3ea51ffb8f1c7c183bc9f33889c82 replay_bloc: ^0.2.4 - share_plus: ^7.0.2 - package_info_plus: ^4.0.2 + share_plus: ^7.1.0 + package_info_plus: ^4.1.0 idb_shim: ^2.3.1 go_router: ^10.0.0 xml: ^6.3.0 @@ -61,7 +61,7 @@ dependencies: rxdart: ^0.27.7 archive: ^3.3.7 animations: ^2.0.7 - connectivity_plus: ^4.0.1 + connectivity_plus: ^4.0.2 cross_file: ^0.3.3+4 args: ^2.4.2 perfect_freehand: diff --git a/fastlane/metadata/android/en-US/changelogs/70.txt b/fastlane/metadata/android/en-US/changelogs/70.txt index 6f5be00871c5..624f78378195 100644 --- a/fastlane/metadata/android/en-US/changelogs/70.txt +++ b/fastlane/metadata/android/en-US/changelogs/70.txt @@ -14,4 +14,5 @@ * Fix internet problems on android ([#457](https://github.com/LinwoodDev/Butterfly/issues/457)) * Fix position when pasting elements ([#468](https://github.com/LinwoodDev/Butterfly/issues/468)) * Fix corner hit detection on hand tool when zoomed -* Fix rotation when selecting multiple elements ([#472](https://github.com/LinwoodDev/Butterfly/issues/472)) \ No newline at end of file +* Fix rotation when selecting multiple elements ([#472](https://github.com/LinwoodDev/Butterfly/issues/472)) +* Fix ruler moving speed when zoomed ([#480](https://github.com/LinwoodDev/Butterfly/issues/480)) \ No newline at end of file