|
|
|
@ -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;
|
|
|
|
|