add functionality to resize window in move mode
This commit is contained in:
@@ -7,6 +7,43 @@ struct
|
|||||||
open InputMessage
|
open InputMessage
|
||||||
open UpdateMessage
|
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) =
|
fun getSaveSquaresMsg (model: app_type) =
|
||||||
let
|
let
|
||||||
val {canvasWidth, canvasHeight, squares, ...} = model
|
val {canvasWidth, canvasHeight, squares, ...} = model
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ struct
|
|||||||
open DrawMessage
|
open DrawMessage
|
||||||
open UpdateMessage
|
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) =
|
fun getDrawMsg (model: app_type) =
|
||||||
let
|
let
|
||||||
@@ -123,5 +129,6 @@ struct
|
|||||||
| ARROW_LEFT => moveImageLeft model
|
| ARROW_LEFT => moveImageLeft model
|
||||||
| ARROW_RIGHT => moveImageRight model
|
| ARROW_RIGHT => moveImageRight model
|
||||||
| KEY_ESC => enterNormalMode model
|
| KEY_ESC => enterNormalMode model
|
||||||
|
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||||
| _ => (model, [])
|
| _ => (model, [])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -194,42 +194,10 @@ struct
|
|||||||
fun resizeWindow (model, width, height) =
|
fun resizeWindow (model, width, height) =
|
||||||
let
|
let
|
||||||
val model = AppWith.windowResize (model, width, height)
|
val model = AppWith.windowResize (model, width, height)
|
||||||
|
val {arrowX, arrowY, ...} = model
|
||||||
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 dots = getDotVecFromIndices (model, arrowX, arrowY)
|
val dots = getDotVecFromIndices (model, arrowX, arrowY)
|
||||||
|
|
||||||
val drawMsg =
|
|
||||||
RESIZE_SQUARES_DOTS_AND_GRAPH
|
|
||||||
{squares = squares, graphLines = graphLines, dots = dots}
|
|
||||||
val drawMsg = [DRAW drawMsg]
|
|
||||||
in
|
in
|
||||||
(model, drawMsg)
|
CommonUpdate.resizeWindow (model, width, height, dots)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun undoAction model = (model, [])
|
fun undoAction model = (model, [])
|
||||||
|
|||||||
Reference in New Issue
Block a user