|
|
|
@ -5,67 +5,89 @@ fontEditor = config \
|
|
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
|
|
|
|
|
|
|
_ = debug! "here" c.path;
|
|
|
|
|
|
|
|
existing = eval! (c.path);
|
|
|
|
existing = eval! (c.path);
|
|
|
|
_ = debug! "here2" existing;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# return app
|
|
|
|
# return app
|
|
|
|
{
|
|
|
|
{
|
|
|
|
view = size \ ui.stateful {
|
|
|
|
view = ctx \
|
|
|
|
focusable = True,
|
|
|
|
editGlyph = path \
|
|
|
|
autoFocus = True,
|
|
|
|
app = pixelEditor { path = path };
|
|
|
|
|
|
|
|
ctx.openApp path app.view app.width;
|
|
|
|
|
|
|
|
|
|
|
|
key = "fontEditor-" & c.path,
|
|
|
|
ui.stateful {
|
|
|
|
|
|
|
|
focusable = True,
|
|
|
|
|
|
|
|
autoFocus = True,
|
|
|
|
|
|
|
|
|
|
|
|
init = existing
|
|
|
|
key = "fontEditor-" & c.path,
|
|
|
|
| Value v \ {
|
|
|
|
|
|
|
|
glyphs = v.glyphs,
|
|
|
|
init = existing
|
|
|
|
height = v.height
|
|
|
|
| Value v \ {
|
|
|
|
}
|
|
|
|
glyphs = v.glyphs,
|
|
|
|
| _ \ {
|
|
|
|
height = v.height
|
|
|
|
glyphs = [],
|
|
|
|
}
|
|
|
|
height = 7
|
|
|
|
| _ \ {
|
|
|
|
},
|
|
|
|
glyphs = [],
|
|
|
|
|
|
|
|
height = 7
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
|
|
|
# | ClickCell { x = x, y = y } \ toggleFocused state.{ selectedRow = y, selectedCol = x }
|
|
|
|
|
|
|
|
# | Key { key = " " } \ toggleFocused state
|
|
|
|
|
|
|
|
# | Key { key = "Enter" } \ toggleFocused state
|
|
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
| Key { key = "ArrowDown" } \ downArrow state
|
|
|
|
| ClickCell { x = x, y = y } \ toggleFocused state.{ selectedRow = y, selectedCol = x }
|
|
|
|
| Key { key = "j" } \ downArrow state
|
|
|
|
| Key { key = " " } \ toggleFocused state
|
|
|
|
| Key { key = "ArrowUp" } \ upArrow state
|
|
|
|
| Key { key = "Enter" } \ toggleFocused state
|
|
|
|
| Key { key = "k" } \ upArrow state
|
|
|
|
|
|
|
|
| Key { key = "ArrowLeft" } \ leftArrow state
|
|
|
|
|
|
|
|
| Key { key = "h" } \ leftArrow state
|
|
|
|
|
|
|
|
| Key { key = "ArrowRight" } \ rightArrow state
|
|
|
|
|
|
|
|
| Key { key = "l" } \ rightArrow state
|
|
|
|
|
|
|
|
|
|
|
|
| Key { key = "ArrowDown" } \ downArrow state
|
|
|
|
| UpdateHeight h \ (
|
|
|
|
| Key { key = "j" } \ downArrow state
|
|
|
|
newState = state.{ pixelHeight = (int h) };
|
|
|
|
| Key { key = "ArrowUp" } \ upArrow state
|
|
|
|
{ state = newState, emit = saveGlyph newState })
|
|
|
|
| Key { key = "k" } \ upArrow state
|
|
|
|
|
|
|
|
| Key { key = "ArrowLeft" } \ leftArrow state
|
|
|
|
|
|
|
|
| Key { key = "h" } \ leftArrow state
|
|
|
|
|
|
|
|
| Key { key = "ArrowRight" } \ rightArrow state
|
|
|
|
|
|
|
|
| Key { key = "l" } \ rightArrow state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| UpdateHeight h \ (
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
newState = state.{ pixelHeight = (int h) };
|
|
|
|
|
|
|
|
{ state = newState, emit = saveGlyph newState })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
view = state emit \
|
|
|
|
|
|
|
|
tileSize = 50;
|
|
|
|
|
|
|
|
|
|
|
|
view = state emit \
|
|
|
|
tileView = g \
|
|
|
|
tileSize = 50;
|
|
|
|
glyph = g.value;
|
|
|
|
|
|
|
|
key = g.key;
|
|
|
|
|
|
|
|
scale = max 1 (floor (min (tileSize / glyph.w) (tileSize / glyph.h)) - 2);
|
|
|
|
|
|
|
|
ui.clickable {
|
|
|
|
|
|
|
|
onClick = \ editGlyph (c.path & ".glyphs." & key),
|
|
|
|
|
|
|
|
child = ui.stack {
|
|
|
|
|
|
|
|
children = [
|
|
|
|
|
|
|
|
ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" },
|
|
|
|
|
|
|
|
# center tileSize tileSize (glyphView { glyph = glyph, scale = scale })
|
|
|
|
|
|
|
|
ui.positioned {
|
|
|
|
|
|
|
|
x = scale, y = scale,
|
|
|
|
|
|
|
|
child = glyphView { glyph = glyph, scale = scale }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
tileView = g \
|
|
|
|
header = ui.row {
|
|
|
|
glyph = g.value;
|
|
|
|
gap = 10,
|
|
|
|
scale = max 1 (floor (min (tileSize / glyph.w) (tileSize / glyph.h)) - 2);
|
|
|
|
children = [
|
|
|
|
_ = debug! "scael" scale;
|
|
|
|
inputButton {
|
|
|
|
ui.clickable {
|
|
|
|
key = "new-glyph-button",
|
|
|
|
child = ui.stack {
|
|
|
|
label = "New Glyph",
|
|
|
|
children = [
|
|
|
|
onSubmit = key \ rebindAt (c.path & ".glyphs." & key) { w = 5, h = 7, map = [] }
|
|
|
|
ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" },
|
|
|
|
}
|
|
|
|
glyphView { glyph = glyph, scale = scale }
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ui.column {
|
|
|
|
ui.column {
|
|
|
|
gap = 2,
|
|
|
|
gap = 2,
|
|
|
|
children = map tileView (entries state.glyphs)
|
|
|
|
children = [
|
|
|
|
|
|
|
|
header,
|
|
|
|
|
|
|
|
...map tileView (entries state.glyphs)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|