add functionality for changing height of canvas
This commit is contained in:
@@ -895,6 +895,68 @@ struct
|
|||||||
}
|
}
|
||||||
end
|
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:
|
(* todo:
|
||||||
fun useSquaresAndSetNormalMode (app: app_type, squares, canvasWidth, canvasHeight) =
|
fun useSquaresAndSetNormalMode (app: app_type, squares, canvasWidth, canvasHeight) =
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -252,10 +252,10 @@ struct
|
|||||||
fun updateBlue model = (AppWith.b model, [])
|
fun updateBlue model = (AppWith.b model, [])
|
||||||
fun updateAlpha model = (AppWith.a model, [])
|
fun updateAlpha model = (AppWith.a model, [])
|
||||||
|
|
||||||
fun updateCanvasWidth model =
|
fun updateCanvas (model, canvasWidth, canvasHeight) =
|
||||||
let
|
let
|
||||||
val newCanvasWidth = #modalNum model
|
val newCanvaidth = #modalNum model
|
||||||
val model = AppWith.canvasWidth (model, newCanvasWidth)
|
val model = AppWith.canvasWidth (model, canvasWidth)
|
||||||
|
|
||||||
val
|
val
|
||||||
{ arrowX
|
{ arrowX
|
||||||
@@ -263,15 +263,13 @@ struct
|
|||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, squares
|
, squares
|
||||||
, canvasWidth
|
|
||||||
, canvasHeight
|
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, showGraph
|
, showGraph
|
||||||
, ...
|
, ...
|
||||||
} = model
|
} = model
|
||||||
|
|
||||||
val dotVec = getDotVecFromIndices (model, #arrowX model, #arrowY model)
|
val dotVec = getDotVecFromIndices (model, arrowX, arrowY)
|
||||||
val graphLines =
|
val graphLines =
|
||||||
if showGraph then GraphLines.generate model else Vector.fromList []
|
if showGraph then GraphLines.generate model else Vector.fromList []
|
||||||
|
|
||||||
@@ -294,6 +292,23 @@ struct
|
|||||||
(model, [DRAW msg])
|
(model, [DRAW msg])
|
||||||
end
|
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 =
|
fun enterBrowseMode model =
|
||||||
let
|
let
|
||||||
@@ -324,6 +339,7 @@ struct
|
|||||||
| KEY_B => updateBlue model
|
| KEY_B => updateBlue model
|
||||||
| KEY_A => updateAlpha model
|
| KEY_A => updateAlpha model
|
||||||
| KEY_W => updateCanvasWidth model
|
| KEY_W => updateCanvasWidth model
|
||||||
|
| KEY_H => updateCanvasHeight model
|
||||||
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||||
| UNDO_ACTION => undoAction model
|
| UNDO_ACTION => undoAction model
|
||||||
| REDO_ACTION => redoAction model
|
| REDO_ACTION => redoAction model
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ int KEY_L = GLFW_KEY_L;
|
|||||||
int KEY_O = GLFW_KEY_O;
|
int KEY_O = GLFW_KEY_O;
|
||||||
int KEY_A = GLFW_KEY_A;
|
int KEY_A = GLFW_KEY_A;
|
||||||
int KEY_W = GLFW_KEY_W;
|
int KEY_W = GLFW_KEY_W;
|
||||||
|
int KEY_H = GLFW_KEY_H;
|
||||||
|
|
||||||
int KEY_ENTER = GLFW_KEY_ENTER;
|
int KEY_ENTER = GLFW_KEY_ENTER;
|
||||||
int KEY_SPACE = GLFW_KEY_SPACE;
|
int KEY_SPACE = GLFW_KEY_SPACE;
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ struct
|
|||||||
_symbol "KEY_A" public : ( unit -> int ) * ( int -> unit );
|
_symbol "KEY_A" public : ( unit -> int ) * ( int -> unit );
|
||||||
val (KEY_W, _) =
|
val (KEY_W, _) =
|
||||||
_symbol "KEY_W" public : ( unit -> int ) * ( int -> unit );
|
_symbol "KEY_W" public : ( unit -> int ) * ( int -> unit );
|
||||||
|
val (KEY_H, _) =
|
||||||
|
_symbol "KEY_H" public : ( unit -> int ) * ( int -> unit );
|
||||||
|
|
||||||
val (KEY_ENTER, _) =
|
val (KEY_ENTER, _) =
|
||||||
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );
|
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ struct
|
|||||||
key = Input.KEY_W () andalso action = Input.PRESS () andalso mods = 0
|
key = Input.KEY_W () andalso action = Input.PRESS () andalso mods = 0
|
||||||
then
|
then
|
||||||
Mailbox.send (mailbox, KEY_W)
|
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
|
else if
|
||||||
key = Input.KEY_UP () andalso action <> Input.RELEASE ()
|
key = Input.KEY_UP () andalso action <> Input.RELEASE ()
|
||||||
andalso mods = 0x0
|
andalso mods = 0x0
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ struct
|
|||||||
| KEY_T
|
| KEY_T
|
||||||
| KEY_A
|
| KEY_A
|
||||||
| KEY_W
|
| KEY_W
|
||||||
|
| KEY_H
|
||||||
| KEY_CTRL_S
|
| KEY_CTRL_S
|
||||||
| KEY_CTRL_L
|
| KEY_CTRL_L
|
||||||
| KEY_CTRL_E
|
| KEY_CTRL_E
|
||||||
|
|||||||
Reference in New Issue
Block a user