add functionality for changing height of canvas
This commit is contained in:
@@ -895,6 +895,68 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
fun canvasHeight (app: app_type, newCanvasHeight) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, canvasHeight = _
|
||||
, canvasWidth
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, a
|
||||
, modalNum
|
||||
, undo
|
||||
, redo
|
||||
} = app
|
||||
|
||||
val squares = changeSquaresSize (squares, canvasWidth, newCanvasHeight)
|
||||
val arrowY = Int.min (arrowY, newCanvasHeight)
|
||||
val (xClickPoints, yClickPoints) =
|
||||
ClickPoints.generate
|
||||
(windowWidth, windowHeight, canvasWidth, newCanvasHeight)
|
||||
in
|
||||
{ mode = mode
|
||||
, canvasHeight = newCanvasHeight
|
||||
, canvasWidth = canvasWidth
|
||||
, arrowX = arrowX
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowY = arrowY
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, a = a
|
||||
, modalNum = 0
|
||||
, undo = undo
|
||||
, redo = redo
|
||||
}
|
||||
end
|
||||
|
||||
(* todo:
|
||||
fun useSquaresAndSetNormalMode (app: app_type, squares, canvasWidth, canvasHeight) =
|
||||
*)
|
||||
|
||||
@@ -252,10 +252,10 @@ struct
|
||||
fun updateBlue model = (AppWith.b model, [])
|
||||
fun updateAlpha model = (AppWith.a model, [])
|
||||
|
||||
fun updateCanvasWidth model =
|
||||
fun updateCanvas (model, canvasWidth, canvasHeight) =
|
||||
let
|
||||
val newCanvasWidth = #modalNum model
|
||||
val model = AppWith.canvasWidth (model, newCanvasWidth)
|
||||
val newCanvaidth = #modalNum model
|
||||
val model = AppWith.canvasWidth (model, canvasWidth)
|
||||
|
||||
val
|
||||
{ arrowX
|
||||
@@ -263,15 +263,13 @@ struct
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, showGraph
|
||||
, ...
|
||||
} = model
|
||||
|
||||
val dotVec = getDotVecFromIndices (model, #arrowX model, #arrowY model)
|
||||
val dotVec = getDotVecFromIndices (model, arrowX, arrowY)
|
||||
val graphLines =
|
||||
if showGraph then GraphLines.generate model else Vector.fromList []
|
||||
|
||||
@@ -294,6 +292,23 @@ struct
|
||||
(model, [DRAW msg])
|
||||
end
|
||||
|
||||
fun updateCanvasWidth model =
|
||||
let
|
||||
val newCanvasWidth = #modalNum model
|
||||
val (model as {canvasWidth, canvasHeight, ...}) =
|
||||
AppWith.canvasWidth (model, newCanvasWidth)
|
||||
in
|
||||
updateCanvas (model, canvasWidth, canvasHeight)
|
||||
end
|
||||
|
||||
fun updateCanvasHeight model =
|
||||
let
|
||||
val newCanvasHeight = #modalNum model
|
||||
val (model as {canvasWidth, canvasHeight, ...}) =
|
||||
AppWith.canvasHeight (model, newCanvasHeight)
|
||||
in
|
||||
updateCanvas (model, canvasWidth, canvasHeight)
|
||||
end
|
||||
|
||||
fun enterBrowseMode model =
|
||||
let
|
||||
@@ -324,6 +339,7 @@ struct
|
||||
| KEY_B => updateBlue model
|
||||
| KEY_A => updateAlpha model
|
||||
| KEY_W => updateCanvasWidth model
|
||||
| KEY_H => updateCanvasHeight model
|
||||
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||
| UNDO_ACTION => undoAction model
|
||||
| REDO_ACTION => redoAction model
|
||||
|
||||
Reference in New Issue
Block a user