Expand description
§TUIRealm Tree via orx-tree
Example usage:
type TreeView = tuirealm_orx_tree::component::TreeView<String>;
#[derive(Debug, Component)]
struct OurComponent {
component: TreeView
}
impl OurComponent {
fn new() -> Self {
Self {
component: TreeView::default()
.background(Color::Reset)
.foreground(Color::White)
.border(
Borders::default()
.color(Color::LightBlue)
.modifiers(BorderType::Rounded),
)
.indent_size(2)
.scroll_step_horizontal(NonZeroUsize::new(2).unwrap())
.empty_tree_text("Loading...")
.title(Title::from(" Library ").alignment(HorizontalAlignment::Left))
.highlight_style(Style::new().fg(Color::Yellow).add_modifier(TextModifiers::REVERSED))
.highlight_symbol(">"),
}
}
}
impl AppComponent<Msg, NoUserEvent> for OurComponent {
fn on(&mut self, ev: &Event<NoUserEvent>) -> Option<Msg> {
let result = match ev {
// selection
Event::Keyboard(KeyEvent {
code: Key::Left,
modifiers: KeyModifiers::NONE,
}) => self.perform(Cmd::Move(Direction::Left)),
Event::Keyboard(KeyEvent {
code: Key::Right,
modifiers: KeyModifiers::NONE,
}) => self.perform(Cmd::Move(Direction::Right)),
Event::Keyboard(KeyEvent {
code: Key::Down,
modifiers: KeyModifiers::NONE,
}) => self.perform(Cmd::Move(Direction::Down)),
Event::Keyboard(KeyEvent {
code: Key::Up,
modifiers: KeyModifiers::NONE,
}) => self.perform(Cmd::Move(Direction::Up)),
// etc...
_ => CmdResult::NoChange,
};
match result {
CmdResult::NoChange => None,
_ => Some(Msg::ForceRedraw)
}
}
}Re-exports§
pub use orx_tree;
Modules§
- component
- Custom implementation of a tuirealm Tree View, specifically made for our usecase.
- traversal
- Module defining tree traversal iterators.
- types
- Type Aliases
- widget
- Module for all the render parts
Enums§
- Side
- Side of a sibling node relative to a particular node within the children collection.
Traits§
- NodeRef
- Reference to a tree node.