aboutsummaryrefslogtreecommitdiff
path: root/script.it/script_event/out.ml
diff options
context:
space:
mode:
Diffstat (limited to 'script.it/script_event/out.ml')
-rwxr-xr-xscript.it/script_event/out.ml25
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