Skip to content

Tables and trees

Column :: struct {...}
TreeNode :: struct {...}
table :: proc(selected: int, columns: []Column, rows: [][]string) -> (int, bool)
tree :: proc(selected: int, nodes: []TreeNode, expanded := true) -> (int, bool)
tree_find :: proc(nodes: []TreeNode, index: int) -> (node: TreeNode, ok: bool)
tree_path :: proc(nodes: []TreeNode, index: int, allocator := context.temp_allocator) -> []TreeNode
Column :: struct {
title: string,
width: f32, // fixed width in units; 0 = share the remaining width
min_width: f32, // flexible columns: the width they need (default 120 units)
align: Align,
numeric: bool, // sort by the number at the start of the cell text
priority: int, // 0 = always shown; higher numbers are hidden first when space runs out
}
FieldTypeNotes
titlestring
widthf32fixed width in units; 0 = share the remaining width
min_widthf32flexible columns: the width they need (default 120 units)
alignAlign
numericboolsort by the number at the start of the cell text
priorityint0 = always shown; higher numbers are hidden first when space runs out

Source: kiln/table.odin:11

TreeNode :: struct {
label: string,
icon: Icon,
children: []TreeNode,
}

One node of a tree; leaves have no children. icon is optional and goes before the label.

FieldTypeNotes
labelstring
iconIcon
children[]TreeNode

Source: kiln/tree.odin:12

table :: proc(selected: int, columns: []Column, rows: [][]string) -> (int, bool)

A table of text cells. rows[i][j] is the text of row i in column j. selected is the index of the selected row in rows (-1 = none); clicking a row returns its index (also when the table is sorted):

if i, ok := kiln.table(m.selected, COLUMNS[:], rows); ok {append(out, Select{i})}
ArgumentTypeDefault
selectedintrequired
columns[]Columnrequired
rows[][]stringrequired
ReturnsType
#0int
#1bool

Source: kiln/table.odin:34

tree :: proc(selected: int, nodes: []TreeNode, expanded := true) -> (int, bool)

A tree. selected is the depth-first index of the selected node (-1 = none); clicking a row selects it, the arrow opens / closes a branch. expanded is the initial state of branches.

if i, ok := kiln.tree(m.selected, m.nodes); ok {append(out, Select{i})}
ArgumentTypeDefault
selectedintrequired
nodes[]TreeNoderequired
expandedbooltrue
ReturnsType
#0int
#1bool

Source: kiln/tree.odin:25

tree_find :: proc(nodes: []TreeNode, index: int) -> (node: TreeNode, ok: bool)

The node with the given depth-first index.

ArgumentTypeDefault
nodes[]TreeNoderequired
indexintrequired
ReturnsType
nodeTreeNode
okbool

Source: kiln/tree.odin:49

tree_path :: proc(nodes: []TreeNode, index: int, allocator := context.temp_allocator) -> []TreeNode

The nodes from the root down to the node with the given depth-first index (e.g. breadcrumbs).

ArgumentTypeDefault
nodes[]TreeNoderequired
indexintrequired
allocatorAllocatorcontext.temp_allocator
ReturnsType
#0[]TreeNode

Source: kiln/tree.odin:56