pub struct TreeView { /* private fields */ }Expand description
A list of items that open to show more items: a chooser, a menu of a module, the
structure of a document. Arrows move and open, Enter opens the item, Space checks it
or selects it. With a height, only the visible lines are built.
use ravenrs_reactive::State;
use ravenrs_widgets::{TreeNode, TreeView, Ui};
let selected = State::new(None::<String>);
let tree = TreeView::new(vec![
TreeNode::new("sales", "Sales").child(TreeNode::new("orders", "Orders")),
TreeNode::new("stock", "Stock"),
])
.selected(selected.binding());
let mut ui = Ui::new(tree, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl TreeView
impl TreeView
Sourcepub fn expanded(self, expanded: Binding<BTreeSet<String>>) -> Self
pub fn expanded(self, expanded: Binding<BTreeSet<String>>) -> Self
The items open, by key, to keep or to set from outside.
Sourcepub fn checked(self, checked: Binding<BTreeSet<String>>) -> Self
pub fn checked(self, checked: Binding<BTreeSet<String>>) -> Self
Shows a check box on every line, bound to the keys of the items at the tips. Checking a branch checks everything under it, and a branch partly under check says so.
Sourcepub fn filter(self, text: impl Into<String>) -> Self
pub fn filter(self, text: impl Into<String>) -> Self
Shows only the items with this text, and the branches that lead to them.
Sourcepub fn on_open(self, handler: impl Fn(&str) + 'static) -> Self
pub fn on_open(self, handler: impl Fn(&str) + 'static) -> Self
Runs with the key on Enter or on a double click.
Sourcepub fn on_expand(self, handler: impl Fn(&str) + 'static) -> Self
pub fn on_expand(self, handler: impl Fn(&str) + 'static) -> Self
Runs with the key when an item opens, to bring what is under a TreeNode::lazy one.
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Scrolls inside this height, building only the lines in sight.
Sourcepub fn row_height(self, height: f32) -> Self
pub fn row_height(self, height: f32) -> Self
Height of a line in logical pixels. 32 by default.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TreeView
impl !Send for TreeView
impl !Sync for TreeView
impl !UnwindSafe for TreeView
impl Freeze for TreeView
impl Unpin for TreeView
impl UnsafeUnpin for TreeView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.