blob: 3566b8f52c084dc784cf8b90ce27365bcf272359 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 process { 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
|