Struct TreeItem

Source
pub struct TreeItem<T> { /* private fields */ }
Expand description

Stable retained item stored by TreeModel.

Branch/leaf identity belongs to the item rather than being inferred from children. Builder methods replace optional presentation metadata.

§Examples

use ailloli_ui_widgets::controls::TreeItem;
let item = TreeItem::branch(1_u64, "src").disabled(true);
assert!(item.is_branch());
assert!(item.is_disabled());

Implementations§

Source§

impl<T> TreeItem<T>

Source

pub fn branch(id: T, label: impl Into<String>) -> Self

Creates an enabled branch with no presentation metadata.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
let item = TreeItem::branch("root", "Root");
assert!(item.is_branch());
Source

pub fn leaf(id: T, label: impl Into<String>) -> Self

Creates an enabled leaf with no presentation metadata.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
let item = TreeItem::leaf(7, "README.md");
assert!(!item.is_branch());
Source

pub fn disabled(self, disabled: bool) -> Self

Sets whether the item is unavailable to tree interaction.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert!(TreeItem::leaf(1, "locked").disabled(true).is_disabled());
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::TreeItem;
let item = TreeItem::leaf(1, "file").leading_icon(IconId::History);
assert_eq!(item.leading_icon_ref(), Some(&IconId::History));
Source

pub fn leading_icon_tint(self, tint: Color) -> Self

Sets the leading-icon tint override.

§Examples
use ailloli_ui_core::Color;
use ailloli_ui_widgets::controls::TreeItem;
let item = TreeItem::leaf(1, "file").leading_icon_tint(Color::WHITE);
assert_eq!(item.leading_icon_tint_ref(), Some(Color::WHITE));
Source

pub fn trailing_action(self, action: TreeNodeTrailingAction) -> Self

Sets trailing action metadata, replacing any previous action.

§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::{TreeItem, TreeNodeTrailingAction};
let item = TreeItem::leaf(1, "file").trailing_action(TreeNodeTrailingAction::new(IconId::Close));
assert!(item.trailing_action_ref().is_some());
Source

pub fn transient(self, transient: bool) -> Self

Marks or unmarks provisional presentation state.

The model does not otherwise treat transient items specially.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert!(TreeItem::leaf(1, "draft").transient(true).is_transient());
Source

pub fn id(&self) -> &T

Borrows the stable item identifier.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert_eq!(TreeItem::leaf(42, "answer").id(), &42);
Source

pub fn label(&self) -> &str

Borrows the stored display label.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert_eq!(TreeItem::leaf(1, "README").label(), "README");
Source

pub const fn is_branch(&self) -> bool

Reports whether the item can own children and expansion state.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert!(TreeItem::branch(1, "dir").is_branch());
Source

pub const fn is_disabled(&self) -> bool

Reports whether tree interaction should skip this item.

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

pub fn leading_icon_ref(&self) -> Option<&IconId>

Borrows the optional leading icon.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert!(TreeItem::leaf(1, "file").leading_icon_ref().is_none());
Source

pub const fn leading_icon_tint_ref(&self) -> Option<Color>

Returns the optional leading-icon tint by value.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert_eq!(TreeItem::leaf(1, "file").leading_icon_tint_ref(), None);
Source

pub fn trailing_action_ref(&self) -> Option<&TreeNodeTrailingAction>

Borrows optional trailing action metadata.

§Examples
use ailloli_ui_widgets::controls::TreeItem;
assert!(TreeItem::leaf(1, "file").trailing_action_ref().is_none());
Source

pub const fn is_transient(&self) -> bool

Reports whether this is provisional presentation state.

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

Trait Implementations§

Source§

impl<T: Clone> Clone for TreeItem<T>

Source§

fn clone(&self) -> TreeItem<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
Source§

impl<T: Debug> Debug for TreeItem<T>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats core identity/state while deliberately omitting tint/action details.

Source§

impl<T: PartialEq> PartialEq for TreeItem<T>

Source§

fn eq(&self, other: &TreeItem<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> StructuralPartialEq for TreeItem<T>

Auto Trait Implementations§

§

impl<T> Freeze for TreeItem<T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for TreeItem<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> 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,