Loading glyphs

master
Dustin Swan 5 days ago
parent f426573f96
commit d58c39a1ac
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -35,20 +35,31 @@ pixelEditor = config \
newState = state.{ map = newMap };
{ state = newState, emit = saveGlyph newState });
existing = eval! (c.path);
size \ ui.stateful {
focusable = True,
autoFocus = True,
key = "pixelEditor-" & config.path,
key = "pixelEditor-" & c.path,
init = {
map = [], # loadMap from store
pixelWidth = 5,
pixelHeight = 7,
cellSize = 30,
selectedRow = 0,
selectedCol = 0
},
init = existing
| Value v \ {
map = v.map,
pixelWidth = 5,
pixelHeight = 7,
cellSize = 30,
selectedRow = 0,
selectedCol = 0
}
| _ \ {
map = [],
pixelWidth = 5,
pixelHeight = 7,
cellSize = 30,
selectedRow = 0,
selectedCol = 0
},
update = state event \ event
| ClickCell { x = x, y = y } \ toggleFocused state.{ selectedRow = y, selectedCol = x }
@ -87,7 +98,7 @@ pixelEditor = config \
strokeColor = (selected | True \ "#f00" | False \ "rgba(0,0,0,0.2)");
ui.clickable {
onClick = \ _ = debug! "here" [rIdx, cIdx]; emit (ClickCell { x = cIdx, y = rIdx }),
onClick = \ emit (ClickCell { x = cIdx, y = rIdx }),
child = ui.rect { w = state.cellSize, h = state.cellSize, color = color, strokeWidth = 1, strokeColor = strokeColor }
}
) (range 0 state.pixelWidth)

Loading…
Cancel
Save