pub struct TreeView<T: Display + Debug> { /* fields omitted */ }
Expand description

A low level tree view.

Each view provides a number of low level methods for manipulating its contained items and their structure.

All interactions are performed via relative (i.e. visual) row indices which makes reasoning about behaviour much easier in the context of interactive user manipulation of the tree.

Examples

let mut tree = TreeView::new();

tree.insert_item("root".to_string(), Placement::LastChild, 0);

tree.insert_item("1".to_string(), Placement::LastChild, 0);
tree.insert_item("2".to_string(), Placement::LastChild, 1);
tree.insert_item("3".to_string(), Placement::LastChild, 2);

Implementations

Creates a new, empty TreeView.

Disables this view.

A disabled view cannot be selected.

Re-enables this view.

Enable or disable this view.

Returns true if this view is enabled.

Sets a callback to be used when <Enter> is pressed while an item is selected.

Example
tree.set_on_submit(|siv: &mut Cursive, row: usize| {

});

Sets a callback to be used when <Enter> is pressed while an item is selected.

Chainable variant.

Example
tree.on_submit(|siv: &mut Cursive, row: usize| {

});

Sets a callback to be used when an item is selected.

Example
tree.set_on_select(|siv: &mut Cursive, row: usize| {

});

Sets a callback to be used when an item is selected.

Chainable variant.

Example
tree.on_select(|siv: &mut Cursive, row: usize| {

});

Sets a callback to be used when an item has its children collapsed or expanded.

Example
tree.set_on_collapse(|siv: &mut Cursive, row: usize, is_collapsed: bool, children: usize| {

});

Sets a callback to be used when an item has its children collapsed or expanded.

Chainable variant.

Example
tree.on_collapse(|siv: &mut Cursive, row: usize, is_collapsed: bool, children: usize| {

});

Removes all items from this view.

Removes all items from this view, returning them.

Returns the number of items in this tree.

Returns true if this tree has no items.

Returns the index of the currently selected tree row.

None is returned in case of the tree being empty.

Returns position on the x axis of the symbol (first character of an item) at the given row.

None is returned in case the specified row does not visually exist.

Returns total width (including the symbol) of the item at the given row.

None is returned in case the specified row does not visually exist.

Selects the row at the specified index.

Selects the row at the specified index.

Chainable variant.

Returns a immutable reference to the item at the given row.

None is returned in case the specified row does not visually exist.

Returns a mutable reference to the item at the given row.

None is returned in case the specified row does not visually exist.

Inserts a new item at the given row with the specified Placement, returning the visual row of the item occupies after its insertion.

None will be returned in case the item is not visible after insertion due to one of its parents being in a collapsed state.

Inserts a new container at the given row with the specified Placement, returning the visual row of the container occupies after its insertion.

A container is identical to a normal item except for the fact that it can always be collapsed even if it does not contain any children.

Note: If the container is not visible because one of its parents is collapsed None will be returned since there is no visible row for the container to occupy.

Removes the item at the given row along with all of its children.

The returned vector contains the removed items in top to bottom order.

None is returned in case the specified row does not visually exist.

Removes all children of the item at the given row.

The returned vector contains the removed children in top to bottom order.

None is returned in case the specified row does not visually exist.

Extracts the item at the given row from the tree.

All of the items children will be moved up one level within the tree.

None is returned in case the specified row does not visually exist.

Collapses the children of the given row.

Expands the children of the given row.

Collapses or expands the children of the given row.

Collapses or expands the children of the given row.

Chained variant.

Select item n rows up from the one currently selected.

Select item n rows down from the one currently selected.

Returns position of the parent of the item located in row.

None is returned if row is not currenlty visible or if the item has no ancestors.

Trait Implementations

Formats the value using the given formatter. Read more

Creates a new, empty TreeView.

Draws the view with the given printer (includes bounds) and focus. Read more

Returns the minimum size the view requires with the given restrictions. Read more

Called once the size for this view has been decided. Read more

Attempt to give this view the focus. Read more

Called when an event is received (key press, mouse event, …). Read more

What part of the view is important and should be visible? Read more

Should return true if the view content changed since the last call to layout(). Read more

Runs a closure on the view identified by the given selector. Read more

Moves the focus to the view identified by the given selector. Read more

Returns the type of this view. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Downcast self to a Any.

Downcast self to a mutable Any.

Returns a boxed any from a boxed self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Runs a callback on all views identified by sel. Read more

Runs a callback on the view identified by sel. Read more

Convenient method to use call_on with a view::Selector::Name.

Convenient method to find a view wrapped in an NamedView.

Performs the conversion.

Performs the conversion.

Returns a Box<View>.

Wraps this view into an NamedView with the given id. Read more

Wraps self in a ResizedView with the given size constraints.

Wraps self into a fixed-size ResizedView.

Wraps self into a fixed-width ResizedView.

Wraps self into a fixed-width ResizedView.

Wraps self into a full-screen ResizedView.

Wraps self into a full-width ResizedView.

Wraps self into a full-height ResizedView.

Wraps self into a limited-size ResizedView.

Wraps self into a limited-width ResizedView.

Wraps self into a limited-height ResizedView.

Wraps self into a ResizedView at least sized size.

Wraps self in a ResizedView at least min_width wide.

Wraps self in a ResizedView at least min_height tall.

Wraps self in a ScrollView.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Calls the given closure and return the result. Read more

Calls the given closure on self.

Calls the given closure on self.

Calls the given closure if condition == true.