begin drawing file browser text
This commit is contained in:
@@ -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} =>
|
||||
|
||||
Reference in New Issue
Block a user