Skip to main content

TreeItem

Struct TreeItem 

Source
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

Source

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.

Source

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.

Source

pub fn shut(self) -> Self

Starts this row shut, so what is under it is not drawn until it is opened.

Source

pub fn with_leading(self, leading: impl Into<String>) -> Self

Puts a short run of text in a column before the label.

Source

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.

Source

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.

Source

pub fn text(&self) -> &str

The row’s label.

Source

pub fn leading(&self) -> &str

The text before the label.

Source

pub fn trailing(&self) -> &str

The text at the trailing edge.

Source

pub const fn depth(&self) -> u16

How deep this row sits.

Source

pub const fn is_open(&self) -> bool

Whether what is under this row is drawn.

Source

pub const fn is_enabled(&self) -> bool

Whether this row can be selected.

Source

pub fn set_text(&mut self, text: impl Into<String>)

Replaces the label.

Source

pub fn set_open(&mut self, open: bool)

Opens or shuts this row.

Source

pub fn set_enabled(&mut self, enabled: bool)

Enables or disables this row.

Trait Implementations§

Source§

impl Clone for TreeItem

Source§

fn clone(&self) -> TreeItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TreeItem

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for TreeItem

Source§

impl From<&str> for TreeItem

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for TreeItem

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for TreeItem

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TreeItem

Auto Trait Implementations§

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrows as dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Mutably borrows as dyn Any.
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.

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.