Skip to main content

DrawModifierNode

Trait DrawModifierNode 

Source
pub trait DrawModifierNode: ModifierNode {
    // Provided methods
    fn create_draw_closure(&self) -> Option<NodeDrawClosure> { ... }
    fn create_behind_draw_closure(&self) -> Option<NodeDrawClosure> { ... }
}
Expand description

Marker trait for draw-specific modifier nodes.

Draw nodes participate in the draw pass of the render pipeline. A node draws through the closures it hands out, which the renderer runs at render time with a live scope of the node’s size; slice collection only gathers them.

Provided Methods§

Source

fn create_draw_closure(&self) -> Option<NodeDrawClosure>

Creates a closure for deferred drawing that will be evaluated at render time.

This is the preferred method for nodes with dynamic content like:

  • Blinking cursors (visibility changes over time)
  • Live selection during drag (selection changes during mouse move)

The returned closure captures the node’s internal state (via Rc) and evaluates at render time, not at slice collection time.

Returns None by default. Override for nodes needing deferred draw.

Source

fn create_behind_draw_closure(&self) -> Option<NodeDrawClosure>

Like create_draw_closure, but the primitives render BEHIND the node’s content — e.g. a text field’s selection highlight, which must sit under the glyphs (a highlight drawn over them tints the text with its translucent fill).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§