add functionality for changing height of canvas

This commit is contained in:
2025-07-11 22:57:20 +01:00
parent a448fcf469
commit 86369db055
7 changed files with 92 additions and 6 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -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) =
*)

View File

@@ -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

View File

@@ -21,6 +21,7 @@ int KEY_L = GLFW_KEY_L;
int KEY_O = GLFW_KEY_O;
int KEY_A = GLFW_KEY_A;
int KEY_W = GLFW_KEY_W;
int KEY_H = GLFW_KEY_H;
int KEY_ENTER = GLFW_KEY_ENTER;
int KEY_SPACE = GLFW_KEY_SPACE;

View File

@@ -59,6 +59,8 @@ struct
_symbol "KEY_A" public : ( unit -> int ) * ( int -> unit );
val (KEY_W, _) =
_symbol "KEY_W" public : ( unit -> int ) * ( int -> unit );
val (KEY_H, _) =
_symbol "KEY_H" public : ( unit -> int ) * ( int -> unit );
val (KEY_ENTER, _) =
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );

View File

@@ -76,6 +76,10 @@ struct
key = Input.KEY_W () andalso action = Input.PRESS () andalso mods = 0
then
Mailbox.send (mailbox, KEY_W)
else if
key = Input.KEY_H () andalso action = Input.PRESS () andalso mods = 0
then
Mailbox.send (mailbox, KEY_H)
else if
key = Input.KEY_UP () andalso action <> Input.RELEASE ()
andalso mods = 0x0

View File

@@ -13,6 +13,7 @@ struct
| KEY_T
| KEY_A
| KEY_W
| KEY_H
| KEY_CTRL_S
| KEY_CTRL_L
| KEY_CTRL_E