Tree

Struct Tree 

Source
pub struct Tree<T>(/* private fields */);
Expand description

A hierarchical tree view component.

Displays data in a tree structure with expandable/collapsible nodes. Supports keyboard navigation and single selection.

§Visual Format

▶ Documents
▼ Projects
  ├─ envision
  │  ├─ src
  │  └─ tests
  └─ other

§Keyboard Navigation

  • Up/Down - Move selection
  • Right - Expand node
  • Left - Collapse node
  • Enter - Select/activate node

§Example

use envision::component::{Tree, TreeMessage, TreeOutput, TreeState, TreeNode, Component};

// Build tree structure
let mut docs = TreeNode::new("Documents", "docs");
docs.add_child(TreeNode::new("readme.md", "readme"));
docs.add_child(TreeNode::new("guide.md", "guide"));

let mut projects = TreeNode::new_expanded("Projects", "projects");
projects.add_child(TreeNode::new("envision", "envision"));

let mut state = TreeState::new(vec![docs, projects]);

// Navigate
Tree::update(&mut state, TreeMessage::SelectNext);
Tree::update(&mut state, TreeMessage::Expand);

Trait Implementations§

Source§

impl<T: Clone + 'static> Component for Tree<T>

Source§

type State = TreeState<T>

The component’s internal state type. Read more
Source§

type Message = TreeMessage

Messages this component can receive. Read more
Source§

type Output = TreeOutput

Messages this component can emit to its parent. Read more
Source§

fn init() -> Self::State

Initialize the component state. Read more
Source§

fn update(state: &mut Self::State, msg: Self::Message) -> Option<Self::Output>

Update component state based on a message. Read more
Source§

fn view(state: &Self::State, frame: &mut Frame<'_>, area: Rect)

Render the component to the given area. Read more
Source§

impl<T: Clone + 'static> Focusable for Tree<T>

Source§

fn is_focused(state: &Self::State) -> bool

Returns true if this component is currently focused.
Source§

fn set_focused(state: &mut Self::State, focused: bool)

Sets the focus state of this component.
Source§

fn focus(state: &mut Self::State)

Gives focus to this component. Read more
Source§

fn blur(state: &mut Self::State)

Removes focus from this component. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Tree<T>

§

impl<T> RefUnwindSafe for Tree<T>
where T: RefUnwindSafe,

§

impl<T> Send for Tree<T>
where T: Send,

§

impl<T> Sync for Tree<T>
where T: Sync,

§

impl<T> Unpin for Tree<T>
where T: Unpin,

§

impl<T> UnwindSafe for Tree<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.