pub struct TreeItem { /* private fields */ }Expand description
One row of a tree: a label at a depth, and optionally something before and after it.
TreeItem::new("Nettverk");
TreeItem::new("Wi-Fi").at_depth(1).with_trailing("på");
TreeItem::new("Ikke ferdig").at_depth(1).disabled();Implementations§
Source§impl TreeItem
impl TreeItem
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
A row at the top level, open, enabled.
Open by default because a tree that arrives entirely shut shows one row per top-level branch and nothing of what it is for.
Sourcepub fn at_depth(self, depth: u16) -> Self
pub fn at_depth(self, depth: u16) -> Self
How deep this row sits. 0 is the top level.
The hierarchy is this number: a row is a child of the nearest row
above it with a smaller depth. See the note on Tree for why the rows
are flat.
Sourcepub fn shut(self) -> Self
pub fn shut(self) -> Self
Starts this row shut, so what is under it is not drawn until it is opened.
Sourcepub fn with_leading(self, leading: impl Into<String>) -> Self
pub fn with_leading(self, leading: impl Into<String>) -> Self
Puts a short run of text in a column before the label.
Sourcepub fn with_trailing(self, trailing: impl Into<String>) -> Self
pub fn with_trailing(self, trailing: impl Into<String>) -> Self
Puts text at the trailing edge of the row: a value, a unit, a state.
Sourcepub fn disabled(self) -> Self
pub fn disabled(self) -> Self
Makes the row unselectable: skipped by the keyboard, inert to the mouse.
A disabled row that has children still opens and shuts: what is under it may well be reachable even when it is not.
Sourcepub const fn is_enabled(&self) -> bool
pub const fn is_enabled(&self) -> bool
Whether this row can be selected.
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enables or disables this row.