progress towards toggling graph
This commit is contained in:
@@ -4,8 +4,10 @@
|
|||||||
int PRESS = GLFW_PRESS;
|
int PRESS = GLFW_PRESS;
|
||||||
int RELEASE = GLFW_RELEASE;
|
int RELEASE = GLFW_RELEASE;
|
||||||
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
|
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
|
||||||
int KEY_Z = GLFW_KEY_Z;
|
|
||||||
|
int KEY_G = GLFW_KEY_G;
|
||||||
int KEY_Y = GLFW_KEY_Y;
|
int KEY_Y = GLFW_KEY_Y;
|
||||||
|
int KEY_Z = GLFW_KEY_Z;
|
||||||
|
|
||||||
// Calls function exported from SML
|
// Calls function exported from SML
|
||||||
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
|
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ struct
|
|||||||
_export "mltonKeyCallback" public : (int * int * int * int -> unit) -> unit;
|
_export "mltonKeyCallback" public : (int * int * int * int -> unit) -> unit;
|
||||||
val setKeyCallback = _import "setKeyCallback" public reentrant : window -> unit;
|
val setKeyCallback = _import "setKeyCallback" public reentrant : window -> unit;
|
||||||
|
|
||||||
val (KEY_Z, _) =
|
val (KEY_G, _) =
|
||||||
_symbol "KEY_Z" public : ( unit -> int ) * ( int -> unit );
|
_symbol "KEY_G" public : ( unit -> int ) * ( int -> unit );
|
||||||
val (KEY_Y, _) =
|
val (KEY_Y, _) =
|
||||||
_symbol "KEY_Y" public : ( unit -> int ) * ( int -> unit );
|
_symbol "KEY_Y" public : ( unit -> int ) * ( int -> unit );
|
||||||
|
val (KEY_Z, _) =
|
||||||
|
_symbol "KEY_Z" public : ( unit -> int ) * ( int -> unit );
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ struct
|
|||||||
, redo = []
|
, redo = []
|
||||||
, mouseX = 0.0
|
, mouseX = 0.0
|
||||||
, mouseY = 0.0
|
, mouseY = 0.0
|
||||||
|
, showGraph = true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ sig
|
|||||||
, redo: (Real32.real * Real32.real) list
|
, redo: (Real32.real * Real32.real) list
|
||||||
, mouseX: Real32.real
|
, mouseX: Real32.real
|
||||||
, mouseY: Real32.real
|
, mouseY: Real32.real
|
||||||
|
, showGraph: bool
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,5 +66,6 @@ struct
|
|||||||
, redo: (Real32.real * Real32.real) list
|
, redo: (Real32.real * Real32.real) list
|
||||||
, mouseX: Real32.real
|
, mouseX: Real32.real
|
||||||
, mouseY: Real32.real
|
, mouseY: Real32.real
|
||||||
|
, showGraph: bool
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -174,7 +174,26 @@ struct
|
|||||||
in
|
in
|
||||||
(model, drawMsg)
|
(model, drawMsg)
|
||||||
end)
|
end)
|
||||||
| [] => (* Nothing to redo. *) (model, NO_DRAW)
|
| [] =>
|
||||||
|
(* Nothing to redo. *)
|
||||||
|
(model, NO_DRAW)
|
||||||
|
|
||||||
|
fun toggleGraph (model: app_type) =
|
||||||
|
if #showGraph model then
|
||||||
|
let
|
||||||
|
val model = AppWith.graphVisibility (model, false)
|
||||||
|
val drawMsg = DRAW_GRAPH (Vector.fromList [])
|
||||||
|
in
|
||||||
|
(model, drawMsg)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val model = AppWith.graphVisibility (model, true)
|
||||||
|
val graphLines = GraphLines.generate model
|
||||||
|
val drawMsg = DRAW_GRAPH graphLines
|
||||||
|
in
|
||||||
|
(model, drawMsg)
|
||||||
|
end
|
||||||
|
|
||||||
fun update (model: app_type, inputMsg) =
|
fun update (model: app_type, inputMsg) =
|
||||||
case inputMsg of
|
case inputMsg of
|
||||||
@@ -187,4 +206,5 @@ struct
|
|||||||
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||||
| UNDO_ACTION => undoAction model
|
| UNDO_ACTION => undoAction model
|
||||||
| REDO_ACTION => redoAction model
|
| REDO_ACTION => redoAction model
|
||||||
|
| KEY_G => toggleGraph model
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
signature APP_WITH =
|
signature APP_WITH =
|
||||||
sig
|
sig
|
||||||
|
val graphVisibility: AppType.app_type * bool -> AppType.app_type
|
||||||
|
|
||||||
val windowResize: AppType.app_type * int * int -> AppType.app_type
|
val windowResize: AppType.app_type * int * int -> AppType.app_type
|
||||||
|
|
||||||
val mousePosition: AppType.app_type * Real32.real * Real32.real
|
val mousePosition: AppType.app_type * Real32.real * Real32.real
|
||||||
@@ -59,6 +61,7 @@ struct
|
|||||||
, redo = _
|
, redo = _
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, showGraph
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo = newUndoHd :: undo
|
val newUndo = newUndoHd :: undo
|
||||||
@@ -73,6 +76,7 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, showGraph = showGraph
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -89,6 +93,7 @@ struct
|
|||||||
, redo = _
|
, redo = _
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, showGraph
|
||||||
} = 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}
|
||||||
@@ -105,6 +110,7 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, showGraph = showGraph
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -123,6 +129,7 @@ struct
|
|||||||
, redo
|
, redo
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, showGraph
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
||||||
@@ -138,6 +145,7 @@ struct
|
|||||||
, redo = redo
|
, redo = redo
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, showGraph = showGraph
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -177,6 +185,7 @@ struct
|
|||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
, redo
|
, redo
|
||||||
|
, showGraph
|
||||||
} = app
|
} = app
|
||||||
in
|
in
|
||||||
{ mouseX = mouseX
|
{ mouseX = mouseX
|
||||||
@@ -189,6 +198,7 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, undo = undo
|
, undo = undo
|
||||||
, redo = redo
|
, redo = redo
|
||||||
|
, showGraph = showGraph
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -206,6 +216,7 @@ struct
|
|||||||
, redo
|
, redo
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, showGraph
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo =
|
val newUndo =
|
||||||
@@ -225,6 +236,7 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, showGraph = showGraph
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -242,6 +254,7 @@ struct
|
|||||||
, redo
|
, redo
|
||||||
, mouseX
|
, mouseX
|
||||||
, mouseY
|
, mouseY
|
||||||
|
, showGraph
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val newUndo = newUndoHd :: undo
|
val newUndo = newUndoHd :: undo
|
||||||
@@ -260,6 +273,37 @@ struct
|
|||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
|
, showGraph = showGraph
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
fun graphVisibility (app: app_type, shouldShowGraph) =
|
||||||
|
let
|
||||||
|
val
|
||||||
|
{ triangleStage
|
||||||
|
, triangles
|
||||||
|
, xClickPoints
|
||||||
|
, yClickPoints
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, undo
|
||||||
|
, redo
|
||||||
|
, mouseX
|
||||||
|
, mouseY
|
||||||
|
, showGraph = _
|
||||||
|
} = app
|
||||||
|
in
|
||||||
|
{ showGraph = shouldShowGraph
|
||||||
|
, triangleStage = triangleStage
|
||||||
|
, triangles = triangles
|
||||||
|
, undo = undo
|
||||||
|
, redo = redo
|
||||||
|
, xClickPoints = xClickPoints
|
||||||
|
, yClickPoints = yClickPoints
|
||||||
|
, windowWidth = windowWidth
|
||||||
|
, windowHeight = windowHeight
|
||||||
|
, mouseX = mouseX
|
||||||
|
, mouseY = mouseY
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ struct
|
|||||||
then
|
then
|
||||||
(* ctrl-y *)
|
(* ctrl-y *)
|
||||||
Mailbox.send (mailbox, REDO_ACTION)
|
Mailbox.send (mailbox, REDO_ACTION)
|
||||||
|
else if
|
||||||
|
key = Input.KEY_G () andalso action <> Input.RELEASE () andalso mods = 0x0
|
||||||
|
then
|
||||||
|
Mailbox.send (mailbox, KEY_G)
|
||||||
else
|
else
|
||||||
()
|
()
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ sig
|
|||||||
| DRAW_TRIANGLES_AND_BUTTONS of
|
| DRAW_TRIANGLES_AND_BUTTONS of
|
||||||
{triangles: Real32.real vector, buttons: Real32.real vector}
|
{triangles: Real32.real vector, buttons: Real32.real vector}
|
||||||
| DRAW_TRIANGLES_AND_RESET_BUTTONS of Real32.real vector
|
| DRAW_TRIANGLES_AND_RESET_BUTTONS of Real32.real vector
|
||||||
|
| DRAW_GRAPH of Real32.real vector
|
||||||
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH of
|
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH of
|
||||||
{triangles: Real32.real vector, graphLines: Real32.real vector}
|
{triangles: Real32.real vector, graphLines: Real32.real vector}
|
||||||
| CLEAR_BUTTONS
|
| CLEAR_BUTTONS
|
||||||
@@ -18,6 +19,7 @@ struct
|
|||||||
| DRAW_TRIANGLES_AND_BUTTONS of
|
| DRAW_TRIANGLES_AND_BUTTONS of
|
||||||
{triangles: Real32.real vector, buttons: Real32.real vector}
|
{triangles: Real32.real vector, buttons: Real32.real vector}
|
||||||
| DRAW_TRIANGLES_AND_RESET_BUTTONS of Real32.real vector
|
| DRAW_TRIANGLES_AND_RESET_BUTTONS of Real32.real vector
|
||||||
|
| DRAW_GRAPH of Real32.real vector
|
||||||
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH of
|
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH of
|
||||||
{triangles: Real32.real vector, graphLines: Real32.real vector}
|
{triangles: Real32.real vector, graphLines: Real32.real vector}
|
||||||
| CLEAR_BUTTONS
|
| CLEAR_BUTTONS
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ sig
|
|||||||
| RESIZE_WINDOW of {width: int, height: int}
|
| RESIZE_WINDOW of {width: int, height: int}
|
||||||
| UNDO_ACTION
|
| UNDO_ACTION
|
||||||
| REDO_ACTION
|
| REDO_ACTION
|
||||||
|
| KEY_G
|
||||||
end
|
end
|
||||||
|
|
||||||
structure InputMessage :> INPUT_MESSAGE =
|
structure InputMessage :> INPUT_MESSAGE =
|
||||||
@@ -18,4 +19,5 @@ struct
|
|||||||
| RESIZE_WINDOW of {width: int, height: int}
|
| RESIZE_WINDOW of {width: int, height: int}
|
||||||
| UNDO_ACTION
|
| UNDO_ACTION
|
||||||
| REDO_ACTION
|
| REDO_ACTION
|
||||||
|
| KEY_G
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user