port function to handlw window resizing event

This commit is contained in:
2025-07-06 14:08:44 +01:00
parent d231edda6a
commit 11052e801f

View File

@@ -14,28 +14,20 @@ struct
val ypos = Vector.sub (yClickPoints, vIdx) val ypos = Vector.sub (yClickPoints, vIdx)
val endXpos = val endXpos =
if hIdx + 1 = Vector.length xClickPoints then if hIdx + 1 = Vector.length xClickPoints then xpos
xpos else Vector.sub (xClickPoints, hIdx + 1)
else
Vector.sub (xClickPoints, hIdx + 1)
val endYpos = val endYpos =
if vIdx + 1 = Vector.length yClickPoints then if vIdx + 1 = Vector.length yClickPoints then ypos
ypos else Vector.sub (yClickPoints, vIdx + 1)
else
Vector.sub (yClickPoints, vIdx + 1)
val tl = val tl = ClickPoints.getDrawDotRgb
ClickPoints.getDrawDotRgb
(xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight) (xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
val tr = val tr = ClickPoints.getDrawDotRgb
ClickPoints.getDrawDotRgb
(endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight) (endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
val bl = val bl = ClickPoints.getDrawDotRgb
ClickPoints.getDrawDotRgb
(xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight) (xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
val br = val br = ClickPoints.getDrawDotRgb
ClickPoints.getDrawDotRgb
(endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight) (endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
in in
Vector.concat [tl, tr, bl, br] Vector.concat [tl, tr, bl, br]
@@ -157,7 +149,8 @@ struct
val xpos = Vector.sub (xClickPoints, hIdx) val xpos = Vector.sub (xClickPoints, hIdx)
val ypos = Vector.sub (yClickPoints, vIdx) val ypos = Vector.sub (yClickPoints, vIdx)
val model = AppWith.addSquare (model, realToInt xpos, realToInt ypos, hIdx, vIdx) val model = AppWith.addSquare
(model, realToInt xpos, realToInt ypos, hIdx, vIdx)
val squares = #squares model val squares = #squares model
val dotVec = getDotVecFromIndices (model, hIdx, vIdx) val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
@@ -183,4 +176,26 @@ struct
in addCoordinates (model, arrowX, arrowY) in addCoordinates (model, arrowX, arrowY)
end end
fun resizeWindow (model, width, height) =
let
val model = AppWith.windowResize (model, width, height)
val {squares, canvasWidth, canvasHeight, showGraph, arrowX, arrowY, ...} =
model
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles (width, height, squares, maxSide)
val graphLines =
if showGraph then GraphLines.generate model else Vector.fromList []
val dots = getDotVecFromIndices (model, arrowX, arrowY)
val drawMsg =
RESIZE_SQUARES_DOTS_AND_GRAPH
{squares = squares, graphLines = graphLines, dots = dots}
val drawMsg = [DRAW drawMsg]
in
(model, drawMsg)
end
end end