Skip to content

Commit

Permalink
Move normalization html logic where it belongs
Browse files Browse the repository at this point in the history
  • Loading branch information
panglesd committed Jan 13, 2025
1 parent badaee2 commit c61a697
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
26 changes: 12 additions & 14 deletions src/compiler/src/lib/slipshow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ let embed_in_page content ~has_math ~math_link ~slip_css_link ~theorem_css_link
%s
</head>
<body>
<div id="open-window">
<div class="format-container">
<div class="rotate-container">
<div class="scale-container">
<div class="universe movable" id="universe">
<div width="10000" height="10000" class="fog"></div>
<svg id="slipshow-drawing" style="overflow:visible; position: absolute; z-index:1000"></svg>
<div class="slip-rescaler">
<div class="slip">
<div class="slip-body">
%s
</div>
<div id="slipshow-content">
<div class="rotate-container">
<div class="scale-container">
<div class="universe movable" id="universe">
<div width="10000" height="10000" class="fog"></div>
<svg id="slipshow-drawing" style="overflow:visible; position: absolute; z-index:1000"></svg>
<div class="slip-rescaler">
<div class="slip">
<div class="slip-body">
%s
</div>
</div>
</div>
Expand All @@ -83,10 +81,10 @@ let embed_in_page content ~has_math ~math_link ~slip_css_link ~theorem_css_link



<!-- Include the library -->
<!-- Include the library -->
%s
<!-- Start the presentation () -->
<script>hljs.highlightAll();</script>
<script>hljs.highlightAll();</script>
<script>
startSlipshow(|}
mathjax_element slip_css_element theorem_css_element highlight_css_element
Expand Down
5 changes: 4 additions & 1 deletion src/engine/main.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
let start id step =
let open Fut.Syntax in
let* () = Normalization.setup () in
let el =
Brr.El.find_first_by_selector (Jstr.v "#slipshow-content") |> Option.get
in
let* () = Normalization.setup el in
let* window = Window.setup () in
(* TODO: move out of here *)
let () = Rescaler.setup_rescalers () in
Expand Down
23 changes: 12 additions & 11 deletions src/engine/normalization.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,20 @@ let replace_open_window window =
state := { !state with scale = window_w /. Constants.width };
Css.set_pure [ Scale (window_w /. Constants.width) ] window.format_container

let create () =
let find s =
match El.find_first_by_selector (Jstr.v s) with
| Some s -> s
| None -> failwith ("No element with '" ^ s ^ "' id. Cannot continue.")
let create el =
let format_container =
Brr.El.div ~at:[ Brr.At.class' (Jstr.v "format-container") ] []
in
let open_window = find "#open-window"
and format_container = find ".format-container" in
let open_window =
Brr.El.div ~at:[ Brr.At.id (Jstr.v "open-window") ] [ format_container ]
in
Brr.El.insert_siblings `Replace el [ open_window ];
Brr.El.append_children format_container [ el ];
{ open_window; format_container }

let setup () =
let open_window = create () in
let+ () = replace_open_window open_window in
let setup el =
let open_window = create el in
let* () = replace_open_window open_window in
let resize _ = ignore @@ replace_open_window open_window in
let _listener = Ev.listen Ev.resize resize (Window.as_target G.window) in
()
Fut.tick ~ms:0
2 changes: 1 addition & 1 deletion src/engine/normalization.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
It is important that 2 is not made by moving the window, as otherwise on
rescaling the window, the scale would change... *)

val setup : unit -> unit Fut.t
val setup : Brr.El.t -> unit Fut.t
val translate_coords : float * float -> float * float

0 comments on commit c61a697

Please sign in to comment.