a bit of formatting (no other changes in this commit)

This commit is contained in:
2024-07-31 12:30:12 +01:00
parent d18e6f105d
commit 6a2fe3ed18
6 changed files with 40 additions and 33 deletions

View File

@@ -94,8 +94,8 @@ struct
| MOUSE_LEFT_RELEASE => | MOUSE_LEFT_RELEASE =>
let let
val _ = print "mouse released\n" val _ = print "mouse released\n"
val drawMsg = DRAW_BUTTON val drawMsg =
(getClickPos (mouseX, mouseY, 1.0, 0.0, 0.0)) DRAW_BUTTON (getClickPos (mouseX, mouseY, 1.0, 0.0, 0.0))
in in
(model, drawMsg, mouseX, mouseY) (model, drawMsg, mouseX, mouseY)
end end

View File

@@ -106,5 +106,4 @@ struct
in in
() ()
end end
end end

View File

@@ -7,7 +7,8 @@ struct
fun loop (inputMailbox, drawMailbox, mouseX, mouseY, model) = fun loop (inputMailbox, drawMailbox, mouseX, mouseY, model) =
let let
val inputMsg = Mailbox.recv inputMailbox val inputMsg = Mailbox.recv inputMailbox
val (model, drawMsg, mouseX, mouseY) = AppUpdate.update (model, mouseX, mouseY, inputMsg) val (model, drawMsg, mouseX, mouseY) =
AppUpdate.update (model, mouseX, mouseY, inputMsg)
val _ = Mailbox.send (drawMailbox, drawMsg) val _ = Mailbox.send (drawMailbox, drawMsg)
in in
loop (inputMailbox, drawMailbox, mouseX, mouseY, model) loop (inputMailbox, drawMailbox, mouseX, mouseY, model)
@@ -17,7 +18,8 @@ struct
loop (inputMailbox, drawMailbox, 0, 0, AppType.initial) loop (inputMailbox, drawMailbox, 0, 0, AppType.initial)
end end
fun draw (drawMailbox, window, graphDrawObject, buttonDrawObject, buttonDrawLength) = fun draw
(drawMailbox, window, graphDrawObject, buttonDrawObject, buttonDrawLength) =
if not (Glfw.windowShouldClose window) then if not (Glfw.windowShouldClose window) then
let let
val _ = Gles3.clearColor (1.0, 1.0, 1.0, 1.0) val _ = Gles3.clearColor (1.0, 1.0, 1.0, 1.0)
@@ -29,7 +31,13 @@ struct
val _ = Glfw.pollEvents () val _ = Glfw.pollEvents ()
val _ = Glfw.swapBuffers window val _ = Glfw.swapBuffers window
in in
draw (drawMailbox, window, graphDrawObject, buttonDrawObject, buttonDrawLength) draw
( drawMailbox
, window
, graphDrawObject
, buttonDrawObject
, buttonDrawLength
)
end end
else else
Glfw.terminate () Glfw.terminate ()

View File

@@ -21,8 +21,7 @@ struct
val _ = Input.exportMouseMoveCallback mouseMoveCallback val _ = Input.exportMouseMoveCallback mouseMoveCallback
val _ = Input.setMouseMoveCallback window val _ = Input.setMouseMoveCallback window
val mouseClickCallback = val mouseClickCallback = mouseClickCallback inputMailbox
mouseClickCallback inputMailbox
val _ = Input.exportMouseClickCallback mouseClickCallback val _ = Input.exportMouseClickCallback mouseClickCallback
val _ = Input.setMouseClickCallback window val _ = Input.setMouseClickCallback window
in in

View File

@@ -19,9 +19,12 @@ struct
val inputMailbox = Mailbox.mailbox () val inputMailbox = Mailbox.mailbox ()
val drawMailbox = Mailbox.mailbox () val drawMailbox = Mailbox.mailbox ()
val _ = CML.spawn (fn () => InputCallbacks.registerCallbacks (window, inputMailbox)) val _ = CML.spawn (fn () =>
InputCallbacks.registerCallbacks (window, inputMailbox))
val _ = CML.spawn (fn () => EventLoop.update (inputMailbox, drawMailbox)) val _ = CML.spawn (fn () => EventLoop.update (inputMailbox, drawMailbox))
val _ = CML.spawn (fn () => EventLoop.draw (drawMailbox, window, graphDrawObject, buttonDrawObject, 0)) val _ = CML.spawn (fn () =>
EventLoop.draw
(drawMailbox, window, graphDrawObject, buttonDrawObject, 0))
in in
() ()
end end

View File

@@ -1,11 +1,9 @@
signature DRAW_MESSAGE = signature DRAW_MESSAGE =
sig sig
datatype t = datatype t = DRAW_BUTTON of Real32.real vector
DRAW_BUTTON of Real32.real vector
end end
structure DrawMessage :> DRAW_MESSAGE = structure DrawMessage :> DRAW_MESSAGE =
struct struct
datatype t = datatype t = DRAW_BUTTON of Real32.real vector
DRAW_BUTTON of Real32.real vector
end end