Skip to content

Commit

Permalink
pageIndexStart of selection is set to current page immediatley after …
Browse files Browse the repository at this point in the history
…selection movement is stored to history.

This fixes problem when selection is moved across pages, and then moved on page (in this case pageIndexStart was set according to the first movement of selection)
  • Loading branch information
Jakub Zlámal committed Apr 1, 2024
1 parent 0589dee commit 3350fc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/data/tools/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SelectResult {
Path path;

/// The page index when the items were selected.
final int pageIndexStart;
int pageIndexStart;

SelectResult({
required this.pageIndex,
Expand Down
9 changes: 9 additions & 0 deletions lib/pages/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ class EditorState extends State<Editor> {
}

void onDrawUpdate(ScaleUpdateDetails details) {
if (dragPageIndex==null){
// cursor is somewhere between pages, do not respond until its page will be recognized
return;
}
final page = coreInfo.pages[dragPageIndex!];
Offset position = page.renderBox!.globalToLocal(details.focalPoint);
Offset offset = position - previousPosition;
Expand Down Expand Up @@ -765,6 +769,10 @@ class EditorState extends State<Editor> {
}

void onDrawEnd(ScaleEndDetails details) {
if (dragPageIndex==null){
// page cannot be determined from cursor position
return;
}
final page = coreInfo.pages[dragPageIndex!];
bool shouldSave = true;
setState(() {
Expand Down Expand Up @@ -820,6 +828,7 @@ class EditorState extends State<Editor> {
moveOffset.dy,
),
));
select.selectResult.pageIndexStart=select.selectResult.pageIndex; // set starting page index to current page
} else {
shouldSave = false;
select.onDragEnd(page.strokes, page.images);
Expand Down

0 comments on commit 3350fc4

Please sign in to comment.