Loading glyphs
This commit is contained in:
parent
f426573f96
commit
d58c39a1ac
1 changed files with 21 additions and 10 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue