pub struct TreeNode<T> { /* private fields */ }Expand description
Recursive snapshot-tree node with static/reactive disabled state.
IDs should be unique for deterministic lookup, but snapshot construction does not validate uniqueness. Adding any child promotes a leaf to a branch.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::branch(1, "src").child(TreeNode::leaf(2, "lib.rs"));
assert_eq!(node.child_nodes().len(), 1);Implementations§
Source§impl<T> TreeNode<T>
impl<T> TreeNode<T>
Sourcepub fn branch(id: T, label: impl Into<String>) -> Self
pub fn branch(id: T, label: impl Into<String>) -> Self
Creates an enabled empty branch with no icons/action.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::branch("root", "Root");
assert!(node.child_nodes().is_empty());Sourcepub fn leaf(id: T, label: impl Into<String>) -> Self
pub fn leaf(id: T, label: impl Into<String>) -> Self
Creates an enabled childless leaf with no icons/action.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "README");
assert_eq!(node.label(), "README");Sourcepub fn child(self, child: TreeNode<T>) -> Self
pub fn child(self, child: TreeNode<T>) -> Self
Appends one child and promotes this node to a branch.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "parent").child(TreeNode::leaf(2, "child"));
assert_eq!(node.child_nodes()[0].id(), &2);Sourcepub fn children(self, children: impl IntoIterator<Item = TreeNode<T>>) -> Self
pub fn children(self, children: impl IntoIterator<Item = TreeNode<T>>) -> Self
Extends children in iterator order without clearing existing children.
A nonempty input promotes this node to a branch; empty input preserves its current branch flag.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::branch(1, "root").children([TreeNode::leaf(2, "a"), TreeNode::leaf(3, "b")]);
assert_eq!(node.child_nodes().len(), 2);Sourcepub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
Sets static or reactive unavailable state.
Disabled nodes are skipped by selection/navigation/editing/drop targets.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "locked").disabled(true);
let _ = node;Sourcepub fn leading_icon(self, icon: IconId) -> Self
pub fn leading_icon(self, icon: IconId) -> Self
Sets the leading icon, replacing any previous icon.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "file").leading_icon(IconId::History);
let _ = node;Sourcepub fn leading_icon_tint(self, color: Color) -> Self
pub fn leading_icon_tint(self, color: Color) -> Self
Sets a leading-icon tint override.
§Examples
use ailloli_ui_core::Color;
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "file").leading_icon_tint(Color::WHITE);
let _ = node;Sourcepub fn transient(self, transient: bool) -> Self
pub fn transient(self, transient: bool) -> Self
Marks or unmarks provisional presentation state.
The tree retains this metadata but otherwise treats the node normally.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert!(TreeNode::leaf(1, "draft").transient(true).is_transient());Sourcepub fn trailing_action(self, icon: IconId) -> Self
pub fn trailing_action(self, icon: IconId) -> Self
Sets a tooltip-free trailing action.
It is painted and hit-testable only while this row is selected.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "file").trailing_action(IconId::Close);
assert!(node.trailing_action_ref().is_some());Sourcepub fn trailing_action_with_tooltip(
self,
icon: IconId,
tooltip: impl Into<String>,
) -> Self
pub fn trailing_action_with_tooltip( self, icon: IconId, tooltip: impl Into<String>, ) -> Self
Sets a trailing action with retained tooltip metadata.
The tree does not itself render the tooltip.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::TreeNode;
let node = TreeNode::leaf(1, "file").trailing_action_with_tooltip(IconId::Close, "Remove");
assert_eq!(node.trailing_action_ref().unwrap().tooltip.as_deref(), Some("Remove"));Sourcepub fn id(&self) -> &T
pub fn id(&self) -> &T
Borrows the application-defined ID.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert_eq!(TreeNode::leaf(7, "file").id(), &7);Sourcepub fn label(&self) -> &str
pub fn label(&self) -> &str
Borrows the stored display label.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert_eq!(TreeNode::leaf(1, "file").label(), "file");Sourcepub fn child_nodes(&self) -> &[TreeNode<T>]
pub fn child_nodes(&self) -> &[TreeNode<T>]
Borrows children in display order.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert!(TreeNode::leaf(1, "file").child_nodes().is_empty());Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Reports provisional presentation metadata.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert!(!TreeNode::leaf(1, "file").is_transient());Sourcepub fn trailing_action_ref(&self) -> Option<&TreeNodeTrailingAction>
pub fn trailing_action_ref(&self) -> Option<&TreeNodeTrailingAction>
Borrows optional trailing action metadata.
§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert!(TreeNode::leaf(1, "file").trailing_action_ref().is_none());Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TreeNode<T>where
T: Freeze,
impl<T> !RefUnwindSafe for TreeNode<T>
impl<T> !Send for TreeNode<T>
impl<T> !Sync for TreeNode<T>
impl<T> Unpin for TreeNode<T>where
T: Unpin,
impl<T> !UnwindSafe for TreeNode<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.