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
Activateaction in the tree. - Tree
View - A tree view widget.
- Tree
View Builder - The builder used to construct the tree.
- Tree
View Settings - The global settings the tree view will use.
- Tree
View State - Represents the state of the tree view.
Enums§
- DirPosition
- A position inside a directory node.
- Indent
Hint Style - Style of the vertical line to show the indentation level.
- RowLayout
- How rows in the tree are laid out.
- Tree
Action - 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
TreeViewinside a scope that overridesvisuals.selection.bg_fillto the theme’ssecondary_background, so the selected row matches the look ofcrate::ListItem. Returns the upstream(Response, Vec<TreeAction>).