diff --git a/lib/components/canvas/canvas.dart b/lib/components/canvas/canvas.dart index ffcbabe00..4db2fb55f 100644 --- a/lib/components/canvas/canvas.dart +++ b/lib/components/canvas/canvas.dart @@ -18,6 +18,7 @@ class Canvas extends StatelessWidget { required this.currentStroke, required this.currentSelection, required this.setAsBackground, + required this.currentToolIsSelect, this.placeholder = false, }); @@ -32,6 +33,8 @@ class Canvas extends StatelessWidget { final void Function(EditorImage image)? setAsBackground; + final bool currentToolIsSelect; + final bool placeholder; @override @@ -62,6 +65,7 @@ class Canvas extends StatelessWidget { currentStroke: currentStroke, currentSelection: currentSelection, setAsBackground: setAsBackground, + currentToolIsSelect: currentToolIsSelect, ), ), ), diff --git a/lib/components/canvas/canvas_image.dart b/lib/components/canvas/canvas_image.dart index 27d20fb2c..39cebb7e4 100644 --- a/lib/components/canvas/canvas_image.dart +++ b/lib/components/canvas/canvas_image.dart @@ -123,6 +123,14 @@ class _CanvasImageState extends State { }); } + @override + void didUpdateWidget(covariant CanvasImage oldWidget) { + if (widget.readOnly && active) { + active = false; + } + super.didUpdateWidget(oldWidget); + } + @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; diff --git a/lib/components/canvas/canvas_preview.dart b/lib/components/canvas/canvas_preview.dart index 82cd0b453..d7d680088 100644 --- a/lib/components/canvas/canvas_preview.dart +++ b/lib/components/canvas/canvas_preview.dart @@ -41,6 +41,7 @@ class CanvasPreview extends StatelessWidget { currentStroke: null, currentSelection: null, hideBackground: Prefs.hideHomeBackgrounds.value, + currentToolIsSelect: false, ), ), ), diff --git a/lib/components/canvas/inner_canvas.dart b/lib/components/canvas/inner_canvas.dart index 970e8eead..a65e2d536 100644 --- a/lib/components/canvas/inner_canvas.dart +++ b/lib/components/canvas/inner_canvas.dart @@ -28,6 +28,7 @@ class InnerCanvas extends StatefulWidget { this.setAsBackground, this.onRenderObjectChange, this.hideBackground = false, + required this.currentToolIsSelect, }); final int pageIndex; @@ -44,6 +45,7 @@ class InnerCanvas extends StatefulWidget { final ValueChanged? onRenderObjectChange; final bool hideBackground; + final bool currentToolIsSelect; static const Color defaultBackgroundColor = Color(0xFFFCFCFC); @@ -165,8 +167,9 @@ class _InnerCanvasState extends State { filePath: widget.coreInfo.filePath, image: editorImage, pageSize: Size(widget.width, widget.height), - readOnly: widget.coreInfo.readOnly, setAsBackground: widget.setAsBackground, + readOnly: widget.coreInfo.readOnly + || !widget.currentToolIsSelect, ), ], ), diff --git a/lib/data/editor/editor_exporter.dart b/lib/data/editor/editor_exporter.dart index d204c997c..68a13e42c 100644 --- a/lib/data/editor/editor_exporter.dart +++ b/lib/data/editor/editor_exporter.dart @@ -77,6 +77,7 @@ abstract class EditorExporter { coreInfo: coreInfo, currentStroke: null, currentSelection: null, + currentToolIsSelect: false, ), ), ), diff --git a/lib/pages/editor/editor.dart b/lib/pages/editor/editor.dart index 7d3cd1f84..caff52ac5 100644 --- a/lib/pages/editor/editor.dart +++ b/lib/pages/editor/editor.dart @@ -842,6 +842,7 @@ class EditorState extends State { autosaveAfterDelay(); setState(() {}); }, + currentToolIsSelect: currentTool is Select, ); }, placeholderPageBuilder: (BuildContext context, int pageIndex) { @@ -855,6 +856,7 @@ class EditorState extends State { currentSelection: null, placeholder: true, setAsBackground: null, + currentToolIsSelect: currentTool is Select, ); }, );