adjust app type by adding arrowX and arrowY integer fields, and subsequent refactoring, as preparation for being able to draw with arrow keys
This commit is contained in:
@@ -24,6 +24,8 @@ struct
|
|||||||
, mouseX = 0.0
|
, mouseX = 0.0
|
||||||
, mouseY = 0.0
|
, mouseY = 0.0
|
||||||
, showGraph = true
|
, showGraph = true
|
||||||
|
, arrowX = 0
|
||||||
|
, arrowY = 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ sig
|
|||||||
, y3: Real32.real
|
, y3: Real32.real
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type app_type =
|
type app_type =
|
||||||
{ triangles: triangle list
|
{ triangles: triangle list
|
||||||
, triangleStage: triangle_stage
|
, triangleStage: triangle_stage
|
||||||
@@ -24,9 +25,11 @@ sig
|
|||||||
, yClickPoints: Real32.real vector
|
, yClickPoints: Real32.real vector
|
||||||
, undo: (Real32.real * Real32.real) list
|
, undo: (Real32.real * Real32.real) list
|
||||||
, redo: (Real32.real * Real32.real) list
|
, redo: (Real32.real * Real32.real) list
|
||||||
|
, showGraph: bool
|
||||||
, mouseX: Real32.real
|
, mouseX: Real32.real
|
||||||
, mouseY: Real32.real
|
, mouseY: Real32.real
|
||||||
, showGraph: bool
|
, arrowX: int
|
||||||
|
, arrowY: int
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,8 +67,10 @@ struct
|
|||||||
, yClickPoints: Real32.real vector
|
, yClickPoints: Real32.real vector
|
||||||
, undo: (Real32.real * Real32.real) list
|
, undo: (Real32.real * Real32.real) list
|
||||||
, redo: (Real32.real * Real32.real) list
|
, redo: (Real32.real * Real32.real) list
|
||||||
|
, showGraph: bool
|
||||||
, mouseX: Real32.real
|
, mouseX: Real32.real
|
||||||
, mouseY: Real32.real
|
, mouseY: Real32.real
|
||||||
, showGraph: bool
|
, arrowX: int
|
||||||
|
, arrowY: int
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ struct
|
|||||||
val drawMsg = DRAW_DOT drawVec
|
val drawMsg = DRAW_DOT drawVec
|
||||||
|
|
||||||
val newTriangleStage = FIRST {x1 = hpos, y1 = vpos}
|
val newTriangleStage = FIRST {x1 = hpos, y1 = vpos}
|
||||||
val model =
|
val model = AppWith.addTriangleStage
|
||||||
AppWith.addTriangleStage
|
(model, newTriangleStage, newUndoTuple, hIdx, vIdx)
|
||||||
(model, newTriangleStage, newUndoTuple)
|
|
||||||
in
|
in
|
||||||
(model, DRAW drawMsg)
|
(model, DRAW drawMsg)
|
||||||
end
|
end
|
||||||
@@ -73,16 +72,15 @@ 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 =
|
val model = AppWith.addTriangleStage
|
||||||
AppWith.addTriangleStage
|
(model, newTriangleStage, newUndoTuple, hIdx, vIdx)
|
||||||
(model, newTriangleStage, newUndoTuple)
|
|
||||||
in
|
in
|
||||||
(model, DRAW drawMsg)
|
(model, DRAW drawMsg)
|
||||||
end
|
end
|
||||||
| SECOND {x1, y1, x2, y2} =>
|
| SECOND {x1, y1, x2, y2} =>
|
||||||
let
|
let
|
||||||
val model = AppWith.addTriangle
|
val model = AppWith.addTriangle
|
||||||
(model, x1, y1, x2, y2, hpos, vpos, newUndoTuple)
|
(model, x1, y1, x2, y2, hpos, vpos, newUndoTuple, hIdx, vIdx)
|
||||||
val drawVec = Triangles.toVector model
|
val drawVec = Triangles.toVector model
|
||||||
val drawMsg = DRAW_TRIANGLES_AND_RESET_DOTS drawVec
|
val drawMsg = DRAW_TRIANGLES_AND_RESET_DOTS drawVec
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ sig
|
|||||||
* and also add new click position to undo stack.
|
* and also add new click position to undo stack.
|
||||||
*)
|
*)
|
||||||
val addTriangleStage:
|
val addTriangleStage:
|
||||||
AppType.app_type * AppType.triangle_stage * (Real32.real * Real32.real)
|
AppType.app_type
|
||||||
|
* AppType.triangle_stage
|
||||||
|
* (Real32.real * Real32.real)
|
||||||
|
* int
|
||||||
|
* int
|
||||||
-> AppType.app_type
|
-> AppType.app_type
|
||||||
|
|
||||||
val addTriangle:
|
val addTriangle:
|
||||||
@@ -39,6 +43,8 @@ sig
|
|||||||
* Real32.real
|
* Real32.real
|
||||||
* Real32.real
|
* Real32.real
|
||||||
* (Real32.real * Real32.real)
|
* (Real32.real * Real32.real)
|
||||||
|
* int
|
||||||
|
* int
|
||||||
-> AppType.app_type
|
-> AppType.app_type
|
||||||
|
|
||||||
val useTriangles: AppType.app_type * AppType.triangle list -> AppType.app_type
|
val useTriangles: AppType.app_type * AppType.triangle list -> AppType.app_type
|
||||||
@@ -50,7 +56,8 @@ struct
|
|||||||
|
|
||||||
(* add to undo, clear redo *)
|
(* add to undo, clear redo *)
|
||||||
fun addTriangleStage
|
fun addTriangleStage
|
||||||
(app: app_type, newTriangleStage: triangle_stage, newUndoHd) : app_type =
|
(app: app_type, newTriangleStage: triangle_stage, newUndoHd, arrowX, arrowY) :
|
||||||
|
app_type =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
{ triangleStage = _
|
{ triangleStage = _
|
||||||
@@ -61,9 +68,11 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo = _
|
, redo = _
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX = _
|
||||||
|
, arrowY = _
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo = newUndoHd :: undo
|
val newUndo = newUndoHd :: undo
|
||||||
@@ -76,13 +85,17 @@ struct
|
|||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
|
, showGraph = showGraph
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, showGraph = showGraph
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fun addTriangle (app: app_type, x1, y1, x2, y2, x3, y3, newUndoHd) : app_type =
|
fun addTriangle
|
||||||
|
(app: app_type, x1, y1, x2, y2, x3, y3, newUndoHd, arrowX, arrowY) :
|
||||||
|
app_type =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
{ triangles
|
{ triangles
|
||||||
@@ -93,9 +106,11 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo = _
|
, redo = _
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX = _
|
||||||
|
, arrowY = _
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newTriangle = {x1 = x1, y1 = y1, x2 = x2, y2 = y2, x3 = x3, y3 = y3}
|
val newTriangle = {x1 = x1, y1 = y1, x2 = x2, y2 = y2, x3 = x3, y3 = y3}
|
||||||
@@ -110,9 +125,11 @@ struct
|
|||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
|
, showGraph = showGraph
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, showGraph = showGraph
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -129,9 +146,11 @@ struct
|
|||||||
, triangleStage
|
, triangleStage
|
||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX
|
||||||
|
, arrowY
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
||||||
@@ -145,9 +164,11 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, undo = undo
|
, undo = undo
|
||||||
, redo = redo
|
, redo = redo
|
||||||
|
, showGraph = showGraph
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, showGraph = showGraph
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -188,6 +209,8 @@ struct
|
|||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
, showGraph
|
, showGraph
|
||||||
|
, arrowX
|
||||||
|
, arrowY
|
||||||
} = app
|
} = app
|
||||||
in
|
in
|
||||||
{ mouseX = mouseX
|
{ mouseX = mouseX
|
||||||
@@ -201,6 +224,8 @@ struct
|
|||||||
, undo = undo
|
, undo = undo
|
||||||
, redo = redo
|
, redo = redo
|
||||||
, showGraph = showGraph
|
, showGraph = showGraph
|
||||||
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -216,9 +241,11 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX
|
||||||
|
, arrowY
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo =
|
val newUndo =
|
||||||
@@ -236,9 +263,11 @@ struct
|
|||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
|
, showGraph = showGraph
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, showGraph = showGraph
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -254,9 +283,11 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX
|
||||||
|
, arrowY
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo = newUndoHd :: undo
|
val newUndo = newUndoHd :: undo
|
||||||
@@ -273,9 +304,11 @@ struct
|
|||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
|
, showGraph = showGraph
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, showGraph = showGraph
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -292,6 +325,8 @@ struct
|
|||||||
, redo
|
, redo
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, arrowX
|
||||||
|
, arrowY
|
||||||
, showGraph = _
|
, showGraph = _
|
||||||
} = app
|
} = app
|
||||||
in
|
in
|
||||||
@@ -306,6 +341,8 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -318,9 +355,11 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
|
, showGraph
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
, showGraph
|
, arrowX
|
||||||
|
, arrowY
|
||||||
, triangles = _
|
, triangles = _
|
||||||
, triangleStage = _
|
, triangleStage = _
|
||||||
} = app
|
} = app
|
||||||
@@ -338,6 +377,8 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, arrowX = arrowX
|
||||||
|
, arrowY = arrowY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user