Skip to content

Commit

Permalink
images: only move with select tool
Browse files Browse the repository at this point in the history
Fixes #183
  • Loading branch information
adil192 committed Feb 22, 2023
1 parent 6be4552 commit 1fa573e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/components/canvas/canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Canvas extends StatelessWidget {
required this.currentStroke,
required this.currentSelection,
required this.setAsBackground,
required this.currentToolIsSelect,
this.placeholder = false,
});

Expand All @@ -32,6 +33,8 @@ class Canvas extends StatelessWidget {

final void Function(EditorImage image)? setAsBackground;

final bool currentToolIsSelect;

final bool placeholder;

@override
Expand Down Expand Up @@ -62,6 +65,7 @@ class Canvas extends StatelessWidget {
currentStroke: currentStroke,
currentSelection: currentSelection,
setAsBackground: setAsBackground,
currentToolIsSelect: currentToolIsSelect,
),
),
),
Expand Down
8 changes: 8 additions & 0 deletions lib/components/canvas/canvas_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class _CanvasImageState extends State<CanvasImage> {
});
}

@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;
Expand Down
1 change: 1 addition & 0 deletions lib/components/canvas/canvas_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CanvasPreview extends StatelessWidget {
currentStroke: null,
currentSelection: null,
hideBackground: Prefs.hideHomeBackgrounds.value,
currentToolIsSelect: false,
),
),
),
Expand Down
5 changes: 4 additions & 1 deletion lib/components/canvas/inner_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class InnerCanvas extends StatefulWidget {
this.setAsBackground,
this.onRenderObjectChange,
this.hideBackground = false,
required this.currentToolIsSelect,
});

final int pageIndex;
Expand All @@ -44,6 +45,7 @@ class InnerCanvas extends StatefulWidget {
final ValueChanged<RenderObject>? onRenderObjectChange;

final bool hideBackground;
final bool currentToolIsSelect;

static const Color defaultBackgroundColor = Color(0xFFFCFCFC);

Expand Down Expand Up @@ -165,8 +167,9 @@ class _InnerCanvasState extends State<InnerCanvas> {
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,
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/data/editor/editor_exporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ abstract class EditorExporter {
coreInfo: coreInfo,
currentStroke: null,
currentSelection: null,
currentToolIsSelect: false,
),
),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ class EditorState extends State<Editor> {
autosaveAfterDelay();
setState(() {});
},
currentToolIsSelect: currentTool is Select,
);
},
placeholderPageBuilder: (BuildContext context, int pageIndex) {
Expand All @@ -855,6 +856,7 @@ class EditorState extends State<Editor> {
currentSelection: null,
placeholder: true,
setAsBackground: null,
currentToolIsSelect: currentTool is Select,
);
},
);
Expand Down

0 comments on commit 1fa573e

Please sign in to comment.