Skip to content

Commit

Permalink
Fix moving issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 29, 2023
1 parent 0e62299 commit 12c52a7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/lib/handlers/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AreaHandler extends Handler<AreaTool> {
context.getCameraTransform().localToGlobal(details.localFocalPoint);

start = globalPosition;
return false;
return true;
}

@override
Expand Down
15 changes: 3 additions & 12 deletions app/lib/handlers/hand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ class GeneralHandHandler<T> extends Handler<T> {

GeneralHandHandler(super.data);

@override
void onScaleUpdate(ScaleUpdateDetails details, EventContext context) {
context
.getCurrentIndexCubit()
.move(details.focalPointDelta / context.getCameraTransform().size);
_moved = true;
}

@override
void onScaleEnd(ScaleEndDetails details, EventContext context) {
if (_moved) {
context.bake();
}
_moved = false;
context.refresh();
}

@override
bool onScaleStart(ScaleStartDetails details, EventContext context) {
_moved = false;
_moved = true;
context.refresh();
return false;
}

Expand Down
10 changes: 9 additions & 1 deletion app/lib/handlers/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ abstract class Handler<T> {

void onLongPressEnd(LongPressEndDetails details, EventContext context) {}

bool onScaleStart(ScaleStartDetails details, EventContext context) => false;
bool onScaleStart(ScaleStartDetails details, EventContext context) => true;

void onScaleStartAbort(ScaleStartDetails details, EventContext context) {}

Expand Down Expand Up @@ -477,6 +477,7 @@ abstract class PastingHandler<T> extends Handler<T> {
[bool first = false]) {
final transform = context.getCameraTransform();
if (first) _firstPos = transform.localToGlobal(event.localPosition);
if (!first && _firstPos == null) return;
_secondPos = transform.localToGlobal(event.localPosition);
_aspectRatio = context.isCtrlPressed;
_center = context.isShiftPressed;
Expand Down Expand Up @@ -507,6 +508,13 @@ abstract class PastingHandler<T> extends Handler<T> {
context.refresh();
}

@override
void onScaleStartAbort(ScaleStartDetails details, EventContext context) {
_firstPos = null;
_secondPos = null;
context.refresh();
}

double get constraintedAspectRatio => 0;
double get constraintedWidth => 0;
double get constraintedHeight => 0;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class SelectHandler extends Handler<SelectTool> {
return true;
}
context.refresh();
return false;
return true;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/spacer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SpacerHandler extends Handler<SpacerTool> {
final transform = context.getCameraTransform();
_startPosition = transform.localToGlobal(details.localFocalPoint);
_refreshRenderers(_startPosition!, context).whenComplete(context.refresh);
return false;
return true;
}

@override
Expand Down
8 changes: 4 additions & 4 deletions app/lib/views/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ class _MainViewViewportState extends State<MainViewViewport>
_isScalingDisabled = null;
},
onScaleStart: (details) {
_isScalingDisabled ??= !cubit.state.moveEnabled;
if (_isScalingDisabled != false) {
_isScalingDisabled = !cubit.state.moveEnabled ||
cubit
.getHandler()
.onScaleStart(details, getEventContext());
_isScalingDisabled = cubit
.getHandler()
.onScaleStart(details, getEventContext());
} else {
cubit
.getHandler()
Expand Down

0 comments on commit 12c52a7

Please sign in to comment.