port function to handlw window resizing event
This commit is contained in:
@@ -14,29 +14,21 @@ struct
|
||||
val ypos = Vector.sub (yClickPoints, vIdx)
|
||||
|
||||
val endXpos =
|
||||
if hIdx + 1 = Vector.length xClickPoints then
|
||||
xpos
|
||||
else
|
||||
Vector.sub (xClickPoints, hIdx + 1)
|
||||
if hIdx + 1 = Vector.length xClickPoints then xpos
|
||||
else Vector.sub (xClickPoints, hIdx + 1)
|
||||
|
||||
val endYpos =
|
||||
if vIdx + 1 = Vector.length yClickPoints then
|
||||
ypos
|
||||
else
|
||||
Vector.sub (yClickPoints, vIdx + 1)
|
||||
if vIdx + 1 = Vector.length yClickPoints then ypos
|
||||
else Vector.sub (yClickPoints, vIdx + 1)
|
||||
|
||||
val tl =
|
||||
ClickPoints.getDrawDotRgb
|
||||
(xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val tr =
|
||||
ClickPoints.getDrawDotRgb
|
||||
(endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val bl =
|
||||
ClickPoints.getDrawDotRgb
|
||||
(xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val br =
|
||||
ClickPoints.getDrawDotRgb
|
||||
(endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val tl = ClickPoints.getDrawDotRgb
|
||||
(xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val tr = ClickPoints.getDrawDotRgb
|
||||
(endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val bl = ClickPoints.getDrawDotRgb
|
||||
(xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
val br = ClickPoints.getDrawDotRgb
|
||||
(endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||
in
|
||||
Vector.concat [tl, tr, bl, br]
|
||||
end
|
||||
@@ -157,7 +149,8 @@ struct
|
||||
val xpos = Vector.sub (xClickPoints, hIdx)
|
||||
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 dotVec = getDotVecFromIndices (model, hIdx, vIdx)
|
||||
@@ -166,7 +159,7 @@ struct
|
||||
val halfHeight = Real32.fromInt (windowHeight div 2)
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val squares =
|
||||
val squares =
|
||||
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide)
|
||||
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
|
||||
in
|
||||
@@ -183,4 +176,26 @@ struct
|
||||
in addCoordinates (model, arrowX, arrowY)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user