Struct TreeNode

Source
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>

Source

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());
Source

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");
Source

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);
Source

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);
Source

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;
Source

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;
Source

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;
Source

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());
Source

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());
Source

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"));
Source

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);
Source

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");
Source

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());
Source

pub fn is_transient(&self) -> bool

Reports provisional presentation metadata.

§Examples
use ailloli_ui_widgets::controls::TreeNode;
assert!(!TreeNode::leaf(1, "file").is_transient());
Source

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§

Source§

impl<T: Clone> Clone for TreeNode<T>

Source§

fn clone(&self) -> TreeNode<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<A> IntoClickAction<A> for A
where A: Clone + 'static,

§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Props for T
where T: Clone + 'static,