diff options
Diffstat (limited to 'script.it')
| -rwxr-xr-x | script.it/script.ml | 23 | ||||
| -rwxr-xr-x | script.it/state/state.ml | 18 | 
2 files changed, 12 insertions, 29 deletions
| diff --git a/script.it/script.ml b/script.it/script.ml index 29bf2c9..6c2b5d3 100755 --- a/script.it/script.ml +++ b/script.it/script.ml @@ -87,7 +87,7 @@ type 'a param_events =    ; angle : float S.t    ; export : unit E.t    ; delete : unit E.t -  ; rendering : State.events E.t +  ; rendering : State.event E.t    }  type slider = @@ -174,7 +174,7 @@ let set_sidebar              State.E                ( render_type -              ,  (module M: State.Handler with type t = Layer.Paths.printer )) +              ,  (module M: State.Event with type t = Layer.Paths.printer ))            )  rendering' in @@ -377,7 +377,7 @@ let page_main id =                 let module Delete = Script_event.Delete in                 State.E                   ( Delete.{ worker } -                 , (module Delete: State.Handler with type t = Delete.t ))) +                 , (module Delete: State.Event with type t = Delete.t )))              parameters.delete          and export_event = @@ -385,21 +385,21 @@ let page_main id =                let module Export = Script_event.Export in                State.E                  ( () -                , (module Export: State.Handler with type t = Export.t ))) +                , (module Export: State.Event with type t = Export.t )))              parameters.export          and angle_event = S.changes parameters.angle                            |> E.map (fun value ->                                let module Property = Script_event.Property in                                State.E                                  ( Property.{ value ; worker ; prop = `Angle } -                                , (module Property: State.Handler with type t = Property.t ))) +                                , (module Property: State.Event with type t = Property.t )))          and width_event = S.changes parameters.width                            |> E.map (fun value ->                                let module Property = Script_event.Property in                                State.E                                  ( Property.{ value ; worker ; prop = `Width } -                                , (module Property: State.Handler with type t = Property.t ))) +                                , (module Property: State.Event with type t = Property.t )))          and worker_event = Note.E.filter_map              (function                | `Other t -> @@ -410,7 +410,7 @@ let page_main id =                  Some (                    State.E                      ( outline -                    , (module Complete_path: State.Handler with type t = Complete_path.t )))) +                    , (module Complete_path: State.Event with type t = Complete_path.t ))))              worker_event          in @@ -439,13 +439,13 @@ let page_main id =                  let module MouseDown = Script_event.Mouse_down in                  State.E                    ( MouseDown.{ position = c ; timer } -                  , (module MouseDown: State.Handler with type t = MouseDown.t )) +                  , (module MouseDown: State.Event with type t = MouseDown.t ))                | `Out c ->                  let module Click = Script_event.Click in                  State.E                    ( Click.{ point = c ; worker; timer } -                  , (module Click: State.Handler with type t = Click.t )) +                  , (module Click: State.Event with type t = Click.t ))              ) canva_events in          let tick_event = @@ -456,14 +456,13 @@ let page_main id =                 Option.map (fun p ->                     State.E                       ( (f, p) -                     , (module Tick: State.Handler with type t = Tick.t ))) +                     , (module Tick: State.Event with type t = Tick.t )))                   pos ) in          (* The first evaluation is the state. Which is the result of all the             successives events to the initial state *)          let state = -          Application.run -            State.do_action +          State.run              State.init              (E.select                 [ worker_event diff --git a/script.it/state/state.ml b/script.it/state/state.ml index e8cd87e..f3be91d 100755 --- a/script.it/state/state.ml +++ b/script.it/state/state.ml @@ -19,17 +19,7 @@ type state =    ; mouse_down_position : Gg.v2    } -module type Handler = sig - -  type t - -  val update: t -> state -> state - -end - -type t = E : 'a * (module Handler with type t = 'a) -> t - -type events = t +include Application.Make(struct type t = state end)  let post    : Brr_webworkers.Worker.t -> Worker_messages.to_worker -> unit @@ -73,12 +63,6 @@ let select_segment _ (_, selected, p0, p1) state dist =    ; width } -let do_action -  : (events, state) Application.t -  = fun (E (t, (module Handler))) state -> -    Handler.update t state - -  let init =    { paths = []    ; current = Path.Path_Builder.empty | 
