progress towards adding load functionality'
This commit is contained in:
@@ -14,6 +14,7 @@ int KEY_S = GLFW_KEY_S;
|
||||
int KEY_E = GLFW_KEY_E;
|
||||
int KEY_I = GLFW_KEY_I;
|
||||
int KEY_L = GLFW_KEY_L;
|
||||
int KEY_O = GLFW_KEY_O;
|
||||
|
||||
int KEY_ENTER = GLFW_KEY_ENTER;
|
||||
int KEY_SPACE = GLFW_KEY_SPACE;
|
||||
|
||||
@@ -46,6 +46,8 @@ struct
|
||||
_symbol "KEY_I" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_L, _) =
|
||||
_symbol "KEY_L" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_O, _) =
|
||||
_symbol "KEY_O" public : ( unit -> int ) * ( int -> unit );
|
||||
|
||||
val (KEY_ENTER, _) =
|
||||
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );
|
||||
|
||||
@@ -355,6 +355,15 @@ struct
|
||||
|
||||
fun trianglesLoadError model = (model, NO_MAILBOX)
|
||||
|
||||
fun enterBrowseMode model =
|
||||
let
|
||||
val model = AppWith.mode (model, AppType.BROWSE_MODE)
|
||||
(* should draw modal window as well, but that's not needed right now *)
|
||||
val fileMsg = LOAD_FILES (#openFilePath model)
|
||||
in
|
||||
(model, FILE fileMsg)
|
||||
end
|
||||
|
||||
fun updateNormalMode (model: app_type, inputMsg) =
|
||||
case inputMsg of
|
||||
MOUSE_MOVE {x = mouseX, y = mouseY} =>
|
||||
@@ -370,6 +379,7 @@ struct
|
||||
| KEY_CTRL_S => getSaveTrianglesMsg model
|
||||
| KEY_CTRL_L => getLoadTrianglesMsg model
|
||||
| KEY_CTRL_E => getExportTrianglesMsg model
|
||||
| KEY_CTRL_O => enterBrowseMode model
|
||||
| ARROW_UP => moveArrowUp model
|
||||
| ARROW_LEFT => moveArrowLeft model
|
||||
| ARROW_RIGHT => moveArrowRight model
|
||||
@@ -380,5 +390,7 @@ struct
|
||||
| TRIANGLES_LOAD_ERROR => trianglesLoadError model
|
||||
|
||||
fun update (model: app_type, inputMsg) =
|
||||
case #mode model of NORMAL_MODE => updateNormalMode (model, inputMsg)
|
||||
case #mode model of
|
||||
NORMAL_MODE => updateNormalMode (model, inputMsg)
|
||||
| BROWSE_MODE => updateNormalMode (model, inputMsg)
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ signature APP_WITH =
|
||||
sig
|
||||
val graphVisibility: AppType.app_type * bool -> AppType.app_type
|
||||
|
||||
val mode: AppType.app_type * AppType.app_mode -> AppType.app_type
|
||||
|
||||
val windowResize: AppType.app_type * int * int -> AppType.app_type
|
||||
|
||||
val mousePosition: AppType.app_type * Real32.real * Real32.real
|
||||
@@ -489,6 +491,48 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
fun mode (app: app_type, newMode) =
|
||||
let
|
||||
val
|
||||
{ mode = _
|
||||
, triangleStage
|
||||
, triangles
|
||||
, numClickPoints
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, undo
|
||||
, redo
|
||||
, mouseX
|
||||
, mouseY
|
||||
, arrowX
|
||||
, arrowY
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
} = app
|
||||
in
|
||||
{ mode = newMode
|
||||
, showGraph = showGraph
|
||||
, triangleStage = triangleStage
|
||||
, triangles = triangles
|
||||
, undo = undo
|
||||
, redo = redo
|
||||
, numClickPoints = numClickPoints
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
}
|
||||
end
|
||||
|
||||
fun useTriangles (app: app_type, triangles) =
|
||||
let
|
||||
val
|
||||
|
||||
@@ -171,15 +171,12 @@ struct
|
||||
fun getDirList (dir, acc) =
|
||||
case OS.FileSys.readDir dir of
|
||||
SOME path =>
|
||||
let
|
||||
val _ = print (path ^ "\n")
|
||||
val acc =
|
||||
if OS.FileSys.isDir path then (AppType.FOLDER path) :: acc
|
||||
else if OS.FileSys.isLink path then acc
|
||||
else (AppType.FILE path) :: acc
|
||||
in
|
||||
if OS.FileSys.isDir path then
|
||||
getDirList (dir, AppType.FOLDER path :: acc)
|
||||
else if OS.FileSys.isLink path then
|
||||
getDirList (dir, acc)
|
||||
end
|
||||
else
|
||||
getDirList (dir, AppType.FILE path :: acc)
|
||||
| NONE => let val acc = List.rev acc in Vector.fromList acc end
|
||||
|
||||
fun loadFiles (path, inputMailbox) =
|
||||
|
||||
@@ -86,6 +86,10 @@ struct
|
||||
andalso mods = 0x0
|
||||
then
|
||||
Mailbox.send (mailbox, KEY_SPACE)
|
||||
else if
|
||||
key = Input.KEY_O () andalso action = Input.PRESS () andalso mods = 0x02
|
||||
then
|
||||
Mailbox.send (mailbox, KEY_CTRL_O)
|
||||
else
|
||||
()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ sig
|
||||
| KEY_CTRL_S
|
||||
| KEY_CTRL_L
|
||||
| KEY_CTRL_E
|
||||
| KEY_CTRL_O
|
||||
| ARROW_UP
|
||||
| ARROW_LEFT
|
||||
| ARROW_RIGHT
|
||||
@@ -19,6 +20,7 @@ sig
|
||||
| KEY_SPACE
|
||||
| USE_TRIANGLES of AppType.triangle list
|
||||
| TRIANGLES_LOAD_ERROR
|
||||
| FILE_BROWSER_AND_PATH of { fileBrowser: AppType.file_browser_item vector, path: string }
|
||||
end
|
||||
|
||||
structure InputMessage :> INPUT_MESSAGE =
|
||||
@@ -34,6 +36,7 @@ struct
|
||||
| KEY_CTRL_S
|
||||
| KEY_CTRL_L
|
||||
| KEY_CTRL_E
|
||||
| KEY_CTRL_O
|
||||
| ARROW_UP
|
||||
| ARROW_LEFT
|
||||
| ARROW_RIGHT
|
||||
@@ -42,4 +45,5 @@ struct
|
||||
| KEY_SPACE
|
||||
| USE_TRIANGLES of AppType.triangle list
|
||||
| TRIANGLES_LOAD_ERROR
|
||||
| FILE_BROWSER_AND_PATH of { fileBrowser: AppType.file_browser_item vector, path: string }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user