100/home/humza/Downloads/sml/dotscape/README.md done with undo/redo functionality (tested and both of them work as expected)

This commit is contained in:
2024-08-08 23:52:49 +01:00
parent 541fdd877f
commit d9c7b753f8
5 changed files with 21 additions and 3 deletions

View File

@@ -45,7 +45,7 @@ This isn't an exhaustive list, but these are some features I would like to add t
- [x] Display clicked positions
- [x] Redraw components when resized
- [ ] Support undo (with `<Ctrl-z>`) and redo (with `<Ctrl-y>` or `<Ctrl-Shift-z>`)
- [x] Support undo (with `<Ctrl-z>`) and redo (with `<Ctrl-y>` or `<Ctrl-Shift-z>`)
- [ ] Export to code
- Possibly different options like creating a flat array/vector or an index buffer
- [ ] Linear interpolation

BIN
dotscape

Binary file not shown.

View File

@@ -5,6 +5,7 @@ int PRESS = GLFW_PRESS;
int RELEASE = GLFW_RELEASE;
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
int KEY_Z = GLFW_KEY_Z;
int KEY_Y = GLFW_KEY_Y;
// Calls function exported from SML
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {

View File

@@ -33,4 +33,6 @@ struct
val (KEY_Z, _) =
_symbol "KEY_Z" public : ( unit -> int ) * ( int -> unit );
val (KEY_Y, _) =
_symbol "KEY_Y" public : ( unit -> int ) * ( int -> unit );
end

View File

@@ -21,9 +21,24 @@ struct
fun keyActionCallback mailbox (key, scancode, action, mods) =
if
key = Input.KEY_Z () andalso action <> Input.RELEASE ()
then
if mods = 0x0002 then
(* ctrl-z *)
Mailbox.send (mailbox, UNDO_ACTION)
else if mods = 0x0003 then
(* ctrl-shift-z *)
Mailbox.send (mailbox, REDO_ACTION)
else
(* no action recognised *)
()
else if
key = Input.KEY_Y () andalso action <> Input.RELEASE ()
andalso mods = 0x0002
then Mailbox.send (mailbox, UNDO_ACTION)
else ()
then
(* ctrl-y *)
Mailbox.send (mailbox, REDO_ACTION)
else
()
fun registerCallbacks (window, inputMailbox) =
let