Skip to content

Commit

Permalink
Improve multi toggle tool editing
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 30, 2024
1 parent 8aa4ba8 commit 7546bd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions app/lib/handlers/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,8 @@ mixin PointerManipulationHandler<T> on Handler<T> {
static Offset calculatePointerPosition(
CurrentIndex index, Offset position, Size viewportSize) {
return index.toggleableHandlers.values
.whereType<PointerManipulationHandler>()
.map((e) => e.getPointerPosition(position, viewportSize))
.where((e) => e != position)
.firstOrNull ??
position;
.whereType<PointerManipulationHandler>()
.fold(position,
(pos, handler) => handler.getPointerPosition(pos, viewportSize));
}
}
9 changes: 5 additions & 4 deletions app/lib/handlers/ruler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Rect _getRulerRect(Size size, Offset position,
transform.position.dx + position.dx / transform.size,
transform.position.dy +
(size.height / 2 + -rulerSize / 2 + position.dy) / transform.size,
size.width / transform.size,
size.width * 2 / transform.size,
rulerSize / transform.size,
);
}

class RulerHandler extends Handler<RulerTool> with PointerManipulationHandler {
Offset _position = Offset.zero;
double _rotation = 20;
double _rotation = 0;

Offset get position => _position;
double get rotation => _rotation;
Expand Down Expand Up @@ -140,10 +140,11 @@ class RulerRenderer extends Renderer<RulerTool> {
// Paint ruler lines
int x = steps;
var even = (transform.position.dx ~/ (steps / transform.size)) % 2 == 0;
while (x <= size.width * transform.size) {
while (x <= size.width * transform.size * 2) {
final posX = x / transform.size -
(transform.position.dx % (steps / transform.size)) -
size.width / 2;
size.width / 2 -
rulerRect.width / 4;
canvas.drawLine(
Offset(posX, rulerRect.top),
Offset(
Expand Down
1 change: 0 additions & 1 deletion app/lib/handlers/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class SelectHandler extends Handler<SelectTool> {

@override
void onScaleUpdate(ScaleUpdateDetails details, EventContext context) {
print("onScaleUpdate");
final globalPos =
context.getCameraTransform().localToGlobal(details.localFocalPoint);
if (_handleRuler(details, context)) {
Expand Down

0 comments on commit 7546bd7

Please sign in to comment.