Tables and trees
At a glance
Section titled “At a glance”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) -> []TreeNodeColumn
Section titled “Column”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}| Field | Type | Notes |
|---|---|---|
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 |
Source: kiln/table.odin:11
TreeNode
Section titled “TreeNode”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.
| Field | Type | Notes |
|---|---|---|
label | string | |
icon | Icon | |
children | []TreeNode |
Source: kiln/tree.odin:12
Procedures
Section titled “Procedures”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})}| Argument | Type | Default |
|---|---|---|
selected | int | required |
columns | []Column | required |
rows | [][]string | required |
| Returns | Type |
|---|---|
| #0 | int |
| #1 | bool |
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})}| Argument | Type | Default |
|---|---|---|
selected | int | required |
nodes | []TreeNode | required |
expanded | bool | true |
| Returns | Type |
|---|---|
| #0 | int |
| #1 | bool |
Source: kiln/tree.odin:25
tree_find
Section titled “tree_find”tree_find :: proc(nodes: []TreeNode, index: int) -> (node: TreeNode, ok: bool)The node with the given depth-first index.
| Argument | Type | Default |
|---|---|---|
nodes | []TreeNode | required |
index | int | required |
| Returns | Type |
|---|---|
node | TreeNode |
ok | bool |
Source: kiln/tree.odin:49
tree_path
Section titled “tree_path”tree_path :: proc(nodes: []TreeNode, index: int, allocator := context.temp_allocator) -> []TreeNodeThe nodes from the root down to the node with the given depth-first index (e.g. breadcrumbs).
| Argument | Type | Default |
|---|---|---|
nodes | []TreeNode | required |
index | int | required |
allocator | Allocator | context.temp_allocator |
| Returns | Type |
|---|---|
| #0 | []TreeNode |
Source: kiln/tree.odin:56