|
|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
pixelEditor = config \
|
|
|
|
|
c = config;
|
|
|
|
|
defaults = {
|
|
|
|
|
path = "newGlyph"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
|
|
|
|
|
upArrow = state \ (
|
|
|
|
|
newRow = max 0 (state.selectedRow - 1);
|
|
|
|
|
@ -17,13 +21,19 @@ pixelEditor = config \
|
|
|
|
|
newCol = min (state.pixelWidth - 1) (state.selectedCol + 1);
|
|
|
|
|
{ state = state.{ selectedCol = newCol }, emit = [] });
|
|
|
|
|
|
|
|
|
|
saveGlyph = state \
|
|
|
|
|
glyph = { w = state.pixelWidth, h = state.pixelHeight, map = state.map };
|
|
|
|
|
[rebindAt c.path glyph];
|
|
|
|
|
|
|
|
|
|
toggleFocused = state \ (
|
|
|
|
|
row = state.selectedRow;
|
|
|
|
|
col = state.selectedCol;
|
|
|
|
|
newMap = contains { x = col, y = row } state.map
|
|
|
|
|
| True \ filter (e \ e != { x = col, y = row }) state.map
|
|
|
|
|
| False \ [...state.map, { x = col, y = row }];
|
|
|
|
|
{ state = state.{ map = newMap }, emit = [] });
|
|
|
|
|
|
|
|
|
|
newState = state.{ map = newMap };
|
|
|
|
|
{ state = newState, emit = saveGlyph newState });
|
|
|
|
|
|
|
|
|
|
size \ ui.stateful {
|
|
|
|
|
focusable = True,
|
|
|
|
|
@ -54,10 +64,17 @@ pixelEditor = config \
|
|
|
|
|
| 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 \
|
|
|
|
|
# onToggle = path \ emit (Toggle path);
|
|
|
|
|
|
|
|
|
|
grid = ui.column {
|
|
|
|
|
children = map (rIdx \
|
|
|
|
|
@ -78,5 +95,42 @@ pixelEditor = config \
|
|
|
|
|
) (range 0 state.pixelHeight)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
center size.w size.h grid
|
|
|
|
|
headerHeight = 30;
|
|
|
|
|
|
|
|
|
|
header = ui.row {
|
|
|
|
|
gap = 10,
|
|
|
|
|
|
|
|
|
|
children = [
|
|
|
|
|
ui.positioned { x = 0, y = 8, child = ui.text { content = c.path, color = "#fff" } },
|
|
|
|
|
|
|
|
|
|
textInput {
|
|
|
|
|
key = "width-input",
|
|
|
|
|
w = 40,
|
|
|
|
|
h = headerHeight,
|
|
|
|
|
color = "#fff",
|
|
|
|
|
backgroundColor = "rgba(0,0,0,0.2)",
|
|
|
|
|
onSubmit = v \ emit (UpdateWidth v),
|
|
|
|
|
initialValue = (show state.pixelWidth)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui.positioned { x = 0, y = 8, child = ui.text { content = "x", color = "#aaa" } },
|
|
|
|
|
|
|
|
|
|
textInput {
|
|
|
|
|
key = "height-input",
|
|
|
|
|
w = 40,
|
|
|
|
|
h = headerHeight,
|
|
|
|
|
color = "#fff",
|
|
|
|
|
backgroundColor = "rgba(0,0,0,0.2)",
|
|
|
|
|
onSubmit = v \ emit (UpdateHeight v),
|
|
|
|
|
initialValue = (show state.pixelHeight)
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ui.column {
|
|
|
|
|
children = [
|
|
|
|
|
header,
|
|
|
|
|
center size.w size.h grid
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|