diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-05-24 22:56:16 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:22:43 +0100 |
commit | 90f1f73f08b2d9231b2ee029b9e39dd570e36f36 (patch) | |
tree | 49c7828d2a549a3278ba5c54ca9b1f500c860951 /script.it/script_event/out.ml | |
parent | 05008c81a9652472a454f47940a6d8aa9a228538 (diff) |
Update
Diffstat (limited to 'script.it/script_event/out.ml')
-rwxr-xr-x | script.it/script_event/out.ml | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/script.it/script_event/out.ml b/script.it/script_event/out.ml index 45f05d3..b8b8599 100755 --- a/script.it/script_event/out.ml +++ b/script.it/script_event/out.ml @@ -8,6 +8,25 @@ type t = { point : float * float ; worker : Brr_webworkers.Worker.t } +(** Long click, move the selected element if any *) +let longClick mouse_coord state worker = function + | State.Selection t -> + let mouse_v2 = Gg.V2.of_tuple mouse_coord in + begin match Selection.find_selection t state.State.paths with + | None -> state + | Some (Point (path, point)) -> + let point' = Path.Point.copy point mouse_v2 in + State.post worker (`TranslatePoint (point', path)); + (* Just replace the position of the selected point *) + { state with mode = Selection (Point (path.id, point')) } + | Some (Path path) -> + let delta = Gg.V2.(mouse_v2 - state.State.mouse_down_position) in + State.post worker (`TranslatePath (path, delta)); + state + end + (* TODO Long click in out mode should translate the slate *) + | _ -> state + let apply {point; timer ; worker} state = match state.State.mode with @@ -61,9 +80,9 @@ let apply {point; timer ; worker} state = end end - | mode when Elements.Timer.delay timer < 0.3 -> - State.click state mode + | _ when Elements.Timer.delay timer < 0.3 -> + state | _ -> - State.longClick point state worker state.mode + longClick point state worker state.mode |