Skip to content

Commit

Permalink
Fixed bug in undo when controller is in erase mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredM committed Nov 1, 2022
1 parent ac30e84 commit 05022fb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
* **BUGFIX** Using PencilController setDrawing could lead to an exception when called in write mode
* **BUGFIX** Fixed images for comparison of drawing routines
* **IMPROVEMENT** PencilDecorator can have custom callback to draw background
* **BREAKING** PencilDecorator now accepts either number of lines or a fixed spacing to draw ruled,
chequered or dotted pattern
* **BREAKING** PencilDecorator now accepts either number of lines or a fixed spacing to draw ruled, chequered or dotted pattern
* **DOCUMENTATION** Improved example

## 0.2.1

* **BUGFIX** Changed signature of custom painter function in PencilDecoration
* **BUGFIX** Changed signature of custom painter function in PencilDecoration

## 0.2.2

* **BUGFIX** Fixed bug in undo method when controller is in erase mode
9 changes: 3 additions & 6 deletions example/lib/pencil_field_with_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,12 @@ class _PencilFieldWithToolsState extends State<PencilFieldWithTools> {
});
}

/*void _onModeSelected(PencilMode newMode) {
void _onPrintJSON() {
setState(() {
widget.controller.setMode(PencilMode.erase);
pencilPaint = eraserPaint;
widget.controller.undo();
});
}*/

void _onPrintJSON() {
log(widget.controller.drawing.toJson().toString());
//log(widget.controller.drawing.toJson().toString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.0"
version: "0.2.1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
4 changes: 4 additions & 0 deletions lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,13 @@ class PencilFieldController {
void undo() {
if (_undoPaths.strokeCount == 0) return;

// Move the last deleted stroke back to the list of strokes
_strokePaths = _strokePaths.add(_undoPaths.lastStroke);
_totalSize = null;
_undoPaths.removeLast();

// Add an additional entry to the list of markers.
_writePathsMarkedForErase.add(false);
}

void clear() {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pencil_field
description: Pencil / stylus interaction (writing & erasing) on different devices and platforms.
Comes with versioned persistence of input.
version: 0.2.1
version: 0.2.2
homepage: https://github.com/ManfredM/pencil_field

environment:
Expand Down

0 comments on commit 05022fb

Please sign in to comment.