glyphView. fontEditor. a few more host functions
parent
cc33b9a015
commit
a874101a3d
@ -1,55 +1,71 @@
|
|||||||
fontEditor = config \
|
fontEditor = config \
|
||||||
defaults = { };
|
defaults = {
|
||||||
|
path = "newFont"
|
||||||
|
};
|
||||||
|
|
||||||
c = { ...defaults, ...config };
|
c = { ...defaults, ...config };
|
||||||
|
|
||||||
size \ ui.stateful {
|
_ = debug! "here" c.path;
|
||||||
focusable = True,
|
existing = eval! (c.path);
|
||||||
autoFocus = True,
|
_ = debug! "here2" existing;
|
||||||
|
|
||||||
|
# return app
|
||||||
|
{
|
||||||
|
view = size \ ui.stateful {
|
||||||
|
focusable = True,
|
||||||
|
autoFocus = True,
|
||||||
|
|
||||||
|
key = "fontEditor-" & c.path,
|
||||||
|
|
||||||
|
init = existing
|
||||||
|
| Value v \ {
|
||||||
|
glyphs = v.glyphs,
|
||||||
|
height = v.height
|
||||||
|
}
|
||||||
|
| _ \ {
|
||||||
|
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
|
||||||
|
|
||||||
|
| Key { key = "ArrowDown" } \ downArrow state
|
||||||
|
| Key { key = "j" } \ downArrow state
|
||||||
|
| Key { key = "ArrowUp" } \ upArrow 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
|
||||||
|
|
||||||
|
| UpdateHeight h \ (
|
||||||
|
newState = state.{ pixelHeight = (int h) };
|
||||||
|
{ state = newState, emit = saveGlyph newState })
|
||||||
|
|
||||||
|
| _ \ { state = state, emit = [] },
|
||||||
|
|
||||||
|
view = state emit \
|
||||||
|
tileSize = 50;
|
||||||
|
|
||||||
key = "fontEditor-" & c.path,
|
tileView = g \
|
||||||
|
glyph = g.value;
|
||||||
|
scale = max 1 (floor (min (tileSize / glyph.w) (tileSize / glyph.h)) - 2);
|
||||||
|
_ = debug! "scael" scale;
|
||||||
|
ui.clickable {
|
||||||
|
child = ui.stack {
|
||||||
|
children = [
|
||||||
|
ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" },
|
||||||
|
glyphView { glyph = glyph, scale = scale }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
init = existing
|
ui.column {
|
||||||
| Value v \ {
|
gap = 2,
|
||||||
map = v.map,
|
children = map tileView (entries state.glyphs)
|
||||||
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 }
|
|
||||||
| Key { key = " " } \ toggleFocused state
|
|
||||||
| Key { key = "Enter" } \ toggleFocused state
|
|
||||||
|
|
||||||
| Key { key = "ArrowDown" } \ downArrow state
|
|
||||||
| Key { key = "j" } \ downArrow state
|
|
||||||
| Key { key = "ArrowUp" } \ upArrow 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
|
|
||||||
|
|
||||||
| UpdateWidth w \ (
|
|
||||||
newState = state.{ pixelWidth = (int w) };
|
|
||||||
{ state = newState, emit = saveGlyph newState })
|
|
||||||
|
|
||||||
| UpdateHeight h \ (
|
|
||||||
newState = state.{ pixelHeight = (int h) };
|
|
||||||
{ state = newState, emit = saveGlyph newState })
|
|
||||||
|
|
||||||
| _ \ { state = state, emit = [] },
|
|
||||||
|
|
||||||
view = state emit \
|
|
||||||
ui.text { content = "testing" }
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue