diff --git a/dotscape b/dotscape index f72227f..400f36c 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/common-update.sml b/fcore/common-update.sml index c35440b..bae17ac 100644 --- a/fcore/common-update.sml +++ b/fcore/common-update.sml @@ -7,6 +7,43 @@ struct open InputMessage open UpdateMessage + fun resizeWindow (model, width, height, dots) = + let + val + { squares + , canvasWidth + , canvasHeight + , showGraph + , arrowX + , arrowY + , xClickPoints + , yClickPoints + , ... + } = model + val maxSide = Int.max (canvasWidth, canvasHeight) + + val squares = CollisionTree.toTriangles + ( width + , height + , squares + , maxSide + , canvasWidth + , canvasHeight + , xClickPoints + , yClickPoints + ) + + val graphLines = + if showGraph then GraphLines.generate model else Vector.fromList [] + + val drawMsg = + RESIZE_SQUARES_DOTS_AND_GRAPH + {squares = squares, graphLines = graphLines, dots = dots} + val drawMsg = [DRAW drawMsg] + in + (model, drawMsg) + end + fun getSaveSquaresMsg (model: app_type) = let val {canvasWidth, canvasHeight, squares, ...} = model diff --git a/fcore/move-mode.sml b/fcore/move-mode.sml index de25963..ed7eae9 100644 --- a/fcore/move-mode.sml +++ b/fcore/move-mode.sml @@ -5,7 +5,13 @@ struct open DrawMessage open UpdateMessage - (* todo: resize message *) + fun resizeWindow (model, width, height) = + let + val model = AppWith.windowResize (model, width, height) + val dots = Vector.fromList [] + in + CommonUpdate.resizeWindow (model, width, height, dots) + end fun getDrawMsg (model: app_type) = let @@ -123,5 +129,6 @@ struct | ARROW_LEFT => moveImageLeft model | ARROW_RIGHT => moveImageRight model | KEY_ESC => enterNormalMode model + | RESIZE_WINDOW {width, height} => resizeWindow (model, width, height) | _ => (model, []) end diff --git a/fcore/normal-mode.sml b/fcore/normal-mode.sml index 6112332..836e18a 100644 --- a/fcore/normal-mode.sml +++ b/fcore/normal-mode.sml @@ -194,42 +194,10 @@ struct fun resizeWindow (model, width, height) = let val model = AppWith.windowResize (model, width, height) - - val - { squares - , canvasWidth - , canvasHeight - , showGraph - , arrowX - , arrowY - , xClickPoints - , yClickPoints - , ... - } = model - val maxSide = Int.max (canvasWidth, canvasHeight) - - val squares = CollisionTree.toTriangles - ( width - , height - , squares - , maxSide - , canvasWidth - , canvasHeight - , xClickPoints - , yClickPoints - ) - - val graphLines = - if showGraph then GraphLines.generate model else Vector.fromList [] - + val {arrowX, arrowY, ...} = model 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) + CommonUpdate.resizeWindow (model, width, height, dots) end fun undoAction model = (model, [])