Changing the shape of apps. adding better error boundries at stateful components. start fontViewer
parent
d58c39a1ac
commit
cc33b9a015
@ -0,0 +1,55 @@
|
|||||||
|
fontEditor = config \
|
||||||
|
defaults = { };
|
||||||
|
c = { ...defaults, ...config };
|
||||||
|
|
||||||
|
size \ ui.stateful {
|
||||||
|
focusable = True,
|
||||||
|
autoFocus = True,
|
||||||
|
|
||||||
|
key = "fontEditor-" & c.path,
|
||||||
|
|
||||||
|
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 }
|
||||||
|
| 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" }
|
||||||
|
};
|
||||||
@ -1,15 +1,19 @@
|
|||||||
inspector = config \ size \
|
inspector = config \
|
||||||
val = eval! config.name;
|
{
|
||||||
|
width = 600,
|
||||||
|
view = size \
|
||||||
|
val = eval! config.name;
|
||||||
|
|
||||||
reflected = val
|
reflected = val
|
||||||
| Value v \ reflect v
|
| Value v \ reflect v
|
||||||
| _ \ reflect 0;
|
| _ \ reflect 0;
|
||||||
|
|
||||||
textInputHeight = 40;
|
textInputHeight = 40;
|
||||||
|
|
||||||
tree {
|
tree {
|
||||||
value = reflected,
|
value = reflected,
|
||||||
path = config.name,
|
path = config.name,
|
||||||
w = size.w,
|
w = size.w,
|
||||||
h = size.h - textInputHeight
|
h = size.h - textInputHeight
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue