diff --git a/dotscape b/dotscape index fa3d28a..d2cbfdc 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/app-with.sml b/fcore/app-with.sml index b21ef16..950728f 100644 --- a/fcore/app-with.sml +++ b/fcore/app-with.sml @@ -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) = *) diff --git a/fcore/normal-mode.sml b/fcore/normal-mode.sml index 917f7a7..672d87d 100644 --- a/fcore/normal-mode.sml +++ b/fcore/normal-mode.sml @@ -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 diff --git a/ffi/glfw-input.c b/ffi/glfw-input.c index 89acd59..8c93d06 100644 --- a/ffi/glfw-input.c +++ b/ffi/glfw-input.c @@ -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; diff --git a/ffi/glfw-input.sml b/ffi/glfw-input.sml index 84eed39..db5a3ab 100644 --- a/ffi/glfw-input.sml +++ b/ffi/glfw-input.sml @@ -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 ); diff --git a/imperative-shell/input-callbacks.sml b/imperative-shell/input-callbacks.sml index 3c4a51a..8e54d12 100644 --- a/imperative-shell/input-callbacks.sml +++ b/imperative-shell/input-callbacks.sml @@ -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 diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index 9e859f6..b1f8033 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -13,6 +13,7 @@ struct | KEY_T | KEY_A | KEY_W + | KEY_H | KEY_CTRL_S | KEY_CTRL_L | KEY_CTRL_E