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>
impl<T> TreeItem<T>
Sourcepub fn branch(id: T, label: impl Into<String>) -> Self
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());Sourcepub fn leaf(id: T, label: impl Into<String>) -> Self
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());Sourcepub fn disabled(self, disabled: bool) -> Self
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());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::TreeItem;
let item = TreeItem::leaf(1, "file").leading_icon(IconId::History);
assert_eq!(item.leading_icon_ref(), Some(&IconId::History));Sourcepub fn leading_icon_tint(self, tint: Color) -> Self
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));Sourcepub fn trailing_action(self, action: TreeNodeTrailingAction) -> Self
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());Sourcepub fn transient(self, transient: bool) -> Self
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());Sourcepub fn id(&self) -> &T
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);Sourcepub fn label(&self) -> &str
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");Sourcepub const fn is_branch(&self) -> bool
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());Sourcepub const fn is_disabled(&self) -> bool
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());Sourcepub fn leading_icon_ref(&self) -> Option<&IconId>
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());Sourcepub const fn leading_icon_tint_ref(&self) -> Option<Color>
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);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::TreeItem;
assert!(TreeItem::leaf(1, "file").trailing_action_ref().is_none());Sourcepub const fn is_transient(&self) -> bool
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§
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> 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.