pub struct TreeView {
pub nodes: Vec<TreeNode>,
pub row_height: f64,
pub indent_width: f64,
pub font: Arc<Font>,
pub font_size: f64,
pub drag_enabled: bool,
pub toggle_on_row_click: bool,
/* private fields */
}Fields§
§nodes: Vec<TreeNode>§row_height: f64§indent_width: f64§font: Arc<Font>§font_size: f64§drag_enabled: bool§toggle_on_row_click: boolWhen true, clicking anywhere on a row that has children also toggles
its expansion state. When false (the default), only the expand-toggle
arrow collapses/expands; clicks elsewhere only select.
Set to true for file-explorer-style trees (the demo Tree tab).
Leave false for the inspector tree, where clicking selects without
accidentally collapsing an expanded branch.
Implementations§
Source§impl TreeView
impl TreeView
pub fn new(font: Arc<Font>) -> Self
pub fn with_row_height(self, h: f64) -> Self
pub fn with_indent_width(self, w: f64) -> Self
pub fn with_font_size(self, s: f64) -> Self
pub fn with_drag_enabled(self) -> Self
pub fn with_toggle_on_row_click(self) -> Self
pub fn with_margin(self, m: Insets) -> Self
pub fn with_h_anchor(self, h: HAnchor) -> Self
pub fn with_v_anchor(self, v: VAnchor) -> Self
pub fn with_min_size(self, s: Size) -> Self
pub fn with_max_size(self, s: Size) -> Self
Sourcepub fn add_root(&mut self, label: impl Into<String>, icon: NodeIcon) -> usize
pub fn add_root(&mut self, label: impl Into<String>, icon: NodeIcon) -> usize
Add a root-level node; returns its index.
Trait Implementations§
Source§impl Widget for TreeView
impl Widget for TreeView
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
A static name for this widget type, used by the inspector. Default: “Widget”.
Source§fn set_bounds(&mut self, b: Rect)
fn set_bounds(&mut self, b: Rect)
Set the bounding rectangle. Called by the parent during layout.
Source§fn children_mut(&mut self) -> &mut Vec<Box<dyn Widget>>
fn children_mut(&mut self) -> &mut Vec<Box<dyn Widget>>
Mutable access to child widgets (required for event dispatch + layout).
Source§fn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Whether this widget can receive keyboard focus. Default: false.
Source§fn h_anchor(&self) -> HAnchor
fn h_anchor(&self) -> HAnchor
Horizontal anchor: how this widget sizes/positions itself horizontally
within the slot the parent assigns.
Default:
HAnchor::FIT (take natural content width).Source§fn v_anchor(&self) -> VAnchor
fn v_anchor(&self) -> VAnchor
Vertical anchor: how this widget sizes/positions itself vertically
within the slot the parent assigns.
Default:
VAnchor::FIT (take natural content height).Source§fn hit_test(&self, local_pos: Point) -> bool
fn hit_test(&self, local_pos: Point) -> bool
Return
true if local_pos (in this widget’s local coordinates) falls
inside this widget’s interactive area. Default: axis-aligned rect test.Source§fn layout(&mut self, available: Size) -> Size
fn layout(&mut self, available: Size) -> Size
Compute desired size given available space, and update internal layout. Read more
Source§fn paint(&mut self, ctx: &mut dyn DrawCtx)
fn paint(&mut self, ctx: &mut dyn DrawCtx)
Paint this widget’s own content into
ctx. Read moreSource§fn on_event(&mut self, event: &Event) -> EventResult
fn on_event(&mut self, event: &Event) -> EventResult
Handle an event. The event’s positions are already in local Y-up
coordinates. Return
EventResult::Consumed to stop bubbling.Source§fn claims_pointer_exclusively(&self, _local_pos: Point) -> bool
fn claims_pointer_exclusively(&self, _local_pos: Point) -> bool
When
true, hit_test_subtree stops recursing into this widget’s
children and returns this widget as the hit target. Used for floating
overlays (e.g. a scrollbar painted above its content) that must claim
the pointer before children that happen to share the same pixels.
Default: false.Source§fn id(&self) -> Option<&str>
fn id(&self) -> Option<&str>
Optional human-readable identifier for this widget instance. Read more
Source§fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Return
false to suppress painting this widget and all its children.
The widget’s own paint() will not be called. Default: true.Source§fn properties(&self) -> Vec<(&'static str, String)>
fn properties(&self) -> Vec<(&'static str, String)>
Return type-specific properties for the inspector properties pane. Read more
Source§fn has_backbuffer(&self) -> bool
fn has_backbuffer(&self) -> bool
Whether this widget renders into its own offscreen buffer before
compositing into the parent. Read more
Source§fn backbuffer_cache_mut(&mut self) -> Option<&mut BackbufferCache>
fn backbuffer_cache_mut(&mut self) -> Option<&mut BackbufferCache>
Opt into per-widget CPU bitmap caching with a dirty flag. Read more
Source§fn backbuffer_mode(&self) -> BackbufferMode
fn backbuffer_mode(&self) -> BackbufferMode
Storage format for this widget’s backbuffer. Ignored unless
[
backbuffer_cache_mut] returns Some. Default
BackbufferMode::Rgba — correct for any widget.
Opt into BackbufferMode::LcdCoverage only when the widget
paints opaque content covering its full bounds.Source§fn contributes_children_to_inspector(&self) -> bool
fn contributes_children_to_inspector(&self) -> bool
Whether the inspector should recurse into this widget’s children. Read more
Source§fn show_in_inspector(&self) -> bool
fn show_in_inspector(&self) -> bool
Return
false to hide this widget (and its subtree) from the inspector
node snapshot entirely. Intended for zero-size utility widgets such
as layout-time watchers / tickers / invisible composers — they bloat
the inspector tree without providing user-relevant information and,
at scale, can make the inspector’s per-frame tree rebuild expensive.Source§fn lcd_preference(&self) -> Option<bool>
fn lcd_preference(&self) -> Option<bool>
Per-widget LCD subpixel preference for backbuffered text rendering. Read more
Source§fn paint_overlay(&mut self, _ctx: &mut dyn DrawCtx)
fn paint_overlay(&mut self, _ctx: &mut dyn DrawCtx)
Paint decorations that must appear on top of all children. Read more
Source§fn clip_children_rect(&self) -> Option<(f64, f64, f64, f64)>
fn clip_children_rect(&self) -> Option<(f64, f64, f64, f64)>
Return a clip rectangle (in local coordinates) that constrains all child
painting.
paint_subtree applies this clip before recursing into
children, then restores the previous clip state afterward. The clip does
not affect paint_overlay, which runs after the clip is removed. Read moreSource§fn enforce_integer_bounds(&self) -> bool
fn enforce_integer_bounds(&self) -> bool
Whether
paint_subtree should snap this widget’s incoming
translation to the physical pixel grid. Read moreSource§fn take_raise_request(&mut self) -> bool
fn take_raise_request(&mut self) -> bool
Container widgets (notably
crate::widgets::Stack) call this on each
child at the start of layout(). A widget that returns true is
moved to the END of its parent’s child list — painted last, i.e.
raised to the top of the z-order. take_ semantics: the call is
also expected to clear the request so the child doesn’t keep
getting raised every frame. Read moreSource§fn needs_paint(&self) -> bool
fn needs_paint(&self) -> bool
Return
true if this widget, or any visible descendant, has state
that requires a repaint (hover change, tween in flight, etc.). Read moreSource§fn next_paint_deadline(&self) -> Option<Instant>
fn next_paint_deadline(&self) -> Option<Instant>
Return the earliest wall-clock instant at which this widget (or any
visible descendant) wants the next paint.
None = no scheduled wake.
The host loop turns a Some(t) into ControlFlow::WaitUntil(t) so
e.g. a cursor blink fires without continuous polling. Read moreAuto Trait Implementations§
impl Freeze for TreeView
impl !RefUnwindSafe for TreeView
impl !Send for TreeView
impl !Sync for TreeView
impl Unpin for TreeView
impl UnsafeUnpin for TreeView
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more