fix bugs moving image up/down in move mode
This commit is contained in:
@@ -5,7 +5,7 @@ struct
|
|||||||
open DrawMessage
|
open DrawMessage
|
||||||
open UpdateMessage
|
open UpdateMessage
|
||||||
|
|
||||||
(* todo: resize message, escape button to go back to normal mode *)
|
(* todo: resize message *)
|
||||||
|
|
||||||
fun getDrawMsg (model: app_type) =
|
fun getDrawMsg (model: app_type) =
|
||||||
let
|
let
|
||||||
@@ -37,8 +37,13 @@ struct
|
|||||||
(model, [DRAW drawMsg])
|
(model, [DRAW drawMsg])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
val blankPixel = {r = 0, g = 0, b = 0, a = 0}
|
||||||
|
|
||||||
fun makeBlankYAxis length =
|
fun makeBlankYAxis length =
|
||||||
Vector.tabulate (length, fn _ => {r = 0, g = 0, b = 0, a = 0})
|
Vector.tabulate (length, fn _ => blankPixel)
|
||||||
|
|
||||||
|
fun makeBlankXAxis length =
|
||||||
|
Vector.tabulate (length, fn _ => makeBlankYAxis length)
|
||||||
|
|
||||||
fun moveImageUp (model: app_type) =
|
fun moveImageUp (model: app_type) =
|
||||||
let
|
let
|
||||||
@@ -46,11 +51,11 @@ struct
|
|||||||
|
|
||||||
val squares =
|
val squares =
|
||||||
Vector.mapi
|
Vector.mapi
|
||||||
(fn (idx, yAxis) =>
|
(fn (_, yAxis) =>
|
||||||
if idx + 1 < Vector.length squares then
|
Vector.mapi
|
||||||
Vector.sub (squares, idx + 1)
|
(fn (yIdx, pixel) =>
|
||||||
else
|
if yIdx = Vector.length yAxis - 1 then blankPixel
|
||||||
makeBlankYAxis (Vector.length yAxis)) squares
|
else Vector.sub (yAxis, yIdx + 1)) yAxis) squares
|
||||||
|
|
||||||
val model = AppWith.squares (model, squares)
|
val model = AppWith.squares (model, squares)
|
||||||
in
|
in
|
||||||
@@ -63,9 +68,11 @@ struct
|
|||||||
|
|
||||||
val squares =
|
val squares =
|
||||||
Vector.mapi
|
Vector.mapi
|
||||||
(fn (idx, yAxis) =>
|
(fn (_, yAxis) =>
|
||||||
if idx = 0 then makeBlankYAxis (Vector.length yAxis)
|
Vector.mapi
|
||||||
else Vector.sub (squares, idx - 1)) squares
|
(fn (yIdx, pixel) =>
|
||||||
|
if yIdx = 0 then blankPixel else Vector.sub (yAxis, yIdx - 1))
|
||||||
|
yAxis) squares
|
||||||
|
|
||||||
val model = AppWith.squares (model, squares)
|
val model = AppWith.squares (model, squares)
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user