TreeView
treeView · Containers · interactive
An expandable hierarchy: a branch sidebar, a file tree, an outline.
Import
cpp
#include "gbui/widgets/treeView.hpp"Example
cpp
TreeResult treeView(Ui& ui, const Interaction& input, std::string_view id, const std::vector<TreeItem>& items, TreeState& state, const TreeViewOptions& options = {});Draws the visible rows of items and walks them. items is the whole hierarchy, flattened in pre-order. Which of it is on screen is worked out here from state.expanded, so a caller that collapses a node passes exactly the same vector as before.
API
TreeViewOptions
| Option | Type | Default | What it does |
|---|---|---|---|
rowHeight | float | 26.0f | |
indent | float | 15.0f | How far one level steps in. |
guides | bool | true | A hairline down each open level, joining a parent to its children. On, because indentation alone stops being readable at about four levels — the eye cannot hold which column belongs to which parent — and a file tree is routinely deeper than that. |
virtualise | bool | true | Builds only the rows on screen. Off draws them all, which is right for an outline of twenty and wrong for a repository. |
name | std::string_view | What the hierarchy is of — "Branches", "Files". | |
height | float | kAuto | |
width | float | kAuto | |
grow | float | 1.0f |