diff --git a/dotscape b/dotscape index c2ea798..7b0e1cf 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/grid.sml b/fcore/grid.sml index a7c016e..9673eb6 100644 --- a/fcore/grid.sml +++ b/fcore/grid.sml @@ -32,4 +32,14 @@ struct fun makeEmpty maxSide = Vector.tabulate (maxSide, fn _ => Vector.tabulate (maxSide, fn _ => emptyPixel)) + + fun flipHorizontally (xAxis: t) = + Vector.mapi + (fn (xIdx, yAxis) => + let + val flippedXIdx = Vector.length xAxis - 1 - xIdx + val flippedYAxis = Vector.sub (xAxis, flippedXIdx) + in + Vector.mapi (fn (yIdx, _) => Vector.sub (flippedYAxis, yIdx)) yAxis + end) xAxis end diff --git a/fcore/layer-tree.sml b/fcore/layer-tree.sml index a540420..8da1050 100644 --- a/fcore/layer-tree.sml +++ b/fcore/layer-tree.sml @@ -107,4 +107,6 @@ struct in insert (key, grid, tree) end + + fun flipHorizontally tree = map (Grid.flipHorizontally, tree) end diff --git a/fcore/normal-mode.sml b/fcore/normal-mode.sml index 2f7076f..3a4961b 100644 --- a/fcore/normal-mode.sml +++ b/fcore/normal-mode.sml @@ -369,6 +369,15 @@ struct in (model, []) end + fun flipHorizontally (model: app_type) = + let + val {layerTree, arrowX, arrowY, ...} = model + val layerTree = LayerTree.flipHorizontally layerTree + val model = AppWith.layerTree (model, layerTree, arrowX, arrowY) + in + getDrawMessage (model, []) + end + fun update (model: app_type, inputMsg) = case inputMsg of MOUSE_MOVE {x = mouseX, y = mouseY} => @@ -388,6 +397,7 @@ struct | KEY_W => updateCanvasWidth model | KEY_H => updateCanvasHeight model | KEY_M => enterMoveMode model + | KEY_F => flipHorizontally model | RESIZE_WINDOW {width, height} => resizeWindow (model, width, height) | UNDO_ACTION => undoAction model | REDO_ACTION => redoAction model diff --git a/ffi/glfw-input.c b/ffi/glfw-input.c index 2067117..af9de15 100644 --- a/ffi/glfw-input.c +++ b/ffi/glfw-input.c @@ -24,6 +24,7 @@ int KEY_W = GLFW_KEY_W; int KEY_H = GLFW_KEY_H; int KEY_C = GLFW_KEY_C; int KEY_M = GLFW_KEY_M; +int KEY_F = GLFW_KEY_F; int KEY_ENTER = GLFW_KEY_ENTER; int KEY_SPACE = GLFW_KEY_SPACE; diff --git a/ffi/glfw-input.sml b/ffi/glfw-input.sml index ec1ed18..0b50a4d 100644 --- a/ffi/glfw-input.sml +++ b/ffi/glfw-input.sml @@ -41,6 +41,8 @@ struct _symbol "KEY_C" public : ( unit -> int ) * ( int -> unit ); val (KEY_M, _) = _symbol "KEY_M" public : ( unit -> int ) * ( int -> unit ); + val (KEY_F, _) = + _symbol "KEY_F" public : ( unit -> int ) * ( int -> unit ); val (KEY_T, _) = _symbol "KEY_T" public : ( unit -> int ) * ( int -> unit ); diff --git a/green.dsc b/green.dsc index d71b39b..af95fba 100644 --- a/green.dsc +++ b/green.dsc @@ -1,3 +1,3 @@ -24 3 { -[ {0 1 0 1 0 0 0 1 } {1 0 22 0 0 0 0 1 } {1 1 22 1 239 239 239 1 } {1 2 22 2 0 0 0 1 } {23 1 23 1 0 0 0 1 } ] +50 50 { + [ { 1 48 1 50 0 0 0 1 } { 1 49 18 50 0 0 0 1 } { 2 47 2 47 0 0 0 1 } { 3 46 3 46 0 0 0 1 } { 4 45 5 45 0 0 0 1 } { 6 44 7 44 0 0 0 1 } { 8 43 9 43 0 0 0 1 } { 10 38 10 42 0 0 0 1 } { 10 42 11 42 0 0 0 1 } { 11 35 11 37 0 0 0 1 } { 12 33 12 34 0 0 0 1 } { 13 31 13 32 0 0 0 1 } { 14 30 14 30 0 0 0 1 } { 15 29 15 29 0 0 0 1 } { 16 28 16 28 0 0 0 1 } { 17 25 17 27 0 0 0 1 } { 17 29 17 30 0 0 0 1 } { 17 42 18 42 0 0 0 1 } { 18 24 18 24 0 0 0 1 } { 18 31 18 32 0 0 0 1 } { 18 42 18 50 0 0 0 1 } { 19 23 19 23 0 0 0 1 } { 19 33 19 33 0 0 0 1 } { 19 39 19 41 0 0 0 1 } { 20 22 20 22 0 0 0 1 } { 20 30 20 32 0 0 0 1 } { 20 34 20 38 0 0 0 1 } { 21 27 21 29 0 0 0 1 } { 22 25 22 26 0 0 0 1 } { 23 24 23 24 0 0 0 1 } ] } diff --git a/imperative-shell/input-callbacks.sml b/imperative-shell/input-callbacks.sml index a784a93..da3be72 100644 --- a/imperative-shell/input-callbacks.sml +++ b/imperative-shell/input-callbacks.sml @@ -180,6 +180,10 @@ struct key = Input.KEY_M () andalso action = Input.PRESS () andalso mods = 0 then Mailbox.send (mailbox, KEY_M) + else if + key = Input.KEY_F () andalso action = Input.PRESS () andalso mods = 0 + then + Mailbox.send (mailbox, KEY_F) else () diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index dc71809..843351e 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -17,6 +17,7 @@ struct | KEY_M | KEY_C | KEY_L + | KEY_F | KEY_BACKSPACE | KEY_CTRL_S | KEY_CTRL_L