diff --git a/src/cg/03-ui-components.cg b/src/cg/03-ui-components.cg index 746ef7d..dbb19f2 100644 --- a/src/cg/03-ui-components.cg +++ b/src/cg/03-ui-components.cg @@ -357,7 +357,7 @@ renderText = config \ ui.row { children = map (char \ 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 } ) chars, gap = gap diff --git a/src/cg/05-palette.cg b/src/cg/05-palette.cg index 3a4306f..b71336a 100644 --- a/src/cg/05-palette.cg +++ b/src/cg/05-palette.cg @@ -72,7 +72,7 @@ palette = config \ ui.positioned { x = 6, y = 12, - child = ui.text { content = config.child, color = "white" } + child = text config.child } ] } @@ -150,7 +150,7 @@ palette = config \ color = "transparent", paddingLeft = 6, paddingTop = 8, - child = ui.text { content = title, color = "#bbb" }, + child = renderText { content = title, color = "#bbb" }, } | Item data \ paletteRow { child = data.label, diff --git a/src/cg/06-fontEditor.cg b/src/cg/06-fontEditor.cg index 6c4650f..e5092dc 100644 --- a/src/cg/06-fontEditor.cg +++ b/src/cg/06-fontEditor.cg @@ -106,7 +106,7 @@ fontEditor = config \ ui.column { gap = 2, children = [ header, grid, - text "testing" + text "This is me testing. F() . I donno. #blessed. This - taht = 2 * 4. -> etc, etc.." ]} } }; diff --git a/src/cg/06-inspector.cg b/src/cg/06-inspector.cg index 65ba513..ca0b459 100644 --- a/src/cg/06-inspector.cg +++ b/src/cg/06-inspector.cg @@ -12,7 +12,7 @@ inspector = config \ tree { value = reflected, - path = config.name, + path = [config.name], w = ctx.w, h = ctx.h - textInputHeight } diff --git a/src/cg/06-tree.cg b/src/cg/06-tree.cg index 871c496..7e3121b 100644 --- a/src/cg/06-tree.cg +++ b/src/cg/06-tree.cg @@ -14,7 +14,7 @@ treeNodeHeight = value path expanded \ | True \ lineH + (sum (map (entry \ (valueLabel entry.value) | Some _ \ lineH - | None \ lineH + (treeNodeHeight entry.value (path & "." & entry.key) expanded) + | None \ lineH + (treeNodeHeight entry.value (path & [entry.key]) expanded) ) entries)) | False \ lineH) | ListValue items \ ( @@ -22,7 +22,7 @@ treeNodeHeight = value path expanded \ | True \ lineH + (sum (mapWithIndex (item i \ (valueLabel item) | Some _ \ lineH - | None \ lineH + (treeNodeHeight item (path & "." & (show i)) expanded) + | None \ lineH + (treeNodeHeight item (path & [show i]) expanded) ) items)) | False \ lineH) | _ \ lineH; @@ -31,7 +31,7 @@ visiblePaths = value path expanded \ value | RecordValue entries \ ( [{ path = path, leaf = False }, ...(contains path expanded) | True \ flatten (map (entry \ - entryPath = path & "." & entry.key; + entryPath = path & [entry.key]; (valueLabel entry.value) | Some _ \ [{ path = entryPath, leaf = True }] | None \ visiblePaths entry.value entryPath expanded @@ -40,7 +40,7 @@ visiblePaths = value path expanded \ value | ListValue items \ ( [{ path = path, leaf = False }, ...(contains path expanded) | True \ flatten (mapWithIndex (item i \ - itemPath = path & "." & (show i); + itemPath = path & [show i]; (valueLabel item) | Some _ \ [{ path = itemPath, leaf = True }] | None \ visiblePaths item itemPath expanded @@ -55,7 +55,7 @@ treeNode = config \ simple = path content color onClick \ selected = (config.selectedPath | Some p \ p == path | None \ False); # 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 | Some handler \ ui.clickable { onClick = handler, child = inner } | None \ inner); @@ -71,7 +71,7 @@ treeNode = config \ | _ \ None; 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; @@ -83,7 +83,7 @@ treeNode = config \ config.value | NumberValue n \ (isEditing | True \ textInput { - key = "edit-" & config.path, + key = "edit-" & (join "." config.path), initialValue = show n, autoFocus = True, color = "white", @@ -96,7 +96,7 @@ treeNode = config \ | StringValue n \ (isEditing | True \ textInput { - key = "edit-" & config.path, + key = "edit-" & (join "." config.path), initialValue = "\"" & n & "\"", autoFocus = True, color = "white", @@ -109,7 +109,7 @@ treeNode = config \ | ConstructorValue { tag = tag } \ (isEditing | True \ textInput { - key = "edit-" & config.path, + key = "edit-" & (join "." config.path), initialValue = tag, autoFocus = True, color = "white", @@ -130,7 +130,7 @@ treeNode = config \ onClick = _ \ noOp, child = ui.column { gap = 0, children = map (entry \ 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 } }] | False \ []) @@ -142,7 +142,7 @@ treeNode = config \ | True \ [ui.clickable { onClick = _ \ noOp, 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 } }] | False \ []) @@ -205,7 +205,6 @@ tree = config \ view = state emit \ onToggle = path \ emit (Toggle path); onEditLeaf = path \ - _ = debug! "onEditLeaf" path; emit (EditLeaf path); onDoneEditing = _ \ emit DoneEditing; totalH = treeNodeHeight config.value config.path state.expanded; diff --git a/src/cg/10-os.cg b/src/cg/10-os.cg index 87eab66..6b8305c 100644 --- a/src/cg/10-os.cg +++ b/src/cg/10-os.cg @@ -190,13 +190,15 @@ os = app = inspector { name = name }; openOrFocus name app.view (appWidth app)) - | Value v \ (hasField "view" v - | True \ openOrFocus input v.view (appWidth v) - | False \ (getSource input == "" - | True \ openOrFocus input (_ \ renderText { content = show v, color = "white" }) dw - | False \ ( - app = inspector { name = input }; - openOrFocus input app.view (appWidth app)))) + | Value v \ (hasField "_tag" v + | True \ batch [historyEvent, v] + | False \ (hasField "view" v + | True \ openOrFocus input v.view (appWidth v) + | False \ (getSource input == "" + | True \ openOrFocus input (_ \ renderText { content = show v, color = "white" }) dw + | False \ ( + app = inspector { name = input }; + openOrFocus input app.view (appWidth app))))) | Err msg \ (_ = debug! "OS Error" msg; noOp); batch [historyEvent, openEvent];