finished with normal nmode for app-update refactoring
This commit is contained in:
@@ -163,7 +163,7 @@ struct
|
||||
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide)
|
||||
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
|
||||
in
|
||||
(model, [drawMsg])
|
||||
(model, [DRAW drawMsg])
|
||||
end
|
||||
|
||||
fun mouseLeftClick model =
|
||||
@@ -198,4 +198,97 @@ struct
|
||||
in
|
||||
(model, drawMsg)
|
||||
end
|
||||
|
||||
fun undoAction model = (model, [])
|
||||
|
||||
fun redoAction model = (model, [])
|
||||
|
||||
fun toggleGraph (model: app_type) =
|
||||
if #showGraph model then
|
||||
let
|
||||
val model = AppWith.graphVisibility (model, false)
|
||||
val drawMsg = DRAW_GRAPH (Vector.fromList [])
|
||||
val drawMsg = [DRAW drawMsg]
|
||||
in
|
||||
(model, drawMsg)
|
||||
end
|
||||
else
|
||||
let
|
||||
val model = AppWith.graphVisibility (model, true)
|
||||
val graphLines = GraphLines.generate model
|
||||
val drawMsg = DRAW_GRAPH graphLines
|
||||
val drawMsg = [DRAW drawMsg]
|
||||
in
|
||||
(model, drawMsg)
|
||||
end
|
||||
|
||||
fun updateNum (model: app_type, inputNum) =
|
||||
let
|
||||
val oldNum = #modalNum model
|
||||
val newNum = oldNum * 10 + inputNum
|
||||
val newNum = if newNum > 255 then 0 else newNum
|
||||
in
|
||||
(AppWith.modalNum (model, newNum), [])
|
||||
end
|
||||
|
||||
fun updateRed model = (AppWith.r model, [])
|
||||
fun updateGreen model = (AppWith.g model, [])
|
||||
fun updateBlue model = (AppWith.b model, [])
|
||||
|
||||
(* unimplemented *)
|
||||
fun getSaveSquaresMsg model = (model, [])
|
||||
|
||||
fun getLoadSquaresMsg model = (model, [])
|
||||
|
||||
fun getExportSquaresMsg model = (model, [])
|
||||
|
||||
fun useSquaresInNormalMode (model, squares) = (model, [])
|
||||
|
||||
fun squaresLoadError model = (model, [])
|
||||
|
||||
fun enterBrowseMode model =
|
||||
let
|
||||
val model = AppWith.mode (model, AppType.BROWSE_MODE)
|
||||
(* todo: should draw modal window as well *)
|
||||
val fileMsg = LOAD_FILES (#openFilePath model)
|
||||
val fileMsg = [FILE fileMsg]
|
||||
in
|
||||
(model, fileMsg)
|
||||
end
|
||||
|
||||
fun handleFileBrowserAndPathInNormalMode (model, fileBrowser, path) =
|
||||
let val model = AppWith.fileBrowserAndPath (model, fileBrowser, path)
|
||||
in (model, [])
|
||||
end
|
||||
|
||||
fun updateNormalMode (model: app_type, inputMsg) =
|
||||
case inputMsg of
|
||||
MOUSE_MOVE {x = mouseX, y = mouseY} =>
|
||||
let val model = AppWith.mousePosition (model, mouseX, mouseY)
|
||||
in mouseMoveOrRelease model
|
||||
end
|
||||
| MOUSE_LEFT_RELEASE => mouseMoveOrRelease model
|
||||
| MOUSE_LEFT_CLICK => mouseLeftClick model
|
||||
| NUM num => updateNum (model, num)
|
||||
| KEY_R => updateRed model
|
||||
| KEY_G => updateGreen model
|
||||
| KEY_B => updateBlue model
|
||||
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||
| UNDO_ACTION => undoAction model
|
||||
| REDO_ACTION => redoAction model
|
||||
| KEY_T => toggleGraph model
|
||||
| KEY_CTRL_S => getSaveSquaresMsg model
|
||||
| KEY_CTRL_L => getLoadSquaresMsg model
|
||||
| KEY_CTRL_E => getExportSquaresMsg model
|
||||
| KEY_CTRL_O => enterBrowseMode model
|
||||
| ARROW_UP => moveArrowUp model
|
||||
| ARROW_LEFT => moveArrowLeft model
|
||||
| ARROW_RIGHT => moveArrowRight model
|
||||
| ARROW_DOWN => moveArrowDown model
|
||||
| KEY_ENTER => enterOrSpaceCoordinates model
|
||||
| KEY_SPACE => enterOrSpaceCoordinates model
|
||||
| USE_SQUARES squares => useSquaresInNormalMode (model, squares)
|
||||
| SQUARES_LOAD_ERROR => squaresLoadError model
|
||||
| FILE_BROWSER_AND_PATH {fileBrowser, path} =>
|
||||
handleFileBrowserAndPathInNormalMode (model, fileBrowser, path)
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ struct
|
||||
| KEY_SPACE
|
||||
| USE_SQUARES of
|
||||
{squares: int vector vector, canvasWidth: int, canvasHeight: int}
|
||||
| SQUARE_LOAD_ERROR
|
||||
| SQUARES_LOAD_ERROR
|
||||
| FILE_BROWSER_AND_PATH of
|
||||
{fileBrowser: AppType.file_browser_item vector, path: string}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user