a little clean up (make the ClickPoints.getClickPosition easier for callers to use, because fewer arguments need to be passed)
This commit is contained in:
@@ -12,27 +12,7 @@ struct
|
|||||||
|
|
||||||
fun mouseMoveOrRelease (model: app_type) =
|
fun mouseMoveOrRelease (model: app_type) =
|
||||||
let
|
let
|
||||||
val
|
val (drawVec, _, _) = ClickPoints.getClickPosition (1.0, 0.0, 0.0, model)
|
||||||
{ xClickPoints
|
|
||||||
, yClickPoints
|
|
||||||
, windowWidth
|
|
||||||
, windowHeight
|
|
||||||
, mouseX
|
|
||||||
, mouseY
|
|
||||||
, ...
|
|
||||||
} = model
|
|
||||||
|
|
||||||
val (drawVec, _, _) = ClickPoints.getClickPosition
|
|
||||||
( 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
|
||||||
@@ -41,27 +21,8 @@ struct
|
|||||||
|
|
||||||
fun mouseLeftClick (model: app_type) =
|
fun mouseLeftClick (model: app_type) =
|
||||||
let
|
let
|
||||||
val
|
val (buttonVec, hpos, vpos) =
|
||||||
{ xClickPoints
|
ClickPoints.getClickPosition (0.0, 0.0, 1.0, model)
|
||||||
, yClickPoints
|
|
||||||
, windowWidth
|
|
||||||
, windowHeight
|
|
||||||
, mouseX
|
|
||||||
, mouseY
|
|
||||||
, ...
|
|
||||||
} = model
|
|
||||||
|
|
||||||
val (buttonVec, hpos, vpos) = ClickPoints.getClickPosition
|
|
||||||
( mouseX
|
|
||||||
, mouseY
|
|
||||||
, 0.0
|
|
||||||
, 0.0
|
|
||||||
, 1.0
|
|
||||||
, xClickPoints
|
|
||||||
, yClickPoints
|
|
||||||
, windowWidth
|
|
||||||
, windowHeight
|
|
||||||
)
|
|
||||||
val newUndoTuple = (hpos, vpos)
|
val newUndoTuple = (hpos, vpos)
|
||||||
in
|
in
|
||||||
if Vector.length buttonVec > 0 then
|
if Vector.length buttonVec > 0 then
|
||||||
@@ -151,7 +112,7 @@ struct
|
|||||||
AppWith.undo (model, triangleStage, trianglesTl, (x3, y3))
|
AppWith.undo (model, triangleStage, trianglesTl, (x3, y3))
|
||||||
|
|
||||||
val newTriangleVec = Triangles.toVector model
|
val newTriangleVec = Triangles.toVector model
|
||||||
val emptyVec : Real32.real vector = Vector.fromList []
|
val emptyVec: Real32.real vector = Vector.fromList []
|
||||||
val drawVec = TriangleStage.secondToVector
|
val drawVec = TriangleStage.secondToVector
|
||||||
(x1, y1, x2, y2, emptyVec, model)
|
(x1, y1, x2, y2, emptyVec, model)
|
||||||
val drawMsg =
|
val drawMsg =
|
||||||
@@ -178,8 +139,7 @@ struct
|
|||||||
(model, newTriangleStage, #triangles model, redoHd)
|
(model, newTriangleStage, #triangles model, redoHd)
|
||||||
|
|
||||||
val emptyVec: Real32.real vector = Vector.fromList []
|
val emptyVec: Real32.real vector = Vector.fromList []
|
||||||
val drawVec =
|
val drawVec = TriangleStage.firstToVector (x, y, emptyVec, model)
|
||||||
TriangleStage.firstToVector (x, y, emptyVec, model)
|
|
||||||
val drawMsg = DRAW_BUTTON drawVec
|
val drawMsg = DRAW_BUTTON drawVec
|
||||||
in
|
in
|
||||||
(model, drawMsg)
|
(model, drawMsg)
|
||||||
@@ -214,9 +174,7 @@ struct
|
|||||||
in
|
in
|
||||||
(model, drawMsg)
|
(model, drawMsg)
|
||||||
end)
|
end)
|
||||||
| [] =>
|
| [] => (* Nothing to redo. *) (model, NO_DRAW)
|
||||||
(* Nothing to redo. *)
|
|
||||||
(model, NO_DRAW)
|
|
||||||
|
|
||||||
fun update (model: app_type, inputMsg) =
|
fun update (model: app_type, inputMsg) =
|
||||||
case inputMsg of
|
case inputMsg of
|
||||||
|
|||||||
@@ -2,15 +2,7 @@ signature CLICK_POINTS =
|
|||||||
sig
|
sig
|
||||||
val generate: int * int -> Real32.real vector
|
val generate: int * int -> Real32.real vector
|
||||||
val getClickPosition:
|
val getClickPosition:
|
||||||
Real32.real
|
Real32.real * Real32.real * Real32.real * AppType.app_type
|
||||||
* Real32.real
|
|
||||||
* Real32.real
|
|
||||||
* Real32.real
|
|
||||||
* Real32.real
|
|
||||||
* Real32.real vector
|
|
||||||
* Real32.real vector
|
|
||||||
* int
|
|
||||||
* int
|
|
||||||
-> Real32.real vector * Real32.real * Real32.real
|
-> Real32.real vector * Real32.real * Real32.real
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -192,27 +184,29 @@ struct
|
|||||||
* If a square wasn't found at the clicked position,
|
* If a square wasn't found at the clicked position,
|
||||||
* an empty vector is returned.
|
* an empty vector is returned.
|
||||||
*)
|
*)
|
||||||
fun getClickPosition
|
fun getClickPosition (r, g, b, app: AppType.app_type) =
|
||||||
( mouseX
|
let
|
||||||
, mouseY
|
val
|
||||||
, r
|
{ xClickPoints
|
||||||
, g
|
, yClickPoints
|
||||||
, b
|
, mouseX
|
||||||
, xClickPoints
|
, mouseY
|
||||||
, yClickPoints
|
, windowWidth
|
||||||
, windowWidth
|
, windowHeight
|
||||||
, windowHeight
|
, ...
|
||||||
) =
|
} = app
|
||||||
getHorizontalClickPos
|
in
|
||||||
( xClickPoints
|
getHorizontalClickPos
|
||||||
, yClickPoints
|
( xClickPoints
|
||||||
, 0
|
, yClickPoints
|
||||||
, mouseX
|
, 0
|
||||||
, mouseY
|
, mouseX
|
||||||
, r
|
, mouseY
|
||||||
, g
|
, r
|
||||||
, b
|
, g
|
||||||
, windowWidth
|
, b
|
||||||
, windowHeight
|
, windowWidth
|
||||||
)
|
, windowHeight
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user