begin drawing file browser text
This commit is contained in:
@@ -10,6 +10,7 @@ in
|
||||
functional-core/app/click-points.sml
|
||||
functional-core/app/graph-lines.sml
|
||||
functional-core/app/triangles.sml
|
||||
fonts/cozette-ascii.mlb
|
||||
end
|
||||
|
||||
functional-core/app/triangle-stage.sml
|
||||
|
||||
@@ -2,7 +2,7 @@ signature APP_TYPE =
|
||||
sig
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE
|
||||
|
||||
datatype file_browser_item = FILE of string | FOLDER of string
|
||||
datatype file_browser_item = IS_FILE of string | IS_FOLDER of string
|
||||
|
||||
datatype triangle_stage =
|
||||
NO_TRIANGLE
|
||||
@@ -44,7 +44,7 @@ structure AppType :> APP_TYPE =
|
||||
struct
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE
|
||||
|
||||
datatype file_browser_item = FILE of string | FOLDER of string
|
||||
datatype file_browser_item = IS_FILE of string | IS_FOLDER of string
|
||||
|
||||
type triangle =
|
||||
{ x1: Real32.real
|
||||
|
||||
@@ -386,13 +386,59 @@ struct
|
||||
(model, fileMsg)
|
||||
end
|
||||
|
||||
fun handleFileBrowserAndPath (model, fileBrowser, path) =
|
||||
fun handleFileBrowserAndPathInNormalMode (model, fileBrowser, path) =
|
||||
let val model = AppWith.fileBrowserAndPath (model, fileBrowser, path)
|
||||
(* todo: update and recreate vector indicating text to redraw,
|
||||
* if not in normal mode *)
|
||||
in (model, [])
|
||||
end
|
||||
|
||||
fun stringToVec (pos, str, acc, startX, startY, windowWidth, windowHeight) =
|
||||
if pos = String.size str then
|
||||
acc
|
||||
else
|
||||
let
|
||||
val chr = String.sub (str, pos)
|
||||
val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr)
|
||||
val chrVec = chrFun
|
||||
(startX, startY, 25.0, 25.0, windowWidth, windowHeight, 0.0, 0.0, 0.0)
|
||||
val acc = chrVec :: acc
|
||||
in
|
||||
stringToVec
|
||||
(pos + 1, str, acc, startX + 13, startY, windowWidth, windowHeight)
|
||||
end
|
||||
|
||||
fun buildFileBrowserText
|
||||
(pos, fileBrowser, acc, startY, windowWidth, windowHeight) =
|
||||
if pos = Vector.length fileBrowser then
|
||||
Vector.concat acc
|
||||
else
|
||||
let
|
||||
val item = Vector.sub (fileBrowser, pos)
|
||||
val itemText =
|
||||
case item of
|
||||
IS_FILE str => str
|
||||
| IS_FOLDER str => str
|
||||
val acc = stringToVec
|
||||
(0, itemText, acc, 10, startY, windowWidth, windowHeight)
|
||||
in
|
||||
buildFileBrowserText
|
||||
(pos + 1, fileBrowser, acc, startY + 23, windowWidth, windowHeight)
|
||||
end
|
||||
|
||||
fun handleFileBrowserAndPath (model, fileBrowser, path) =
|
||||
let
|
||||
val model = AppWith.fileBrowserAndPath (model, fileBrowser, path)
|
||||
|
||||
(* create vector indicating text to redraw *)
|
||||
val {windowWidth, windowHeight, ...} = model
|
||||
val ww = Real32.fromInt windowWidth
|
||||
val wh = Real32.fromInt windowHeight
|
||||
val textVec = buildFileBrowserText (0, fileBrowser, [], 10, ww, wh)
|
||||
|
||||
val drawMsg = DRAW_MODAL_TEXT textVec
|
||||
in
|
||||
(model, [DRAW drawMsg])
|
||||
end
|
||||
|
||||
fun updateNormalMode (model: app_type, inputMsg) =
|
||||
case inputMsg of
|
||||
MOUSE_MOVE {x = mouseX, y = mouseY} =>
|
||||
|
||||
@@ -26,7 +26,8 @@ struct
|
||||
val _ =
|
||||
AppDraw.drawTriangles (triangleDrawObject, triangleDrawLength)
|
||||
val _ = AppDraw.drawDot (dotDrawObject, dotDrawLength)
|
||||
val _ = AppDraw.drawModalText (modalTextDrawObject, modalTextDrawLength)
|
||||
val _ =
|
||||
AppDraw.drawModalText (modalTextDrawObject, modalTextDrawLength)
|
||||
|
||||
val _ = Glfw.swapBuffers window
|
||||
val _ = Glfw.pollEvents ()
|
||||
@@ -167,6 +168,24 @@ struct
|
||||
, modalTextDrawObject
|
||||
, modalTextDrawLength
|
||||
)
|
||||
end
|
||||
| DRAW_MODAL_TEXT vec =>
|
||||
let
|
||||
val _ = AppDraw.uploadModalText (modalTextDrawObject, vec)
|
||||
val modalTextDrawLength = Vector.length vec div 5
|
||||
in
|
||||
run
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, dotDrawObject
|
||||
, dotDrawLength
|
||||
, triangleDrawObject
|
||||
, triangleDrawLength
|
||||
, modalTextDrawObject
|
||||
, modalTextDrawLength
|
||||
)
|
||||
end)
|
||||
else
|
||||
Glfw.terminate ()
|
||||
|
||||
@@ -172,11 +172,11 @@ struct
|
||||
case OS.FileSys.readDir dir of
|
||||
SOME path =>
|
||||
if OS.FileSys.isDir path then
|
||||
getDirList (dir, AppType.FOLDER path :: acc)
|
||||
getDirList (dir, AppType.IS_FOLDER path :: acc)
|
||||
else if OS.FileSys.isLink path then
|
||||
getDirList (dir, acc)
|
||||
else
|
||||
getDirList (dir, AppType.FILE path :: acc)
|
||||
getDirList (dir, AppType.IS_FILE path :: acc)
|
||||
| NONE => let val acc = List.rev acc in Vector.fromList acc end
|
||||
|
||||
fun loadFiles (path, inputMailbox) =
|
||||
@@ -185,8 +185,9 @@ struct
|
||||
val dir = OS.FileSys.openDir path
|
||||
val dirList = getDirList (dir, [])
|
||||
val _ = OS.FileSys.closeDir dir
|
||||
val inputMsg = FILE_BROWSER_AND_PATH {fileBrowser = dirList, path = path}
|
||||
in
|
||||
()
|
||||
Mailbox.send (inputMailbox, inputMsg)
|
||||
end
|
||||
|
||||
fun run (fileMailbox, inputMailbox) =
|
||||
|
||||
@@ -12,6 +12,7 @@ sig
|
||||
, dots: Real32.real vector
|
||||
}
|
||||
| CLEAR_DOTS
|
||||
| DRAW_MODAL_TEXT of Real32.real vector
|
||||
end
|
||||
|
||||
structure DrawMessage :> DRAW_MESSAGE =
|
||||
@@ -28,4 +29,5 @@ struct
|
||||
, dots: Real32.real vector
|
||||
}
|
||||
| CLEAR_DOTS
|
||||
| DRAW_MODAL_TEXT of Real32.real vector
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user