egui-arbor
A flexible tree/outliner widget for egui - hierarchical data visualization and editing inspired by Blender's outliner.
Features
- Hierarchical Tree View: Display nested data structures with collections and entities
- Expand/Collapse: Navigate through tree hierarchy with visual expand/collapse arrows
- Drag & Drop: Reorder and reparent nodes with Before/After/Inside positioning
- Action Icons: Built-in visibility, lock, and selection toggles with custom icon support
- Inline Editing: Double-click to rename nodes with keyboard shortcuts
- Node Selection: Single or multi-selection with visual highlighting
- Customizable Styling: Configure indentation, colors, icons, and spacing
- Trait-Based Integration: Works with any data structure implementing
OutlinerNode - egui Memory Integration: Automatic state persistence across frames
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
Basic Example
use ;
// 1. Define your data structure
// 2. Implement OutlinerNode trait
// 3. Implement OutlinerActions trait
// 4. Use in your egui code
Comprehensive Example
Run the included example to see all features in action:
The example demonstrates:
- Tree structure with collections and entities
- All action icons (visibility, lock, selection)
- Drag & drop with visual feedback
- Inline renaming with double-click
- Event logging and statistics
- Custom styling options
Core Concepts
OutlinerNode Trait
Implement this trait on your data structure to make it work with the outliner:
OutlinerActions Trait
Handle user interactions by implementing this trait:
Action Icons
Built-in action icons:
- Visibility (👁/🚫): Toggle node visibility
- Lock (🔒/🔓): Prevent modifications
- Selection (☑/☐): Quick selection toggle
- Custom: Define your own with custom icons and tooltips
Drag & Drop
Three drop positions supported:
- Before: Insert before the target node
- After: Insert after the target node
- Inside: Add as child of target (collections only)
Automatic validation prevents invalid operations (e.g., parent into child).
Customization
Custom Styling
use ;
let style = default
.with_indent
.with_row_height
.with_selection_color;
new
.with_style
.show;
Custom Icons
Architecture
egui-arbor follows egui ecosystem conventions:
- User-owned data: You own your data structures
- Trait-based integration: Flexible integration with any data type
- Immediate mode: Widget reconstructed each frame
- egui memory integration: Automatic state persistence
See ARCHITECTURE.md for detailed design documentation.
Features
Optional Features
serde: Enable serialization support for state persistence
[]
= { = "0.1", = ["serde"] }
Minimum Supported Rust Version (MSRV)
Rust 1.76 or later (edition 2024).
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
Inspired by Blender's outliner and designed to integrate seamlessly with the egui ecosystem.