Skip to main content

TreeView

Struct TreeView 

Source
pub struct TreeView<'context_menu, NodeIdType> { /* private fields */ }
Expand description

A tree view widget.

Implementations§

Source§

impl<'context_menu, NodeIdType> TreeView<'context_menu, NodeIdType>
where NodeIdType: NodeId,

Source

pub fn new(id: Id) -> TreeView<'context_menu, NodeIdType>

Create a tree view from an unique id.

Source

pub fn show( self, ui: &mut Ui, build_tree_view: impl FnOnce(&mut TreeViewBuilder<'_, NodeIdType>), ) -> (Response, Vec<Action<NodeIdType>>)
where NodeIdType: NodeId + Send + Sync + 'static,

Construct the tree view using the TreeViewBuilder by adding nodes to the tree.

NodeId has to be thread safe for this to load the TreeViewState from egui data. If your NodeId is not threadsafe consider creating a TreeViewState directly and displaying the the tree with TreeView::show_state

Source

pub fn show_state( self, ui: &mut Ui, state: &mut TreeViewState<NodeIdType>, build_tree_view: impl FnOnce(&mut TreeViewBuilder<'_, NodeIdType>), ) -> (Response, Vec<Action<NodeIdType>>)
where NodeIdType: NodeId,

Start displaying the tree view with a TreeViewState.

Construct the tree view using the TreeViewBuilder by adding directories or leaves to the tree.

Source§

impl<'context_menu, NodeIdType> TreeView<'context_menu, NodeIdType>
where NodeIdType: NodeId,

§Customizing the look and feel of the tree view.

To change the basic settings of the tree view you can use the TreeViewSettings to customize the tree view or use the convenience methods on TreeView directly. Check out TreeViewSettings for all settings possible on the tree view.

TreeView::new(id)
    .with_settings(TreeViewSettings{
        override_indent: Some(15.0),
        ..Default::default()
    })
    .min_height(200.0)
    .show(ui, |builder| {
        // build your tree here
});
Source

pub fn with_settings( self, settings: TreeViewSettings, ) -> TreeView<'context_menu, NodeIdType>

Set the settings for this tree view with the TreeViewSettings struct.

This is maybe more convienient to you than setting each setting individually.

Source

pub fn override_indent( self, indent: Option<f32>, ) -> TreeView<'context_menu, NodeIdType>

Override the indent value for this tree view.

By default, this value is ‘None’ which means that the indent value from the current ui is used. If this value is set, this value will be used as the indent value without affecting the ui’s indent value.

Source

pub fn override_striped( self, striped: Option<bool>, ) -> TreeView<'context_menu, NodeIdType>

Override whether or not the background of the nodes should striped.

By default, this value is ‘None’ which means that the striped setting from the current UI style is used. If this value is set, it will be used without affecting the ui’s value.

Source

pub fn indent_hint_style( self, style: IndentHintStyle, ) -> TreeView<'context_menu, NodeIdType>

Set the style of the indent hint to show the indentation level.

Source

pub fn row_layout( self, layout: RowLayout, ) -> TreeView<'context_menu, NodeIdType>

Set the row layout for this tree.

Source

pub fn allow_multi_selection( self, allow_multi_select: bool, ) -> TreeView<'context_menu, NodeIdType>

Set if the tree view is allowed to select multiple nodes at once.

Source

pub fn range_selection_modifier( self, modifiers: Modifiers, ) -> TreeView<'context_menu, NodeIdType>

Set the modifier that the user is required to press to initiate a range based selection.

Source

pub fn set_selection_modifier( self, modifiers: Modifiers, ) -> TreeView<'context_menu, NodeIdType>

Set the modifier that the user is required to press to initiate a set based selection.

Source

pub fn allow_drag_and_drop( self, allow_drag_and_drop: bool, ) -> TreeView<'context_menu, NodeIdType>

Set if nodes in the tree are allowed to be dragged and dropped.

Source

pub fn default_node_height( self, default_node_height: Option<f32>, ) -> TreeView<'context_menu, NodeIdType>

Set the default node height for this tree.

Source

pub fn fallback_context_menu( self, context_menu: impl FnOnce(&mut Ui, &Vec<NodeIdType>) + 'context_menu, ) -> TreeView<'context_menu, NodeIdType>

Add a fallback context menu to the tree.

If the node did not configure a context menu, either through NodeBuilder or NodeConfig, or if multiple nodes were selected and right-clicked, then this fallback context menu will be opened.

A context menu in egui gets its size the first time it becomes visible. Since all nodes in the tree view share the same context menu you must set the size of the context menu manually for each node if you want to have differently sized context menus.

Source

pub fn min_width(self, width: f32) -> TreeView<'context_menu, NodeIdType>

Set the minimum width the tree can have.

Source

pub fn min_height(self, height: f32) -> TreeView<'context_menu, NodeIdType>

Set the minimum height the tree can have.

Auto Trait Implementations§

§

impl<'context_menu, NodeIdType> Freeze for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> !RefUnwindSafe for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> !Send for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> !Sync for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> Unpin for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> UnsafeUnpin for TreeView<'context_menu, NodeIdType>

§

impl<'context_menu, NodeIdType> !UnwindSafe for TreeView<'context_menu, NodeIdType>

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> 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,