From 6e5c6bf7beadc72e64e5d929e301b473b01c9303 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 7 Jan 2021 18:41:30 +0100 Subject: Update --- script.it/state.ml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'script.it/state.ml') diff --git a/script.it/state.ml b/script.it/state.ml index 585ca32..185be4f 100755 --- a/script.it/state.ml +++ b/script.it/state.ml @@ -111,8 +111,8 @@ let select_segment _ (_, selected, p0, p1) state dist = let point' = Path.Point.mix dist (Path.Point.get_coord p0) p0 p1 in - let angle = Path.Point.get_angle point' - and width = Path.Point.get_width point' in + let angle = (Float.round @@ 10. *. Path.Point.get_angle point') /. 10. + and width = (Float.round @@ 10. *. Path.Point.get_width point') /. 10. in let id = Selection.select_path selected in { state with @@ -175,8 +175,9 @@ let angle angle state = {state with paths } (* Change angle localy *) | Selection (Point (s, point)) -> - update_point_selection state s point - (fun p -> Path.Point.set_angle p angle) + let state = update_point_selection state s point + (fun p -> Path.Point.set_angle p angle) in + { state with angle } | _ -> { state with angle} @@ -187,8 +188,9 @@ let width width state = let paths = update_path_selection s state.paths (fun p -> Path.Point.set_width p width) in {state with paths } | Selection (Point (s, point)) -> - update_point_selection state s point - (fun p -> Path.Point.set_width p width) + let state = update_point_selection state s point + (fun p -> Path.Point.set_width p width) in + { state with width } | _ -> { state with width } @@ -239,10 +241,17 @@ let do_action else (* On the same segment, check for a point *) let selection = Selection.select_point path (Gg.V2.of_tuple position) in - - (* In order to handle the point move, start the timer *) - Elements.Timer.start timer 0.3; - {state with mode= Selection selection} + match selection with + | Path _ -> + { state with mode = Selection selection } + | Point (_, pt) -> + (* In order to handle the point move, start the timer *) + Elements.Timer.start timer 0.3; + { state with + mode = Selection selection + ; angle = Path.Point.get_angle pt + ; width = Path.Point.get_width pt + } end | `Out point, Edit -> @@ -344,7 +353,7 @@ let do_action match id = id' with | false -> path | true -> - Path.Fixed.update path paths + (Path.Fixed.update path paths) ) in { state with paths } -- cgit v1.2.3