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:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user