From 90f1f73f08b2d9231b2ee029b9e39dd570e36f36 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 24 May 2021 22:56:16 +0200 Subject: Update --- script.it/script_event/delete.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 script.it/script_event/delete.ml (limited to 'script.it/script_event/delete.ml') diff --git a/script.it/script_event/delete.ml b/script.it/script_event/delete.ml new file mode 100755 index 0000000..edd5d23 --- /dev/null +++ b/script.it/script_event/delete.ml @@ -0,0 +1,31 @@ +(** Delete the selected element *) + +open StdLabels +module State = Script_state.State +module Selection = Script_state.Selection + +type t = { worker : Brr_webworkers.Worker.t } + +(* Click anywhere while in Out mode, we switch in edition *) +let apply { worker } state = + match state.State.mode with + | Selection (Path id) -> + let paths = List.filter + state.State.paths + ~f:(fun p -> + p.Outline.id != id + ) in + { state with paths ; mode = Out} + + | Selection (Point (id, point)) -> + List.iter + state.State.paths + ~f:(fun p -> + let id' = p.Outline.id in + match id' = id with + | false -> () + | true -> State.post worker (`DeletePoint (point, p)) + ); + { state with mode = Selection (Path id) } + + | _ -> state -- cgit v1.2.3