pub struct TreeView<'context_menu, NodeIdType> { /* private fields */ }Expand description
A tree view widget.
Implementations§
Sourcepub fn new(id: Id) -> TreeView<'context_menu, NodeIdType>
pub fn new(id: Id) -> TreeView<'context_menu, NodeIdType>
Create a tree view from an unique id.
Sourcepub fn show(
self,
ui: &mut Ui,
build_tree_view: impl FnOnce(&mut TreeViewBuilder<'_, NodeIdType>),
) -> (Response, Vec<Action<NodeIdType>>)
pub fn show( self, ui: &mut Ui, build_tree_view: impl FnOnce(&mut TreeViewBuilder<'_, NodeIdType>), ) -> (Response, Vec<Action<NodeIdType>>)
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
Sourcepub 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,
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.
TreeView::new(id)
.with_settings(TreeViewSettings{
override_indent: Some(15.0),
..Default::default()
})
.min_height(200.0)
.show(ui, |builder| {
// build your tree here
});Sourcepub fn with_settings(
self,
settings: TreeViewSettings,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn override_indent(
self,
indent: Option<f32>,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn override_striped(
self,
striped: Option<bool>,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn indent_hint_style(
self,
style: IndentHintStyle,
) -> TreeView<'context_menu, NodeIdType>
pub fn indent_hint_style( self, style: IndentHintStyle, ) -> TreeView<'context_menu, NodeIdType>
Set the style of the indent hint to show the indentation level.
Sourcepub fn row_layout(
self,
layout: RowLayout,
) -> TreeView<'context_menu, NodeIdType>
pub fn row_layout( self, layout: RowLayout, ) -> TreeView<'context_menu, NodeIdType>
Set the row layout for this tree.
Sourcepub fn allow_multi_selection(
self,
allow_multi_select: bool,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn range_selection_modifier(
self,
modifiers: Modifiers,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn set_selection_modifier(
self,
modifiers: Modifiers,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn allow_drag_and_drop(
self,
allow_drag_and_drop: bool,
) -> TreeView<'context_menu, NodeIdType>
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.
Sourcepub fn default_node_height(
self,
default_node_height: Option<f32>,
) -> TreeView<'context_menu, NodeIdType>
pub fn default_node_height( self, default_node_height: Option<f32>, ) -> TreeView<'context_menu, NodeIdType>
Set the default node height for this tree.
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.
Sourcepub fn min_width(self, width: f32) -> TreeView<'context_menu, NodeIdType>
pub fn min_width(self, width: f32) -> TreeView<'context_menu, NodeIdType>
Set the minimum width the tree can have.
Sourcepub fn min_height(self, height: f32) -> TreeView<'context_menu, NodeIdType>
pub fn min_height(self, height: f32) -> TreeView<'context_menu, NodeIdType>
Set the minimum height the tree can have.