progress updating canvas width at runtime

This commit is contained in:
2025-07-11 17:41:47 +01:00
parent e760b158ac
commit 08ed5cc3d5
4 changed files with 47 additions and 5 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -860,13 +860,14 @@ struct
} = app
val squares = changeSquaresSize (squares, newCanvasWidth, canvasHeight)
val arrowX = Int.min (arrowX, newCanvasWidth)
in
{ mode = mode
, canvasWidth = newCanvasWidth
, arrowX = arrowX
, mouseX = mouseX
, mouseY = mouseY
, squares = squares
, arrowX = arrowX
, arrowY = arrowY
, canvasHeight = canvasHeight
, windowWidth = windowWidth

View File

@@ -154,9 +154,6 @@ struct
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
val halfWidth = Real32.fromInt (windowWidth div 2)
val halfHeight = Real32.fromInt (windowHeight div 2)
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles
( windowWidth
@@ -248,13 +245,55 @@ struct
end
fun updateNum (model: app_type, newNum) =
(AppWith.modalNum (model, newNum), [])
(AppWith.modalNum (model, newNum), [])
fun updateRed model = (AppWith.r model, [])
fun updateGreen model = (AppWith.g model, [])
fun updateBlue model = (AppWith.b model, [])
fun updateAlpha model = (AppWith.a model, [])
fun updateCanvasWidth (model, newCanvasWidth) =
let
val model = AppWith.canvasWidth (model, newCanvasWidth)
val
{ arrowX
, arrowY
, windowWidth
, windowHeight
, squares
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
, showGraph
, ...
} = model
val dotVec = getDotVecFromIndices (model, #arrowX model, #arrowY model)
val graphLines =
if showGraph then GraphLines.generate model else Vector.fromList []
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles
( windowWidth
, windowHeight
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val msg =
RESIZE_SQUARES_DOTS_AND_GRAPH
{squares = squares, dots = dotVec, graphLines = graphLines}
in
(model, [DRAW msg])
end
fun enterBrowseMode model =
let
val model = AppWith.mode (model, AppType.BROWSE_MODE)
@@ -283,6 +322,7 @@ struct
| KEY_G => updateGreen model
| KEY_B => updateBlue model
| KEY_A => updateAlpha model
| KEY_W newCanvasWidth => updateCanvasWidth (model, newCanvasWidth)
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
| UNDO_ACTION => undoAction model
| REDO_ACTION => redoAction model

View File

@@ -12,6 +12,7 @@ struct
| KEY_B
| KEY_T
| KEY_A
| KEY_W of int
| KEY_CTRL_S
| KEY_CTRL_L
| KEY_CTRL_E