Skip to content

Commit

Permalink
Fix ruler moving speed when zoomed, closes #480
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Aug 2, 2023
1 parent e0348c6 commit 64dfd00
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
9 changes: 6 additions & 3 deletions app/lib/handlers/hand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,14 @@ class HandHandler extends Handler<HandPainter> {
}

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();
Expand Down Expand Up @@ -483,12 +485,13 @@ class HandHandler extends Handler<HandPainter> {
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);
Expand All @@ -500,7 +503,7 @@ class HandHandler extends Handler<HandPainter> {
final currentIndex = context.getCurrentIndex();
final globalPos =
context.getCameraTransform().localToGlobal(details.localFocalPoint);
if (_rulerRotation != null) {
if (_rulerRotation != null && _rulerPosition != null) {
_handleRuler(details, context);
return;
}
Expand Down
16 changes: 8 additions & 8 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion fastlane/metadata/android/en-US/changelogs/70.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
* 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))

0 comments on commit 64dfd00

Please sign in to comment.