Closed huytd closed 1 year ago
However, the Eraser tool does not seem to work well. Maybe we should work into it further.
The problem may result from the cursor event: the function draw
is triggered on mouse (pressed) move, so a large amount of states are pushed into one version. A strategy should be implemented so that draw
or version push
are called only the cursor_position
changes.
Ah. good point. Yeah I totally forgot about the fact that draw can be called multiple times on the same cell. Yeah I think your suggestion is the way to go about this. Let me push a fix
Thanks. I am trying to fix this problem with these changes below
But I've found another problem. If you follow these steps:
Then you will get this
It seems that there may be some problem with the version stack. Please check it out also, thanks.
Implemented the Undo and Redo feature.
Usage:
https://user-images.githubusercontent.com/613943/226196309-96682237-be3b-4ea0-afc5-3e13e1d79930.mov
Due to the way we handled Text editing tool, every keystroke will be recorded as an Undo step, so, if you type "Hello", there will be 5 undo steps.
For other tools (Rect, Line, Erase, Copy/Paste,...), undo step will be recorded as a whole edit.
Currently, there's no limitation on how much undo steps to be recorded (unlimited history!), it gonna crash when the computer run out of memory, but let's wait and see.