diff --git a/lib/widgets/editor/editor.dart b/lib/widgets/editor/editor.dart index 8ae4dd0..4693a47 100644 --- a/lib/widgets/editor/editor.dart +++ b/lib/widgets/editor/editor.dart @@ -158,8 +158,7 @@ class _EditorState extends State { toggleGrid: gridToggleState, editingTool: activeEditingTool, ), - size: Size(constraints.maxWidth, - constraints.maxHeight), + size: Size(constraints.maxWidth, constraints.maxHeight), ); }); }))); diff --git a/lib/widgets/editor/editor_config.dart b/lib/widgets/editor/editor_config.dart index 649f008..6245057 100644 --- a/lib/widgets/editor/editor_config.dart +++ b/lib/widgets/editor/editor_config.dart @@ -3,8 +3,9 @@ import 'dart:ui'; import '../../models/editing_tool.dart'; class EditorConfig { - static const minScale = 1e-6; - static const maxScale = 1e6; + static const scaleFactor = 2000.0; + static const minScale = 1 / scaleFactor; + static const maxScale = scaleFactor; static const frictionCoefficient = 0.0; // TODO 0.0 set for stability, any other positive value leads to funky issue with sliding/no feasible callback updating pointer (experiences on trackpad) diff --git a/lib/widgets/editor/editor_painter.dart b/lib/widgets/editor/editor_painter.dart index 4d6f5ec..9f1c713 100644 --- a/lib/widgets/editor/editor_painter.dart +++ b/lib/widgets/editor/editor_painter.dart @@ -1,4 +1,5 @@ import 'dart:collection'; +import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:toolfoam/extensions/list_extensions.dart'; @@ -246,6 +247,10 @@ class EditorPainter extends CustomPainter { Offset start = offset + perpendicular * startLength; Offset end = offset + perpendicular * endLength; + if (!visibleRect.contains(start) && !visibleRect.contains(end)) { + return; + } + canvas.drawLine(start, end, distancePaint); } @@ -254,6 +259,10 @@ class EditorPainter extends CustomPainter { ..color = Colors.grey.shade500 ..strokeWidth = 0.5 * scaleInverse; + if (!visibleRect.contains(head) && !visibleRect.contains(end)) { + return; + } + canvas.drawLine(head, end, linePaint); final Paint arrowPaint = Paint() @@ -292,15 +301,20 @@ class EditorPainter extends CustomPainter { drawArrow(canvas, arrowStart, arrowMidpoint); drawArrow(canvas, arrowEnd, arrowMidpoint); - final TextPainter textPainter = TextPainter( + if (!visibleRect.contains(arrowMidpoint)) { + return; + } + + TextPainter textPainter = TextPainter( text: TextSpan( text: text, style: TextStyle( color: Colors.grey.shade500, - fontSize: 12 * scaleInverse, + fontSize: 12 , ), ), textDirection: TextDirection.ltr, + textScaler: TextScaler.linear(scaleInverse), ); textPainter.layout(); diff --git a/lib/widgets/editor/editor_painter_data.dart b/lib/widgets/editor/editor_painter_data.dart index 1d525c0..481222d 100644 --- a/lib/widgets/editor/editor_painter_data.dart +++ b/lib/widgets/editor/editor_painter_data.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:logging/logging.dart'; import 'package:toolfoam/models/tools/tf_path_data.dart'; import 'package:toolfoam/widgets/editor/editor_config.dart'; import 'package:toolfoam/widgets/editor/editor_logic.dart'; @@ -10,6 +11,8 @@ class EditorData extends ChangeNotifier { required this.toolData, }); + static final Logger logger = Logger('EditorData'); + void redraw() { notifyListeners(); } @@ -19,6 +22,7 @@ class EditorData extends ChangeNotifier { double get scale => _scale; set scale(double value) { if (value == _scale) return; + logger.finest('Scaling update: $value, inverse: ${1 / value}, old: $_scale, ratio: ${value / _scale}'); _scale = value; notifyListeners(); }