Fixing tree after making paths lists. more font stuff. fixing rebind from the palette

master
Dustin Swan 3 days ago
parent 414fc5d79c
commit cbab2a3417
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -357,7 +357,7 @@ renderText = config \
ui.row { ui.row {
children = map (char \ children = map (char \
getField char font.glyphs getField char font.glyphs
| Some g \ glyphView { glyph = g, scale = c.scale } | Some g \ glyphView { glyph = g, scale = c.scale, color = c.color }
| None \ ui.rect { w = charW * c.scale, h = 12 * c.scale } | None \ ui.rect { w = charW * c.scale, h = 12 * c.scale }
) chars, ) chars,
gap = gap gap = gap

@ -72,7 +72,7 @@ palette = config \
ui.positioned { ui.positioned {
x = 6, x = 6,
y = 12, y = 12,
child = ui.text { content = config.child, color = "white" } child = text config.child
} }
] ]
} }
@ -150,7 +150,7 @@ palette = config \
color = "transparent", color = "transparent",
paddingLeft = 6, paddingLeft = 6,
paddingTop = 8, paddingTop = 8,
child = ui.text { content = title, color = "#bbb" }, child = renderText { content = title, color = "#bbb" },
} }
| Item data \ paletteRow { | Item data \ paletteRow {
child = data.label, child = data.label,

@ -106,7 +106,7 @@ fontEditor = config \
ui.column { gap = 2, children = [ ui.column { gap = 2, children = [
header, header,
grid, grid,
text "testing" text "This is me testing. F() . I donno. #blessed. This - taht = 2 * 4. -> etc, etc.."
]} ]}
} }
}; };

@ -12,7 +12,7 @@ inspector = config \
tree { tree {
value = reflected, value = reflected,
path = config.name, path = [config.name],
w = ctx.w, w = ctx.w,
h = ctx.h - textInputHeight h = ctx.h - textInputHeight
} }

@ -14,7 +14,7 @@ treeNodeHeight = value path expanded \
| True \ lineH + (sum (map (entry \ | True \ lineH + (sum (map (entry \
(valueLabel entry.value) (valueLabel entry.value)
| Some _ \ lineH | Some _ \ lineH
| None \ lineH + (treeNodeHeight entry.value (path & "." & entry.key) expanded) | None \ lineH + (treeNodeHeight entry.value (path & [entry.key]) expanded)
) entries)) ) entries))
| False \ lineH) | False \ lineH)
| ListValue items \ ( | ListValue items \ (
@ -22,7 +22,7 @@ treeNodeHeight = value path expanded \
| True \ lineH + (sum (mapWithIndex (item i \ | True \ lineH + (sum (mapWithIndex (item i \
(valueLabel item) (valueLabel item)
| Some _ \ lineH | Some _ \ lineH
| None \ lineH + (treeNodeHeight item (path & "." & (show i)) expanded) | None \ lineH + (treeNodeHeight item (path & [show i]) expanded)
) items)) ) items))
| False \ lineH) | False \ lineH)
| _ \ lineH; | _ \ lineH;
@ -31,7 +31,7 @@ visiblePaths = value path expanded \ value
| RecordValue entries \ ( | RecordValue entries \ (
[{ path = path, leaf = False }, ...(contains path expanded) [{ path = path, leaf = False }, ...(contains path expanded)
| True \ flatten (map (entry \ | True \ flatten (map (entry \
entryPath = path & "." & entry.key; entryPath = path & [entry.key];
(valueLabel entry.value) (valueLabel entry.value)
| Some _ \ [{ path = entryPath, leaf = True }] | Some _ \ [{ path = entryPath, leaf = True }]
| None \ visiblePaths entry.value entryPath expanded | None \ visiblePaths entry.value entryPath expanded
@ -40,7 +40,7 @@ visiblePaths = value path expanded \ value
| ListValue items \ ( | ListValue items \ (
[{ path = path, leaf = False }, ...(contains path expanded) [{ path = path, leaf = False }, ...(contains path expanded)
| True \ flatten (mapWithIndex (item i \ | True \ flatten (mapWithIndex (item i \
itemPath = path & "." & (show i); itemPath = path & [show i];
(valueLabel item) (valueLabel item)
| Some _ \ [{ path = itemPath, leaf = True }] | Some _ \ [{ path = itemPath, leaf = True }]
| None \ visiblePaths item itemPath expanded | None \ visiblePaths item itemPath expanded
@ -55,7 +55,7 @@ treeNode = config \
simple = path content color onClick \ simple = path content color onClick \
selected = (config.selectedPath | Some p \ p == path | None \ False); selected = (config.selectedPath | Some p \ p == path | None \ False);
# inner = ui.text { content = content, color = (selected | True \ "white" | False \ color) }; # inner = ui.text { content = content, color = (selected | True \ "white" | False \ color) };
inner = renderText { scale = 1, content = content, color = (selected | True \ "white" | False \ color) }; inner = renderText { content = content, color = (selected | True \ "white" | False \ color) };
wrapped = (onClick wrapped = (onClick
| Some handler \ ui.clickable { onClick = handler, child = inner } | Some handler \ ui.clickable { onClick = handler, child = inner }
| None \ inner); | None \ inner);
@ -71,7 +71,7 @@ treeNode = config \
| _ \ None; | _ \ None;
header = isExp label color \ header = isExp label color \
simple config.path (config.prefix & (isExp | True \ "▼ " | False \ "▶ ") & label) color (Some (_ \ config.onToggle config.path)); simple config.path (config.prefix & (isExp | True \ "- " | False \ "+ ") & label) color (Some (_ \ config.onToggle config.path));
isExp = contains config.path config.expanded; isExp = contains config.path config.expanded;
@ -83,7 +83,7 @@ treeNode = config \
config.value config.value
| NumberValue n \ (isEditing | NumberValue n \ (isEditing
| True \ textInput { | True \ textInput {
key = "edit-" & config.path, key = "edit-" & (join "." config.path),
initialValue = show n, initialValue = show n,
autoFocus = True, autoFocus = True,
color = "white", color = "white",
@ -96,7 +96,7 @@ treeNode = config \
| StringValue n \ (isEditing | StringValue n \ (isEditing
| True \ textInput { | True \ textInput {
key = "edit-" & config.path, key = "edit-" & (join "." config.path),
initialValue = "\"" & n & "\"", initialValue = "\"" & n & "\"",
autoFocus = True, autoFocus = True,
color = "white", color = "white",
@ -109,7 +109,7 @@ treeNode = config \
| ConstructorValue { tag = tag } \ (isEditing | ConstructorValue { tag = tag } \ (isEditing
| True \ textInput { | True \ textInput {
key = "edit-" & config.path, key = "edit-" & (join "." config.path),
initialValue = tag, initialValue = tag,
autoFocus = True, autoFocus = True,
color = "white", color = "white",
@ -130,7 +130,7 @@ treeNode = config \
onClick = _ \ noOp, onClick = _ \ noOp,
child = ui.column { gap = 0, children = map (entry \ child = ui.column { gap = 0, children = map (entry \
pfx = (valueLabel entry.value) | Some _ \ " = " | None \ " "; pfx = (valueLabel entry.value) | Some _ \ " = " | None \ " ";
treeNode { value = entry.value, depth = depth + 1, path = config.path & "." & entry.key, expanded = config.expanded, onToggle = config.onToggle, selectedPath = config.selectedPath, prefix = entry.key & pfx, editing = config.editing, onDoneEditing = config.onDoneEditing, onEditLeaf = config.onEditLeaf } treeNode { value = entry.value, depth = depth + 1, path = config.path & [entry.key], expanded = config.expanded, onToggle = config.onToggle, selectedPath = config.selectedPath, prefix = entry.key & pfx, editing = config.editing, onDoneEditing = config.onDoneEditing, onEditLeaf = config.onEditLeaf }
) entries } ) entries }
}] }]
| False \ []) | False \ [])
@ -142,7 +142,7 @@ treeNode = config \
| True \ [ui.clickable { | True \ [ui.clickable {
onClick = _ \ noOp, onClick = _ \ noOp,
child = ui.column { gap = 0, children = mapWithIndex (item i \ child = ui.column { gap = 0, children = mapWithIndex (item i \
treeNode { value = item, depth = depth + 1, path = config.path & "." & (show i), expanded = config.expanded, onToggle = config.onToggle, selectedPath = config.selectedPath, prefix = (show i) & ": ", editing = config.editing, onDoneEditing = config.onDoneEditing, onEditLeaf = config.onEditLeaf } treeNode { value = item, depth = depth + 1, path = config.path & [show i], expanded = config.expanded, onToggle = config.onToggle, selectedPath = config.selectedPath, prefix = (show i) & ": ", editing = config.editing, onDoneEditing = config.onDoneEditing, onEditLeaf = config.onEditLeaf }
) items } ) items }
}] }]
| False \ []) | False \ [])
@ -205,7 +205,6 @@ tree = config \
view = state emit \ view = state emit \
onToggle = path \ emit (Toggle path); onToggle = path \ emit (Toggle path);
onEditLeaf = path \ onEditLeaf = path \
_ = debug! "onEditLeaf" path;
emit (EditLeaf path); emit (EditLeaf path);
onDoneEditing = _ \ emit DoneEditing; onDoneEditing = _ \ emit DoneEditing;
totalH = treeNodeHeight config.value config.path state.expanded; totalH = treeNodeHeight config.value config.path state.expanded;

@ -190,13 +190,15 @@ os =
app = inspector { name = name }; app = inspector { name = name };
openOrFocus name app.view (appWidth app)) openOrFocus name app.view (appWidth app))
| Value v \ (hasField "view" v | Value v \ (hasField "_tag" v
| True \ openOrFocus input v.view (appWidth v) | True \ batch [historyEvent, v]
| False \ (getSource input == "" | False \ (hasField "view" v
| True \ openOrFocus input (_ \ renderText { content = show v, color = "white" }) dw | True \ openOrFocus input v.view (appWidth v)
| False \ ( | False \ (getSource input == ""
app = inspector { name = input }; | True \ openOrFocus input (_ \ renderText { content = show v, color = "white" }) dw
openOrFocus input app.view (appWidth app)))) | False \ (
app = inspector { name = input };
openOrFocus input app.view (appWidth app)))))
| Err msg \ (_ = debug! "OS Error" msg; noOp); | Err msg \ (_ = debug! "OS Error" msg; noOp);
batch [historyEvent, openEvent]; batch [historyEvent, openEvent];

Loading…
Cancel
Save