Skip to content

TreeView

treeView · Containers · interactive

An expandable hierarchy: a branch sidebar, a file tree, an outline.

Import

cpp
#include "gbui/widgets/treeView.hpp"

Example

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
rowHeightfloat26.0f
indentfloat15.0fHow far one level steps in.
guidesbooltrueA 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.
virtualisebooltrueBuilds only the rows on screen. Off draws them all, which is right for an outline of twenty and wrong for a repository.
namestd::string_viewWhat the hierarchy is of — "Branches", "Files".
heightfloatkAuto
widthfloatkAuto
growfloat1.0f

Released under the LGPL-3.0-or-later licence.