done refactoring functional core
This commit is contained in:
@@ -14,7 +14,7 @@ functional-core/triangle-stage.sml
|
|||||||
ann
|
ann
|
||||||
"allowVectorExps true"
|
"allowVectorExps true"
|
||||||
in
|
in
|
||||||
functional-core/triangle.sml
|
functional-core/triangles.sml
|
||||||
end
|
end
|
||||||
|
|
||||||
functional-core/app-init.sml
|
functional-core/app-init.sml
|
||||||
@@ -22,3 +22,4 @@ functional-core/app-with.sml
|
|||||||
|
|
||||||
message-types/input-msg.sml
|
message-types/input-msg.sml
|
||||||
message-types/draw-msg.sml
|
message-types/draw-msg.sml
|
||||||
|
functional-core/app-update.sml
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
signature APP_UPDATE =
|
signature APP_UPDATE =
|
||||||
sig
|
sig
|
||||||
val update: AppType.app_type * int * int * InputMessage.t
|
val update: AppType.app_type * Real32.real * Real32.real * InputMessage.t
|
||||||
-> AppType.app_type * int * int * DrawMessage.t
|
-> AppType.app_type * DrawMessage.t * Real32.real * Real32.real
|
||||||
end
|
end
|
||||||
|
|
||||||
structure AppUpdate :> APP_UPDATE =
|
structure AppUpdate :> APP_UPDATE =
|
||||||
@@ -12,9 +12,18 @@ struct
|
|||||||
|
|
||||||
fun mouseMoveOrRelease (model: app_type, mouseX, mouseY) =
|
fun mouseMoveOrRelease (model: app_type, mouseX, mouseY) =
|
||||||
let
|
let
|
||||||
val {xClickPoints, yClickPoints, ...} = model
|
val {xClickPoints, yClickPoints, windowWidth, windowHeight, ...} = model
|
||||||
val (drawVec, _, _) = ClickPoints.getClickPosition
|
val (drawVec, _, _) = ClickPoints.getClickPosition
|
||||||
(mouseX, mouseY, 1.0, 0.0, 0.0, model)
|
( mouseX
|
||||||
|
, mouseY
|
||||||
|
, 1.0
|
||||||
|
, 0.0
|
||||||
|
, 0.0
|
||||||
|
, xClickPoints
|
||||||
|
, yClickPoints
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
)
|
||||||
val drawVec = TriangleStage.toVector (model, drawVec)
|
val drawVec = TriangleStage.toVector (model, drawVec)
|
||||||
val drawMsg = DRAW_BUTTON drawVec
|
val drawMsg = DRAW_BUTTON drawVec
|
||||||
in
|
in
|
||||||
@@ -23,9 +32,18 @@ struct
|
|||||||
|
|
||||||
fun mouseLeftClick (model: app_type, mouseX, mouseY) =
|
fun mouseLeftClick (model: app_type, mouseX, mouseY) =
|
||||||
let
|
let
|
||||||
val {xClickPoints, yClickPoints, ...} = model
|
val {xClickPoints, yClickPoints, windowWidth, windowHeight, ...} = model
|
||||||
val (buttonVec, hpos, vpos) = ClickPoints.getClickPosition
|
val (buttonVec, hpos, vpos) = ClickPoints.getClickPosition
|
||||||
(mouseX, mouseY, 0.0, 0.0, 1.0, model)
|
( mouseX
|
||||||
|
, mouseY
|
||||||
|
, 0.0
|
||||||
|
, 0.0
|
||||||
|
, 1.0
|
||||||
|
, xClickPoints
|
||||||
|
, yClickPoints
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
)
|
||||||
in
|
in
|
||||||
if Vector.length buttonVec > 0 then
|
if Vector.length buttonVec > 0 then
|
||||||
case #triangleStage model of
|
case #triangleStage model of
|
||||||
@@ -35,7 +53,7 @@ struct
|
|||||||
val drawMsg = DRAW_BUTTON drawVec
|
val drawMsg = DRAW_BUTTON drawVec
|
||||||
|
|
||||||
val newTriangleStage = FIRST {x1 = hpos, y1 = vpos}
|
val newTriangleStage = FIRST {x1 = hpos, y1 = vpos}
|
||||||
val model = AppType.withTriangleStage (model, newTriangleStage)
|
val model = AppWith.triangleStage (model, newTriangleStage)
|
||||||
in
|
in
|
||||||
(model, drawMsg, mouseX, mouseY)
|
(model, drawMsg, mouseX, mouseY)
|
||||||
end
|
end
|
||||||
@@ -47,16 +65,16 @@ struct
|
|||||||
|
|
||||||
val newTriangleStage = SECOND
|
val newTriangleStage = SECOND
|
||||||
{x1 = x1, y1 = y1, x2 = hpos, y2 = vpos}
|
{x1 = x1, y1 = y1, x2 = hpos, y2 = vpos}
|
||||||
val model = AppType.withTriangleStage (model, newTriangleStage)
|
val model = AppWith.triangleStage (model, newTriangleStage)
|
||||||
in
|
in
|
||||||
(model, drawMsg, mouseX, mouseY)
|
(model, drawMsg, mouseX, mouseY)
|
||||||
end
|
end
|
||||||
| SECOND {x1, y1, x2, y2} =>
|
| SECOND {x1, y1, x2, y2} =>
|
||||||
let
|
let
|
||||||
val model = AppType.addTriangleAndResetStage
|
val model = AppWith.newTriangle
|
||||||
(model, x1, y1, x2, y2, hpos, vpos)
|
(model, x1, y1, x2, y2, hpos, vpos)
|
||||||
|
|
||||||
val drawVec = getTrianglesVector model
|
val drawVec = Triangles.toVector model
|
||||||
val drawMsg = DRAW_TRIANGLES_AND_RESET_BUTTONS drawVec
|
val drawMsg = DRAW_TRIANGLES_AND_RESET_BUTTONS drawVec
|
||||||
in
|
in
|
||||||
(model, drawMsg, mouseX, mouseY)
|
(model, drawMsg, mouseX, mouseY)
|
||||||
@@ -67,8 +85,8 @@ struct
|
|||||||
|
|
||||||
fun resizeWindow (model, mouseX, mouseY, width, height) =
|
fun resizeWindow (model, mouseX, mouseY, width, height) =
|
||||||
let
|
let
|
||||||
val model = AppType.withWindowResize (model, width, height)
|
val model = AppWith.windowResize (model, width, height)
|
||||||
val triangles = getTrianglesVector model
|
val triangles = Triangles.toVector model
|
||||||
val graphLines = #graphLines model
|
val graphLines = #graphLines model
|
||||||
val drawMsg =
|
val drawMsg =
|
||||||
RESIZE_TRIANGLES_BUTTONS_AND_GRAPH
|
RESIZE_TRIANGLES_BUTTONS_AND_GRAPH
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
structure Triangle =
|
structure Triangles =
|
||||||
struct
|
struct
|
||||||
open AppType
|
open AppType
|
||||||
|
|
||||||
Reference in New Issue
Block a user