1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! 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.
//!
//! ```ignore
//! 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
//! }
//! }
//! ```
use ;
use Theme;
pub use ;
/// Convenience alias — `egui_components::Tree::new(id)` returns the upstream
/// [`TreeView`].
pub type Tree<'cm, NodeIdType> = ;
/// 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>)`.