done adding ability to change different colours in both functional core and imperative shell
This commit is contained in:
@@ -27,6 +27,17 @@ int KEY_LEFT = GLFW_KEY_LEFT;
|
||||
int KEY_RIGHT = GLFW_KEY_RIGHT;
|
||||
int KEY_DOWN = GLFW_KEY_DOWN;
|
||||
|
||||
int KEY_0 = GLFW_KEY_0;
|
||||
int KEY_1 = GLFW_KEY_1;
|
||||
int KEY_2 = GLFW_KEY_2;
|
||||
int KEY_3 = GLFW_KEY_3;
|
||||
int KEY_4 = GLFW_KEY_4;
|
||||
int KEY_5 = GLFW_KEY_5;
|
||||
int KEY_6 = GLFW_KEY_6;
|
||||
int KEY_7 = GLFW_KEY_7;
|
||||
int KEY_8 = GLFW_KEY_8;
|
||||
int KEY_9 = GLFW_KEY_9;
|
||||
|
||||
// Calls function exported from SML
|
||||
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
|
||||
mltonMouseMoveCallback((float)xpos, (float)ypos);
|
||||
|
||||
@@ -68,4 +68,25 @@ struct
|
||||
_symbol "KEY_RIGHT" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_DOWN, _) =
|
||||
_symbol "KEY_DOWN" public : ( unit -> int ) * ( int -> unit );
|
||||
|
||||
val (KEY_0, _) =
|
||||
_symbol "KEY_0" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_1, _) =
|
||||
_symbol "KEY_1" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_2, _) =
|
||||
_symbol "KEY_2" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_3, _) =
|
||||
_symbol "KEY_3" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_4, _) =
|
||||
_symbol "KEY_4" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_5, _) =
|
||||
_symbol "KEY_5" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_6, _) =
|
||||
_symbol "KEY_6" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_7, _) =
|
||||
_symbol "KEY_7" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_8, _) =
|
||||
_symbol "KEY_8" public : ( unit -> int ) * ( int -> unit );
|
||||
val (KEY_9, _) =
|
||||
_symbol "KEY_9" public : ( unit -> int ) * ( int -> unit );
|
||||
end
|
||||
|
||||
@@ -353,6 +353,19 @@ struct
|
||||
(model, drawMsg)
|
||||
end
|
||||
|
||||
fun updateNum (model: app_type, inputNum) =
|
||||
let
|
||||
val oldNum = #num model
|
||||
val newNum = oldNum * 10 + inputNum
|
||||
val newNum = if newNum > 255 then 0 else newNum
|
||||
in
|
||||
(AppWith.num (model, newNum), [])
|
||||
end
|
||||
|
||||
fun updateRed model = (AppWith.r model, [])
|
||||
fun updateGreen model = (AppWith.g model, [])
|
||||
fun updateBlue model = (AppWith.b model, [])
|
||||
|
||||
fun getSaveTrianglesMsg model =
|
||||
let
|
||||
val {triangles, ...} = model
|
||||
@@ -409,6 +422,10 @@ struct
|
||||
end
|
||||
| MOUSE_LEFT_RELEASE => mouseMoveOrRelease model
|
||||
| MOUSE_LEFT_CLICK => mouseLeftClick model
|
||||
| NUM num => updateNum (model, num)
|
||||
| KEY_R => updateRed model
|
||||
| KEY_G => updateGreen model
|
||||
| KEY_B => updateBlue model
|
||||
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
|
||||
| UNDO_ACTION => undoAction model
|
||||
| REDO_ACTION => redoAction model
|
||||
|
||||
@@ -102,6 +102,46 @@ struct
|
||||
key = Input.KEY_O () andalso action = Input.PRESS () andalso mods = 0x02
|
||||
then
|
||||
Mailbox.send (mailbox, KEY_CTRL_O)
|
||||
else if
|
||||
key = Input.KEY_0 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 0)
|
||||
else if
|
||||
key = Input.KEY_1 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 1)
|
||||
else if
|
||||
key = Input.KEY_2 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 2)
|
||||
else if
|
||||
key = Input.KEY_3 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 3)
|
||||
else if
|
||||
key = Input.KEY_4 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 4)
|
||||
else if
|
||||
key = Input.KEY_5 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 5)
|
||||
else if
|
||||
key = Input.KEY_6 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 6)
|
||||
else if
|
||||
key = Input.KEY_7 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 7)
|
||||
else if
|
||||
key = Input.KEY_8 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 8)
|
||||
else if
|
||||
key = Input.KEY_9 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
Mailbox.send (mailbox, NUM 9)
|
||||
else
|
||||
()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user