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/out.ml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'script.it/script_event/out.ml') 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 -- cgit v1.2.3