Skip to main content

Module tree

Module tree 

Source
Expand description

Tree widget powered by egui_ltreeview.

Our prior hand-rolled tree didn’t deliver working keyboard navigation, so we delegate to egui_ltreeview (MIT-licensed) which provides keyboard arrows, multi-select, drag-and-drop, and other features for free. Theming is applied automatically — egui_components_theme::Theme::install writes into egui::Visuals, which is what egui_ltreeview reads.

Public types are re-exported below so callers can use them as egui_components::Tree etc. without depending on egui_ltreeview directly.

Selected rows in egui_ltreeview use visuals.selection.bg_fill, which our theme sets to the bright text-selection color. That’s correct for text inputs but visually loud for a tree. [Tree::show_themed] applies a small local visual tweak so the selected row uses the same soft secondary background that crate::ListItem uses, keeping the look consistent.

use egui_components::{Tree, TreeViewBuilder};

let id = ui.make_persistent_id("file-tree");
let (response, actions) = Tree::show_themed(ui, id, |builder| {
    builder.dir("src", "src");
    builder.leaf("src/lib.rs", "lib.rs");
    builder.close_dir();
    builder.leaf("Cargo.toml", "Cargo.toml");
});
for action in actions {
    if let egui_components::TreeAction::SetSelected(ids) = action {
        // update your own state from ids
    }
}

Structs§

Activate
Information about the Activate action in the tree.
TreeView
A tree view widget.
TreeViewBuilder
The builder used to construct the tree.
TreeViewSettings
The global settings the tree view will use.
TreeViewState
Represents the state of the tree view.

Enums§

DirPosition
A position inside a directory node.
IndentHintStyle
Style of the vertical line to show the indentation level.
RowLayout
How rows in the tree are laid out.
TreeAction
An action the tree view would like to take as a result of some user input like drag and drop.

Traits§

NodeId
Identifies a node in the tree.

Functions§

show_themed
Build + show a TreeView inside a scope that overrides visuals.selection.bg_fill to the theme’s secondary_background, so the selected row matches the look of crate::ListItem. Returns the upstream (Response, Vec<TreeAction>).

Type Aliases§

Tree
Convenience alias — egui_components::Tree::new(id) returns the upstream TreeView.