pub struct TreeState {
pub expanded: HashSet<usize>,
pub scroll_state: ScrollListState,
}Expand description
State for the Tree widget.
Fields§
§expanded: HashSet<usize>Set of node ids that are currently expanded.
scroll_state: ScrollListStateImplementations§
Source§impl TreeState
impl TreeState
pub fn toggle(&mut self, id: usize)
Sourcepub fn expand_all(&mut self, nodes: &[TreeNode<'_>])
pub fn expand_all(&mut self, nodes: &[TreeNode<'_>])
Expand all nodes that have children.
Sourcepub fn expand_subtree(&mut self, nodes: &[TreeNode<'_>], id: usize)
pub fn expand_subtree(&mut self, nodes: &[TreeNode<'_>], id: usize)
Expand this node and all its descendants recursively.
Sourcepub fn collapse_at(&mut self, nodes: &[TreeNode<'_>], cursor_id: usize)
pub fn collapse_at(&mut self, nodes: &[TreeNode<'_>], cursor_id: usize)
Collapse from cursor position.
If the cursor is on an expanded node with children → collapse that node. Otherwise find the nearest expanded ancestor and collapse it.
Sourcepub fn expand_at(&mut self, nodes: &[TreeNode<'_>], cursor_id: usize)
pub fn expand_at(&mut self, nodes: &[TreeNode<'_>], cursor_id: usize)
Expand from cursor position.
If cursor is on a collapsed node → expand just that node. If cursor is on an already-expanded node → expand the entire subtree recursively.
Sourcepub fn nearest_expanded_ancestor(
&self,
nodes: &[TreeNode<'_>],
cursor_id: usize,
) -> Option<usize>
pub fn nearest_expanded_ancestor( &self, nodes: &[TreeNode<'_>], cursor_id: usize, ) -> Option<usize>
Find the nearest ancestor of cursor_id that is currently expanded,
walking from the root downward. Returns None if no ancestor is expanded.
Sourcepub fn visible_index_of(
&self,
nodes: &[TreeNode<'_>],
target_id: usize,
) -> Option<usize>
pub fn visible_index_of( &self, nodes: &[TreeNode<'_>], target_id: usize, ) -> Option<usize>
Return the visible item index of the first node with id,
or None if it’s hidden behind a collapsed ancestor.
pub fn walk<'b>( nodes: &'b [TreeNode<'b>], target_id: usize, expanded: &HashSet<usize>, visible: bool, idx: &mut usize, ) -> Option<usize>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreeState
impl RefUnwindSafe for TreeState
impl Send for TreeState
impl Sync for TreeState
impl Unpin for TreeState
impl UnsafeUnpin for TreeState
impl UnwindSafe for TreeState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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