Skip to main content

Module tree

Module tree 

Source
Available on crate feature tree only.
Expand description

Hierarchical items that expand and collapse, such as folders and files.

State holds the nodes keyed by id, which are expanded, and the selection. Its update handles expanding, pointer and keyboard selection in the chosen Mode, checkboxes with tri-state parents, and children that load later. The view only builds the rows of expanded nodes that are in view, so a tree of thousands of nodes stays quick.

A node made with Node::lazy has children that are not loaded yet. Expanding it marks it loading and returns Output::Load; the app fetches the children and sends them back through the channel that subscription owns, as Loaded batches.

The tree resolves its keys through a Keymap of Actions while it has focus, which it takes when pressed; see default_keymap. Letters and digits jump to the next node starting with them.

Structs§

Loaded
Children that arrived for a lazy node.
Node
One node: its label and look. Its children are given with children, or later with Node::lazy.
RowStyle
The colours of a row.
State
The nodes, their structure and what is expanded, selected and checked.
Status
How a row is shown.
Tree
A tree builder. Convert it into an Element to render.

Enums§

Action
What a tree keyboard shortcut does.
Event
Everything that changes a tree.
Mode
How nodes are selected.
Output
What the app may need to act on after an Event.
Trailing
What sits at the end of a row.

Constants§

BATCH_SIZE
The most batches delivered in one Event::Received.
CHANNEL_CAPACITY
How many loaded batches a producer can send before it has to wait.
INDENT
Width of one level of indentation, which is also the chevron’s slot.
ROW_HEIGHT
Height of every row, as in a menu.

Functions§

default_keymap
The default tree shortcuts:
guide_colour
The colour of the indentation guides.
loaded
The children of parent, to send through the channel.
node
Creates a leaf node.
row_style
Resolves a row’s colours from the shared menu rows: a selected row is drawn as a highlighted menu row, and a hovered one with a lighter tint.
stream
The stream behind subscription, for driving it without a runtime.
subscription
Owns the channel lazy children arrive on. Emits Event::Ready first, then batches.
tree
Renders state. Without on_event every row renders disabled.

Type Aliases§

Sender
The sending half of the channel lazy children arrive on. Clone it for each producer.