Skip to content

Rust API

A quick reference to the public Rust API of the engine's crates: every type with its fields or variants, methods, what it implements, and the events it takes or produces. The Python API is a thin layer over these. For the design see Architecture; for full signatures and examples build rustdoc with cargo doc --workspace --no-deps --open.

Rust has no class inheritance. Where a class would list its parents, each type here lists the traits it implements (linked), and a Deref to another type where one exists. Items are the ones each crate re-exports at its root.

Crate Role
engine-core The node tree, animation, layout, input dispatch, focus, layers and docking. Pure Rust: no window, GPU or Python.
engine-render Scene building and GPU rendering with vello_gpu and wgpu: the paint walk, damage tracking, text, images, shaders and GPU health.
engine-platform The winit event loop, window creation, platform input translation and the accessibility adapter.
engine-py The PyO3 bindings. Its classes are the Python API.

engine-core

The node tree, animation, layout, input dispatch, focus, layers and docking. Pure Rust: no window, GPU or Python.

AccessNodeData

struct. The accessibility information a node exposes to assistive technology.

Implements: Clone, Debug, Default

Field Type Description
role Role The kind of control the node is, such as button or slider.
label Option<String> The name read out for the node.
description Option<String> A longer hint read out after the label.
states AccessStates The node's state flags, such as disabled.
actions Vec<Action> The actions assistive technology can ask the node to perform.
value Option<AccessValue> The node's current value, as text or a number.
value_min Option<f64> The smallest value a range control accepts.
value_max Option<f64> The largest value a range control accepts.
value_step Option<f64> The amount a range control changes per step.
checked Option<bool> Whether a checkable node is checked.
selected Option<bool> Whether a selectable node is selected.
expanded Option<bool> Whether an expandable node is open.
level Option<usize> A heading's level, 1 for the most important.
live Option<Live> How politely changes to this node are announced.
hidden bool Hidden from assistive technology (a decorative node).
focusable Option<bool> Forces the node focusable or not; None uses the node kind's default.
tab_index i32 The Tab order key; positive first, then zero in tree order, negative skipped.
Method Description
fn in_tab_order(&self) -> bool Whether this node takes part in Tab navigation.
fn new(role: Role) -> Self Creates accessibility data with the given role and nothing else set.
fn offered_actions(&self) -> Vec<Action> Lists every action offered, including those implied by the role and state.
fn with_action(self, action: Action) -> Self Returns this data with one more action added.
fn with_label(self, label: impl Into<String>) -> Self Returns this data with the label set.

AccessStates

struct. The state flags of an accessible node.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Field Type Description
disabled bool Whether the node is disabled.

ActiveAnimation

struct. A running animation: its start and end values, timing and curve.

Field Type Description
from T The value the animation started from.
to T The value the animation is heading toward.
start Instant The moment the animation began.
duration Duration How long the animation runs.
curve MotionCurve The easing curve that shapes the motion.
on_complete Option<CompletionHandle> The handle reported when the animation finishes, if any.

Animated

struct. A value that can move smoothly to a new target over time.

Field Type Description
current T The value right now, between start and target while animating.
active Option<ActiveAnimation<T>> The running animation, or None when the value is at rest.
Method Description
fn animate_to(&mut self, to: T, duration: Duration, curve: MotionCurve, now: Instant) Starts, or replaces, an animation toward a new value.
fn animate_to_with_completion(&mut self, to: T, duration: Duration, curve: MotionCurve, now: Instant, on_complete: CompletionHandle) Starts an animation and reports a handle when it finishes.
fn new(initial: T) -> Self Creates a value at rest at the given initial value.
fn stop(&mut self) Stops any animation and leaves the value where it had reached.
fn target(&self) -> &T Returns where the value is heading, or the current value when at rest.
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool Advances the animation to a time; true while it is still running.

CanvasState

struct. The drawing commands and hit-test rule of a canvas node.

Implements: Default

Field Type Description
commands Vec<DrawCommand> The draw commands the canvas paints, in order.
hit_test Option<CustomHitTest> A custom hit-test rule; None uses the node's ordinary rectangle test.
Method Description
fn new() -> Self Creates an empty canvas with no commands.

CompletionHandle

struct. An opaque token identifying an animation-finished callback.

Implements: Clone, Copy, Debug, PartialEq, Eq, Hash

Field Type Description
0 u64 The numeric id of the callback.

CornerRadii

struct. Four corner radii that animate as one value.

Implements: Clone, Copy, Debug, PartialEq, Interpolate

Field Type Description
0 [f64; 4] Radii in the order top-left, top-right, bottom-right, bottom-left.

DockLayout

struct. The docking zones of a window, one slot per side plus the center.

Implements: Default

Field Type Description
zones [Option<DockZone>; 5] The zone for each dock side, or None where none is registered.
Method Description
fn new() -> Self Creates a layout with no zones.
fn set_zone(&mut self, side: DockSide, zone: DockZone) Registers a zone on a side, replacing any existing one.
fn zone(&self, side: DockSide) -> Option<&DockZone> Returns the zone on a side, if any.
fn zone_mut(&mut self, side: DockSide) -> Option<&mut DockZone> Returns the zone on a side for modification, if any.

DockZone

struct. One docking zone: its panels, which tab is showing, and its size.

Field Type Description
panels SmallVec<[NodeId; 4]> The panel nodes in this zone, tabbed together when there is more than one.
active_tab usize The index of the panel currently shown.
size Animated<f64> The zone's extent in pixels, animatable.
Method Description
fn new(size: f64) -> Self Creates an empty zone with the given size.

ImageState

struct. A file-backed or pixel-supplied image and how it fits its node.

Implements: Clone, Debug, PartialEq

Field Type Description
image ImageData The image's pixel data.
content_fit ContentFit How the image fits a box of a different aspect ratio, like CSS object-fit.
Method Description
fn blank() -> Self Creates a 1x1 transparent placeholder image.
fn new(image: ImageData) -> Self Creates image state from pixel data with the default fit.

Modifiers

struct. The modifier keys held while an event happens.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Field Type Description
shift bool Whether Shift is held.
ctrl bool Whether Control is held.
alt bool Whether Alt is held.
meta bool Whether the Meta (Super or Command) key is held.

Node

struct. One element in the tree, with its place, layout, paint and accessibility data.

Field Type Description
id NodeId The node's own id.
parent Option<NodeId> The node's parent, or None for a root.
children Vec<NodeId> The node's children, in order.
visible bool false hides the node and its subtree.
z_index i32 Paint and hit-test order among siblings.
kind NodeKind What the node is, such as a rectangle, text or image, with its state.
layout_style Style The layout style that sizes and positions the node.
paint PaintProperties The node's paint properties, such as background, opacity and shadows.
access AccessNodeData The node's accessibility data; default until the app opts in.
hit_testable bool Whether this node itself claims a hit in Tree::hit_test_at.
cursor Option<Cursor> The pointer shape shown over this node; None inherits the nearest ancestor's, and the default arrow when none sets one.
window_region WindowRegion Whether a primary press here moves the window, for a custom title bar.
shader Option<Arc<Shader>> The node's shader, if any.

NodeId

struct. A stable handle to a node, safe to hold after the node is removed.

Implements: Copy, Clone, Default, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, From<KeyData>, Key

NodeTransform

struct. Translation, scale and rotation, each animatable, applied about the box center.

Implements: Default

Field Type Description
translate_x Animated<f64> Horizontal shift in pixels.
translate_y Animated<f64> Vertical shift in pixels.
scale Animated<f64> Uniform scale factor; 1.0 is unscaled.
rotation_deg Animated<f64> Rotation in degrees.
Method Description
fn to_affine(&self, width: f64, height: f64) -> Affine Returns the current transform for a box of the given size.

OverlayMeta

struct. The settings of one open overlay or layer.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Field Type Description
anchor Option<NodeId> The node the overlay is positioned against.
dismiss_on_outside_click bool Whether a press outside the overlay dismisses it.
dismiss_on_escape bool Whether Escape dismisses the overlay.
modal bool Whether the overlay blocks all interaction with what is behind it.
dismissible bool Whether dismissal is reported to the app instead of closing the overlay itself.
placement Option<Placement> The side of the anchor the overlay prefers.
placed Option<Placement> The side the last layout actually used.
restore_focus Option<NodeId> The node to give focus back to when the overlay closes.

PaintProperties

struct. The paint state every node has, whatever its kind.

Field Type Description
background Animated<Color> The fill color, animatable.
corner_radius Animated<f64> The corner radius in pixels, animatable.
opacity Animated<f64> The node's opacity from 0.0 to 1.0, animatable.
transform Animated<Affine> A transform that composes with the parent's down the tree.
border_color Animated<Color> The border color, drawn inside the node's edge.
border_width Animated<f64> The border thickness in pixels.
corner_radii_override Option<Animated<CornerRadii>> Per-corner radii that replace the single corner radius when set.
shadows Animated<Shadows> The node's drop shadows, animatable.
node_transform NodeTransform Translate, scale and rotate applied about the box center.
clip_children bool Whether children are clipped to this node's box.
Method Description
fn local_transform(&self, width: f64, height: f64) -> Affine Returns the node's full local transform for a box of the given size.
fn new(background: Color, corner_radius: f64, opacity: f64) -> Self Creates paint properties with a background, corner radius and opacity.
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool Advances every animated field; true while any is still running.

PathData

struct. Vector path geometry that can be animated between shapes.

Implements: Clone, Debug, PartialEq, Interpolate

Field Type Description
0 BezPath The path's drawing segments.
Method Description
fn from_svg(data: &str) -> Result<Self, String> Parses SVG path data into a path, or returns an error message.
fn to_svg(&self) -> String Returns the path as SVG path data.

PathState

struct. The state of a path node: shape, view box and stroke trim.

Field Type Description
data Animated<PathData> The path geometry, animatable.
view_box Option<Rect> The region of path space fitted into the node's box; None uses pixels.
trim_start Animated<f64> Where the drawn stroke starts along the path, from 0.0 to 1.0.
trim_end Animated<f64> Where the drawn stroke ends along the path, from 0.0 to 1.0.
Method Description
fn geometry(&self, width: f64, height: f64) -> (BezPath, BezPath) Returns the path fitted into a box and its trimmed stroke outline.
fn new(data: PathData) -> Self Creates path state from path data with no view box and no trim.
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool Advances every animated field; true while any is still running.

ScrollViewState

struct. The state of a scroll view: offset, direction and scrollbar look.

Field Type Description
scroll Animated<f64> The scroll offset in pixels, animatable.
horizontal bool Whether the view scrolls horizontally instead of vertically.
thumb_drag_anchor Option<(f64, f64)> The pointer position and scroll offset at the start of a thumb drag.
scrollbar_fill Option<Color> The scrollbar thumb color; None uses the default.
scrollbar_width f64 The scrollbar thumb thickness in pixels.
reported f64 The offset last reported to the app as a scroll event.
Method Description
fn new(horizontal: bool) -> Self Creates scroll state, horizontal or vertical.
fn thumb_geometry(&self, viewport_extent: f64, content_extent: f64) -> (f64, f64, f64) Returns the scrollbar track length, thumb length and thumb position.

Shader

struct. A validated WGSL shader with its uniforms, inputs and mode.

Implements: Debug

Method Description
fn animated(&self) -> bool Whether the shader changes with time and needs a redraw every frame.
fn assembled(&self) -> Arc<str> The complete WGSL module for the renderer: tre's prelude, then the app's source.
fn inputs(&self) -> &[(String, NodeId)] The named inputs, in the order their bindings are numbered.
fn mode(&self) -> ShaderMode Whether the shader fills the node or is an effect on its content.
fn new(wgsl: String, uniforms: Vec<(String, UniformValue)>, inputs: Vec<(String, NodeId)>, mode: ShaderMode, animated: bool) -> Result<Arc<Self>, ShaderError> Validates wgsl and builds the shader.
fn prelude_lines(&self) -> u32 How many lines of generated code come before the app's first line.
fn set_uniforms(&self, uniforms: Vec<(String, UniformValue)>) -> Result<(), ShaderError> Replaces the uniforms, checked first and applied all at once.
fn uniform_bytes(&self) -> Vec<u8> The Uniforms buffer's bytes, laid out as WGSL lays the struct out.
fn uniforms(&self) -> Vec<(String, UniformValue)> The uniforms and their current values, in the order given.
fn versions(&self) -> (u64, u64) (values, layout): what changed since the caller last looked, for the damage tracker and the renderer's caches.
fn wgsl(&self) -> &str The app's own source, as given.

ShaderError

struct. A shader problem, positioned in the app's source when possible.

Implements: Clone, Debug, PartialEq, Display, Error

Field Type Description
message String What went wrong.
line Option<u32> The 1-based line in the app's source, if known.
column Option<u32> The 1-based byte column in the app's source, if known.
source_line Option<String> The text of the source line the error is on.

Shadow

struct. One drop shadow, drawn like a CSS box-shadow.

Implements: Clone, Copy, Debug, PartialEq, Interpolate

Field Type Description
color Color The shadow color.
offset_x f64 Horizontal offset in pixels.
offset_y f64 Vertical offset in pixels.
blur f64 Blur radius in pixels.
spread f64 Pixels the shadow grows beyond the node's box.

Shadows

struct. A node's list of drop shadows, the first painted on top.

Implements: Clone, Debug, Default, PartialEq, Interpolate

Field Type Description
0 Vec<Shadow> The shadows in paint order.

TerminalCell

struct. One character cell of a terminal grid, with its colors and style.

Implements: Clone, Copy, Debug, PartialEq

Field Type Description
ch char The character shown in the cell.
fg CellColor The foreground color.
bg CellColor The background color.
bold bool Whether the cell is bold.
dim bool Whether the cell is dimmed.
italic bool Whether the cell is italic.
underline bool Whether the cell is underlined.
inverse bool Whether foreground and background are swapped.
Method Description
fn blank() -> Self Returns an empty cell: a space with a transparent background.

TerminalPalette

struct. Every color a terminal paints: ANSI colors, defaults, cursor and selection.

Implements: Clone, Copy, Debug, PartialEq, Default

Field Type Description
ansi [Color; 16] The 16 standard ANSI colors.
foreground Color The default text color.
background Color The default background color.
cursor Color The cursor color.
selection Color The selection highlight color.
Method Description
fn background_of(&self, color: CellColor) -> Color Resolves a cell color to an actual color, using the default background.
fn foreground_of(&self, color: CellColor) -> Color Resolves a cell color to an actual color, using the default foreground.
fn indexed(&self, index: u8) -> Color Returns one of the 256 indexed colors.

TerminalState

struct. A terminal's current cell grid, cursor, selection and fonts.

Implements: Clone, Debug, PartialEq

Field Type Description
cols u16 The grid width in columns.
rows u16 The grid height in rows.
cells Vec<TerminalCell> The cells in row-major order, columns times rows long.
cursor_col u16 The cursor's column.
cursor_row u16 The cursor's row.
cursor_visible bool Whether the cursor is drawn.
font_family String The font family used to draw the grid.
font_size f32 The font size in pixels.
selection_start Option<(u16, u16)> The row and column where the mouse selection began.
selection_end Option<(u16, u16)> The row and column where the mouse selection currently ends.
palette TerminalPalette The colors the terminal paints with.
Method Description
fn cell(&self, row: u16, col: u16) -> &TerminalCell Returns the cell at a row and column; panics when out of bounds.
fn new(cols: u16, rows: u16, font_family: impl Into<String>, font_size: f32) -> Self Creates a blank grid of the given size and font.
fn resize_grid(&mut self, cols: u16, rows: u16) Resizes the grid, keeping cells that still fit and blanking the rest.

TextFieldState

struct. The state of an editable text field: content, cursor, selection and styling.

Field Type Description
content String The field's text.
font_family String The font family.
font_weight f32 The font weight, 400.0 being normal.
font_size f32 The font size in pixels.
cursor usize The caret position as a byte offset into the content.
selection_anchor Option<usize> The fixed end of the selection as a byte offset; None when nothing is selected.
preedit Option<String> The uncommitted text of an input-method composition, if any.
text_tint Animated<Color> The color of the text, caret and selection, animatable.
multiline bool Whether the field holds several lines instead of one.
show_whitespace bool Whether spaces and tabs are drawn as visible marks.
syntax_spans Vec<(Range<usize>, Color)> Byte ranges with colors supplied by the app for syntax highlighting.
folded_ranges Vec<Range<usize>> Byte ranges of the content that are hidden (folded) when painting.
goal_column Option<usize> The column kept while moving the caret up or down across lines.
scroll_offset Animated<f64> The vertical scroll of an overflowing multiline field, animatable.
horizontal_scroll_offset Animated<f64> The horizontal scroll of an overflowing line, animatable.
placeholder String The hint shown while content is empty; empty shows none.
placeholder_fill Option<Color> The placeholder's color; None is text_tint at 60% alpha.
caret_color Option<Color> The caret's color; None is text_tint.
selection_fill Option<Color> The selection highlight's color; None is text_tint at 30% alpha.
obscured bool A password field — every character paints as a bullet, and its text never leaves through copy or cut.
Method Description
fn new(content: impl Into<String>, font_family: impl Into<String>, font_weight: f32, font_size: f32) -> Self Creates a field with the caret at the end of the content.

TextOptions

struct. Line-layout options for text: wrapping, spacing, line limits and italics.

Implements: Clone, Debug, PartialEq, Default

Field Type Description
italic bool Italic.
letter_spacing f32 Extra space after each character, in pixels.
wrap bool true wraps lines at word boundaries within the node's width; false keeps each paragraph on one line.
max_lines Option<usize> The most lines shown; the rest are cut.
ellipsis bool Ends a cut last line with an ellipsis.

TextState

struct. The state of a text node: content, font, alignment and layout options.

Implements: Clone, Debug, PartialEq

Field Type Description
content String The text shown.
font_family String The font family.
font_weight f32 The font weight from 100.0 to 950.0; 400.0 is normal.
font_size f32 The font size in pixels.
align TextAlign How lines are aligned within the node's width.
line_height Option<f32> The line height as a multiple of the font size; None uses the font's own.
options TextOptions Line layout options beyond the font.

Tree

struct. The node arena: stores nodes, computes layout, routes input and tracks focus.

Implements: Default

Events: takes InputEvent (dispatch) and returns DispatchOutcome; scroll, value and focus changes are read back after a dispatch

Method Description
fn absolute_position(&self, id: NodeId) -> (f64, f64) Returns a node's on-screen position, including every ancestor's transform.
fn activate(&self, node: NodeId) -> DispatchOutcome Activates a node directly, as if it had been clicked, and returns the outcome.
fn add_child(&mut self, parent: NodeId, child: NodeId) Attaches a child under a parent in both the node and layout structures.
fn ancestors(&self, id: NodeId) -> impl Iterator<Item = NodeId> + '_ Iterates a node and then each of its ancestors up to the root, innermost first.
fn apply_active_tab(&mut self, container: NodeId, zone: &DockZone) Attaches only the zone's active tab panel to the container and detaches the others.
fn build_access_update(&self, root: NodeId) -> TreeUpdate Builds a fresh accessibility tree update from the current nodes.
fn can_scroll(&self, id: NodeId, delta: f64) -> bool Returns whether a scroll view or list can move by the given amount along its axis.
fn cancel_press(&mut self) -> Option<NodeId> Ends the current press without a click and releases any pointer capture.
fn children_in_paint_order(&self, id: NodeId) -> Cow<'_, [NodeId]> Returns a node's children bottom first, ordered by z-index then child order.
fn clear_focus(&mut self) -> Option<(Option<NodeId>, Option<NodeId>)> Leaves nothing focused and returns the old and new focus if it changed.
fn close_overlay(&mut self, id: NodeId) -> bool Closes an overlay by detaching its subtree while keeping the content alive.
fn collect_unreferenced(&mut self, id: NodeId, referenced: impl Fn(NodeId) -> bool) -> Vec<NodeId> Frees a detached subtree if the caller no longer references any node in it.
fn compute_layout(&mut self, root: NodeId, available_space: Size<AvailableSpace>) Computes layout for a root's whole subtree within the available space.
fn content_children(&self, parent: NodeId) -> &[NodeId] Returns a node's children other than its open overlays, in order.
fn cut_text_field_selection(&mut self, field: NodeId) -> Option<String> Removes and returns the selected text of a text field.
fn destroy(&mut self, id: NodeId) -> Vec<NodeId> Frees a node and its whole subtree, returning every freed id.
fn detach(&mut self, parent: NodeId, child: NodeId) Detaches a child from its parent without deleting it.
fn detach_collectible(&mut self, id: NodeId) Detaches a node from its parent and keeps it alive until it is collected.
fn dispatch(&mut self, root: NodeId, event: InputEvent, now: Instant) -> DispatchOutcome Handles one input event for a root and returns what the host must act on.
fn extend_terminal_selection(&mut self, id: NodeId, row: u16, col: u16) -> bool Moves the end of a terminal selection to a cell, growing the selection.
fn extend_text_field_selection(&mut self, field: NodeId, offset: usize) -> bool Moves the end of a text field selection to an offset, keeping the anchor.
fn focused(&self) -> Option<NodeId> Returns the node that currently has keyboard focus, if any.
fn get(&self, id: NodeId) -> Option<&Node> Returns a node by id, or None if it no longer exists.
fn get_mut(&mut self, id: NodeId) -> Option<&mut Node> Returns a mutable node by id and marks the tree as needing a frame.
fn has_shaders(&self) -> bool Returns whether any node has a shader.
fn hide_layer(&mut self, node: NodeId) -> Option<OverlayMeta> Closes a layer, keeping it alive, and returns the settings it was opened with.
fn hit_test(&self, root: NodeId, point: Point) -> Option<NodeId> Returns the topmost node at a point, testing in reverse paint order.
fn hit_test_input(&self, root: NodeId, point: Point) -> Option<NodeId> Returns the node that input at a point reaches, with open modal layers blocking others.
fn hit_test_local(&self, root: NodeId, point: Point) -> Option<(NodeId, Point)> Returns the node at a point together with the point in that node's own space.
fn image_nodes(&self) -> impl Iterator<Item = (NodeId, &ImageState)> Iterates every image node in the tree with its image state.
fn insert(&mut self, kind: NodeKind, layout_style: Style, paint: PaintProperties) -> NodeId Creates a new parentless node and returns its id.
fn insert_child(&mut self, parent: NodeId, index: usize, child: NodeId) -> bool Attaches a child under a parent at a given position in its child list.
fn is_layer(&self, id: NodeId) -> bool Returns whether a node is an open layer or overlay.
fn layout(&self, id: NodeId) -> &Layout Returns a node's computed layout box from the last layout pass.
fn local_to_window(&self, id: NodeId, point: Point) -> Point Converts a point in a node's own space into window space.
fn mark_dirty(&mut self) Marks the tree as needing a frame.
fn max_scroll(&self, view: NodeId) -> Option<f64> Returns how far a scroll view can scroll, or None if it is not a scroll view.
fn move_focus(&mut self, root: NodeId, direction: FocusDirection) -> Option<(Option<NodeId>, Option<NodeId>)> Moves keyboard focus to the next or previous node in tab order, wrapping at the ends.
fn new() -> Self Creates an empty tree.
fn open_overlay(&mut self, root: NodeId, anchor: NodeId, content: NodeId, meta: OverlayMeta) Opens content as an overlay positioned just below its anchor node.
fn overlay_meta(&self, id: NodeId) -> Option<&OverlayMeta> Returns the settings of an open overlay, if the node is one.
fn pointer_capture(&self) -> Option<NodeId> Returns the node that currently captures pointer events, if any.
fn position_overlay_over(&mut self, content: NodeId, rect: Rect) Positions an overlay's content so it covers a given rectangle.
fn remove(&mut self, id: NodeId) -> bool Removes a node and its whole subtree, detaching it from its parent.
fn root_of(&self, id: NodeId) -> NodeId Returns the top of a node's tree, or the node itself if it has no parent.
fn scroll_by_key(&mut self, view: NodeId, key: Key) -> bool Scrolls a view for a key: arrows by a line, Page keys by a page, Home and End to the ends.
fn scroll_into_view(&mut self, id: NodeId) -> bool Scrolls the enclosing scroll views just enough to show a node.
fn scroll_scroll_view_by(&mut self, id: NodeId, delta: f64) Moves a scroll view's position by a pixel amount, clamped to its range.
fn scroll_view_for_key(&self, from: NodeId, key: Key) -> Option<NodeId> Returns the scroll view that a key press scrolls, starting from a node.
fn scroll_virtual_list_by(&mut self, id: NodeId, delta_y: f64) Moves a virtual list's scroll offset by a pixel amount, clamped to its range.
fn select_all_text_field(&mut self, field: NodeId) -> bool Selects all the text in a text field.
fn set_access(&mut self, id: NodeId, access: AccessNodeData) Sets a node's accessibility role, label and actions.
fn set_canvas_content(&mut self, id: NodeId, commands: Vec<DrawCommand>, hit_test: Option<CustomHitTest>) -> Option<()> Replaces a canvas node's draw commands and optional custom hit test.
fn set_focus_to(&mut self, node: NodeId) -> Option<(Option<NodeId>, Option<NodeId>)> Moves keyboard focus directly to a node and returns the old and new focus.
fn set_hit_testable(&mut self, id: NodeId, hit_testable: bool) Sets whether a node can claim a hit by itself.
fn set_hovered(&mut self, hit: Option<NodeId>) -> Option<NodeId> Sets the hovered node and returns the previous one if it changed.
fn set_layout_style(&mut self, id: NodeId, style: Style) Updates a node's layout style and keeps the layout engine in sync.
fn set_pointer_capture(&mut self, node: Option<NodeId>) Routes all later pointer events to a node until capture is cleared.
fn set_terminal_selection_start(&mut self, id: NodeId, row: u16, col: u16) -> bool Starts a terminal selection at a cell, collapsing any existing selection.
fn set_text_field_cursor(&mut self, field: NodeId, offset: usize) -> bool Moves a text field's cursor to a character offset and clears its selection.
fn set_virtual_list_resolved_offsets(&mut self, list: NodeId, offsets: impl IntoIterator<Item = (usize, f64)>) Supplies the measured cumulative offsets for a variable-height virtual list.
fn set_virtual_list_window(&mut self, list: NodeId, visible: Range<usize>, materialize: impl FnMut(usize) -> (NodeKind, Style, PaintProperties)) Creates and recycles a virtual list's row nodes to match the visible index range.
fn shader_cycle(&self, id: NodeId, shader: &Shader) -> bool Returns whether giving a node a shader would make a shader depend on itself.
fn show_layer(&mut self, root: NodeId, node: NodeId, meta: OverlayMeta) -> bool Shows a node as a layer on top of every open layer, anchored by its settings.
fn take_dirty(&mut self) -> bool Returns whether the tree needs a frame and clears the flag.
fn take_dismissals(&mut self) -> Vec<NodeId> Returns the layers an outside press or Escape asked to dismiss since the last call.
fn take_scroll_changes(&mut self) -> Vec<(NodeId, f64, f64)> Returns each scroll view whose offset changed since the last call, as (view, old, new).
fn terminal_selected_text(&self, id: NodeId) -> Option<String> Returns the text selected in a terminal, if any.
fn text_field_selected_text(&self, field: NodeId) -> Option<String> Returns the text selected in a text field, if any.
fn tick_all(&mut self, now: Instant) -> (bool, Vec<CompletionHandle>) Advances every animation to the given time and returns finished ones.
fn try_add_child(&mut self, parent: NodeId, child: NodeId) -> bool Attaches a child under a parent unless that would create a cycle.
fn update_hover(&mut self, root: NodeId, point: Point) -> Option<NodeId> Updates the hovered node from a pointer position and returns the old one if it changed.
fn virtual_list_adopt(&mut self, list: NodeId, index: usize, row: NodeId) -> bool Attaches a caller-built node as a given row of a virtual list.
fn virtual_list_release_outside(&mut self, list: NodeId, keep: Range<usize>) -> Vec<NodeId> Detaches the list's rows outside a range and returns them, still alive.
fn virtual_list_visible(&self, list: NodeId) -> Range<usize> Returns the range of rows a virtual list's viewport currently shows.
fn window_to_local(&self, id: NodeId, point: Point) -> Point Converts a window-space point into a node's own space.

VirtualListState

struct. The state of a virtual list, which builds only the visible items.

Field Type Description
item_count usize The total number of items in the list.
item_extent ItemExtent How tall each item is: fixed or variable.
materialized BTreeMap<usize, NodeId> The item index to node map of the items currently built.
scroll_offset Animated<f64> The vertical scroll position in pixels, animatable.
resolved_offsets BTreeMap<usize, f64> Cached top offsets of items in a variable-height list.
thumb_drag_anchor Option<(f64, f64)> The pointer position and scroll offset at the start of a thumb drag.
Method Description
fn new(item_count: usize, item_extent: ItemExtent) -> Self Creates list state for a number of items and an extent rule.
fn offset_of(&self, idx: usize) -> f64 Returns the top offset of an item.
fn thumb_geometry(&self, viewport_extent: f64) -> (f64, f64, f64) Returns the scrollbar track length, thumb length and thumb position.
fn total_extent(&self) -> f64 Returns the combined height of all items.

AccessValue

enum. An accessible value: text for text controls or a number for range controls.

Implements: Clone, Debug, PartialEq

Variant Payload Description
Text (String) A text value.
Number (f64) A numeric value, such as a slider position.

CellColor

enum. A terminal cell color: the default, a palette index or a direct RGB value.

Implements: Clone, Copy, Debug, PartialEq

Variant Payload Description
Default The terminal's default foreground or background color.
Indexed (u8) A color chosen by palette index.
Rgb (Color) A direct RGB color.

ChangedValue

enum. The value a node held before an input changed it.

Implements: Clone, Debug, PartialEq

Event type. A value an input changed.

Event Payload Description
Text (String) The previous text of a text field.

ContentFit

enum. How an image is fitted into its node's box.

Implements: Clone, Copy, Debug, PartialEq, Eq, Default

Variant Payload Description
Cover Scales the image to cover the box, cropping the overflow, centered.
Contain Scales the image to fit inside the box, leaving bars where there is slack, centered.
Fill Stretches the image to the box exactly, ignoring its aspect ratio.

Cursor

enum. The mouse pointer shape a node asks for, named as in CSS.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
Default The standard arrow pointer.
Pointer A pointing hand, for clickable items.
Text A text insertion beam.
Grab An open hand, for something that can be dragged.
Grabbing A closed hand, for something being dragged.
Move A four-way arrow, for something that can be moved.
NotAllowed A prohibited sign, for an action that is not allowed.
Wait A busy indicator while the app cannot respond.
Progress A busy indicator while the app is still usable.
Crosshair A crosshair, for precise selection.
Help A question mark, for help.
ColResize A column resize pointer.
RowResize A row resize pointer.
EwResize A horizontal two-way resize arrow.
NsResize A vertical two-way resize arrow.
NeswResize A diagonal resize arrow from top right to bottom left.
NwseResize A diagonal resize arrow from top left to bottom right.
Copy A pointer showing that dropping will copy.
Cell A plus-shaped pointer for selecting cells.
ContextMenu A pointer showing that a context menu is available.
ZoomIn A magnifier with a plus, for zooming in.
ZoomOut A magnifier with a minus, for zooming out.
AllScroll A four-way arrow showing the content scrolls in any direction.
Method Description
fn from_name(name: &str) -> Option<Self> Looks up a cursor by its snake_case name.
fn name(self) -> &'static str Returns the cursor's snake_case name.

CustomHitTest

enum. A custom hit-test shape for a canvas node.

Implements: Clone

Variant Payload Description
Circle { cx: f64, cy: f64, radius: f64 } Hits when the point is within a radius of a center, in node-local units.
Path { path: BezPath, tolerance: f64 } Hits when the point is within a tolerance of a path, in node-local units.

DispatchOutcome

enum. What the tree reports back to the host after handling one input event.

Implements: Clone, Debug, PartialEq

Event type. What the tree did with an input event.

Event Payload Description
None Nothing needing the host's attention happened.
Activated (NodeId) A node was activated by a primary click or by Enter or Space while focused.
SecondaryActivated (NodeId) A node was activated by a secondary-button (right) click.
HoverChanged { old: Option<NodeId>, new: Option<NodeId> } The hovered node changed, from the old node to the new one.
Changed { node: NodeId, old_value: ChangedValue } A node's value was edited, such as a text field keystroke, with its previous value.
FocusChanged { old: Option<NodeId>, new: Option<NodeId> } Keyboard focus moved from the old node to the new one.

DockSide

enum. A zone of the fixed dock layout.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
Left The zone along the left edge.
Right The zone along the right edge.
Top The zone along the top edge.
Bottom The zone along the bottom edge.
Center The central zone.

DrawCommand

enum. One drawing instruction for a canvas node.

Implements: Clone

Variant Payload Description
FillRect { x: f64, y: f64, width: f64, height: f64, color: Color } Fills a rectangle with a color.
FillCircle { cx: f64, cy: f64, radius: f64, color: Color } Fills a circle with a color.
StrokePath { path: BezPath, color: Color, width: f64 } Strokes a path with a color and line width.

FocusDirection

enum. The direction keyboard focus moves in tab order.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
Next Moves to the next focusable node (Tab).
Previous Moves to the previous focusable node (Shift+Tab).

InputEvent

enum. The platform-neutral input events the tree handles.

Implements: Clone, Debug, PartialEq

Event type. An input the platform delivers to the tree.

Event Payload Description
PointerMoved { position: Point } The pointer moved to a position.
PointerPressed { position: Point, button: PointerButton } A pointer button was pressed at a position.
PointerReleased { position: Point, button: PointerButton } A pointer button was released at a position.
KeyPressed { key: Key, shift: bool } A navigation key was pressed, with the Shift state.
KeyReleased { key: Key, shift: bool } A navigation key was released, with the Shift state.
TextInput (String) A typed character or string was entered.
Copy The copy shortcut (Ctrl+C) was pressed.
Cut The cut shortcut (Ctrl+X) was pressed.
PasteRequested The paste shortcut (Ctrl+V) was pressed.
ControlChar (char) A Ctrl+letter shortcut other than copy, cut or paste was pressed.
TerminalCopyRequested The terminal copy shortcut (Ctrl+Shift+C) was pressed.
ImePreedit (String) An input method composition preview changed.
Scroll { delta: ScrollDelta, position: Point } The wheel or trackpad scrolled by a delta at a pointer position.
ThemeChanged { dark: bool } The system switched between light and dark appearance.
Focused { focused: bool } The window gained or lost system focus.
Resized { width: f32, height: f32 } The window's client area changed size.
Key { name: String, pressed: bool, repeat: bool } A named key was pressed or released, with a flag for auto-repeat.
ModifiersChanged (Modifiers) The held modifier keys changed.
ScaleFactorChanged { scale_factor: f64 } The window moved to a display with a different scale factor.
PointerLeft The pointer left the window, which clears hover.

ItemExtent

enum. The height of a virtual list's items: one fixed size or measured per item.

Variant Payload Description
Fixed (f64) Every item has the same given height.
Variable Items differ in height, and the caller supplies the measured offsets.

Key

enum. The keyboard keys the tree handles itself.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
Tab The Tab key.
Enter The Enter key.
Space The Space bar.
Escape The Escape key.
Backspace The Backspace key.
Delete The Delete key.
ArrowLeft The left arrow key.
ArrowRight The right arrow key.
ArrowUp The up arrow key.
ArrowDown The down arrow key.
Home The Home key.
End The End key.
PageUp The Page Up key, which scrolls a view up by its viewport.
PageDown The Page Down key, which scrolls a view down by its viewport.

MotionCurve

enum. An animation's easing curve: linear or a CSS-style cubic bezier.

Implements: Clone, Copy, Debug, PartialEq

Variant Payload Description
Linear Constant speed with no easing.
Bezier (f64, f64, f64, f64) A CSS-style cubic bezier easing given as (x1, y1, x2, y2).

NodeKind

enum. What a node is, with any data specific to that kind.

Variant Payload Description
Rect A plain painted rectangle.
Container A layout container that holds children.
Text (TextState) A run of text.
VirtualList (VirtualListState) A long list that only creates nodes for the rows currently visible.
Canvas (CanvasState) Custom-drawn content with an optional custom hit test.
TextField (TextFieldState) A single-line editable text field.
Image (ImageState) A decoded image painted as a GPU texture.
Path (PathState) A vector path that can be filled, stroked, trimmed and morphed.
Terminal (TerminalState) A terminal screen showing a grid of character cells.
ScrollView (ScrollViewState) A scrollable viewport over one oversized child.

Placement

enum. Which side of its anchor an overlay appears on.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Variant Payload Description
Below Below the anchor.
Above Above the anchor.
Start Before the anchor on the horizontal axis (left, in left-to-right text).
End After the anchor on the horizontal axis.
Method Description
fn opposite(self) -> Self Returns the placement on the opposite side of the anchor.

PointerButton

enum. A pointer button: primary, secondary, middle, back or forward.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
Primary The main button, usually the left mouse button.
Secondary The secondary button, usually the right mouse button.
Middle The middle button, usually the wheel click.
Back The mouse's back side button.
Forward The mouse's forward side button.

ScrollDelta

enum. How far a wheel or trackpad scrolled, in lines or in pixels.

Implements: Clone, Copy, Debug, PartialEq

Variant Payload Description
Lines (f64, f64) A scroll amount counted in lines, as (x, y).
Pixels (f64, f64) A scroll amount counted in pixels, as (x, y).

ShaderMode

enum. How a shader applies to its node.

Implements: Clone, Copy, Debug, PartialEq, Eq, Hash

Variant Payload Description
Fill Paints the node's box behind its content as a procedural fill.
Effect Transforms the node's own rendered content.
Method Description
fn name(self) -> &'static str Returns the mode's name as used from Python.

TextAlign

enum. Horizontal alignment of text within its box.

Implements: Clone, Copy, Debug, PartialEq, Eq, Default

Variant Payload Description
Start Aligns to the left for left-to-right text and the right for right-to-left.
Center Centers the text.
End Aligns to the right for left-to-right text and the left for right-to-left.

UniformKind

enum. The type of a shader uniform.

Implements: Clone, Copy, Debug, PartialEq, Eq

Variant Payload Description
F32 A single 32-bit float.
Vec2 A vector of two floats.
Vec3 A vector of three floats.
Vec4 A vector of four floats.

UniformValue

enum. A shader uniform's value: one float or a vector of two to four floats.

Implements: Clone, Copy, Debug, PartialEq

Variant Payload Description
F32 (f32) A single float value.
Vec2 ([f32; 2]) A two-float vector value.
Vec3 ([f32; 3]) A three-float vector value.
Vec4 ([f32; 4]) A four-float vector value.
Method Description
fn kind(&self) -> UniformKind Returns the uniform type of this value.

WindowRegion

enum. A node's role in moving the window when the app draws its own title bar.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Variant Payload Description
Default Decided by the nodes around it.
Drag A press here, or on a non-interactive node inside, moves the window.
NoDrag A press here, or inside, never moves the window.

Interpolate

trait. A value type that can be blended between two values, so it can be animated.

Implemented by: CornerRadii, PathData, Shadow, Shadows

Method Description
fn interpolate(&self, other: &Self, t: f64) -> Self Returns the blend between this value and another at progress t from 0 to 1.

Functions (engine-core)

Function Description
fn ctrl_shortcut(letter: char, shift: bool) -> Option<InputEvent> Maps Ctrl plus a letter to the input event it means, if any.
fn fit_transform(view_box: Option<Rect>, width: f64, height: f64) -> Affine Returns the transform that scales and centers a view box into a width and height.
fn frame_block(size: (f32, f32), time: f32) -> [u8; 16] Returns the bytes of the per-frame shader uniform block for a size and time.
fn from_access_id(id: NodeId) -> NodeId Converts an accessibility node id back into a tree node id.
fn node_id_as_u64(id: NodeId) -> u64 Returns a stable u64 for a node id.
fn to_access_id(id: NodeId) -> NodeId Converts a tree node id into a stable accessibility node id.
fn trim(path: &BezPath, start: f64, end: f64) -> BezPath Returns the part of a path between two fractions of its length.

Constants (engine-core)

Constant Type Description
FRAME_BLOCK_SIZE usize The size in bytes of the per-frame shader uniform block.
KEY_SCROLL_LINE f64 How far an arrow key scrolls a scroll view, in pixels.
SCROLLBAR_GRAB_SLOP f64 How far either side of a scrollbar thumb still counts as grabbing it.
SCROLLBAR_MARGIN f64 The gap between a scrollbar track and the edge of its view.
SCROLLBAR_MIN_LENGTH f64 The shortest a scrollbar thumb is drawn.
SCROLLBAR_THICKNESS f64 The width of a scrollbar.

Re-exports (engine-core)

Types re-exported from other crates:

  • Action from access
  • ActionData from access
  • Live from access
  • Role from access

engine-render

Scene building and GPU rendering with vello_gpu and wgpu: the paint walk, damage tracking, text, images, shaders and GPU health.

DamageTracker

struct. Remembers each node's painted rect and fingerprint from the last frame.

Implements: Default

Events: produces Damage (damage)

Method Description
fn damage(&mut self, tree: &Tree, root: NodeId, width: u16, height: u16, text: &mut TextRenderer) -> Damage What changed in root's tree, painted into a width x height window, since the last call.
fn new() -> Self Creates a tracker that has seen no frames yet.
fn reset(&mut self) Forgets the last frame so the next damage report is a full redraw.
fn set_time(&mut self, seconds: f32) Sets the time, in seconds, the next damage call sees: an animated shader's node is damaged whenever it changes.

FontSpec

struct. The font settings that shape a text node's lines, shared by painting and measuring.

Field Type Description
family &'a str The font family name.
weight f32 The font weight, such as 400 for regular.
size f32 The font size in pixels.
line_height Option<f32> A multiple of size; None is the font's own line height.
options &'a TextOptions Extra text options such as wrapping and line limits.

FrameRenderer

struct. Wraps the vello renderer together with the resources it needs on every render call.

Method Description
fn new(device: &Device, config: &RenderTargetConfig) -> Self Creates a renderer for the given device and render target configuration.
fn render(&mut self, scene: &Scene, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, render_size: &RenderSize, target: &TextureView) Renders scene into target via encoder.
fn render_into(&mut self, scene: &Scene, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, render_size: &RenderSize, target: &TextureView, rects: Option<&[Rect]>) Renders a scene, clearing only the given rects and keeping the rest of the target.
fn render_over(&mut self, scene: &Scene, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, render_size: &RenderSize, target: &TextureView) Renders a scene on top of the target's existing pixels without clearing anything.
fn resources_mut(&mut self) -> &mut Resources Gives access to the renderer's resources, which glyph drawing needs.
fn run_shader_passes(&mut self, tree: &Tree, root: NodeId, width: u16, height: u16, time: f32, device: &Device, queue: &Queue, text: &mut TextRenderer, geometry: &mut GeometryCache) -> ShaderTextures Runs this frame's shader passes and offscreen effect renders in dependency order.
fn shader_pass_count(&self) -> usize How many shader passes the last run_shader_passes recorded.
fn shaders_animated(&self) -> bool Whether a shader drawn by the last run_shader_passes is animated.
fn skip_shader_passes(&mut self) Marks a frame that draws nothing, so no shader pass ran.
fn sync_image_textures(&mut self, tree: &Tree, device: &Device, queue: &Queue) Uploads GPU textures for every image node so they are ready before the next render.

GeometryCache

struct. Caches tessellated rounded-rect paths across frames so they rebuild only on change.

Implements: Default

Method Description
fn evict_stale(&mut self, tree: &Tree) Drops cached paths belonging to nodes that no longer exist in the tree.
fn new() -> Self Creates an empty geometry cache.
fn rounded_rect_border(&mut self, id: NodeId, w: f64, h: f64, radius: f64, inset: f64) -> &BezPath Returns the cached border path for a uniform rounded rect, inset by half the stroke.
fn rounded_rect_border_per_corner(&mut self, id: NodeId, w: f64, h: f64, radii: [f64; 4], inset: f64) -> &BezPath Returns the cached border path for a rounded rect with a separate radius per corner.
fn rounded_rect_fill(&mut self, id: NodeId, w: f64, h: f64, radius: f64) -> &BezPath Returns the cached fill path for a uniform rounded rect, rebuilt only on change.
fn rounded_rect_fill_per_corner(&mut self, id: NodeId, w: f64, h: f64, radii: [f64; 4]) -> &BezPath Returns the cached fill path for a rounded rect with a separate radius per corner.

GpuWatch

struct. One device's health: install it right after the device is made.

Implements: Drop

Events: produces GpuReport (poll)

Method Description
fn in_flight(&self) -> bool Whether a submission is still running on this device.
fn install(device: &Device) -> Self Installs the device-lost callback and the uncaptured-error handler on device.
fn is_lost(&self) -> bool Whether the device has been reported lost.
fn poll(&mut self, device: &Device) -> Vec<GpuReport> Polls the device without blocking and returns what the GPU reported since the last call.
fn set_watchdog(&mut self, seconds: Option<f64>) Turns the stall watchdog on (Some(seconds)) or off (None).
fn submitted(&mut self, queue: &Queue) Call right after queue.submit: counts the submission as running until the GPU reports its work done.

NoFontFacesFound

struct. The error returned when font bytes contain no parseable font face.

Implements: Debug, Clone, PartialEq, Eq, Display, Error

Field Type Description
byte_len usize The length in bytes of the data that was rejected.

PersistentTarget

struct. A texture the size of a window's client area, in its surface format, that keeps its contents from frame to frame.

Method Description
fn copy_to(&self, encoder: &mut CommandEncoder, destination: &Texture) Copies the target into destination.
fn ensure_size(&mut self, device: &Device, width: u32, height: u32) -> bool Makes the target width x height, recreating it if its size changed.
fn new(device: &Device, format: TextureFormat, width: u32, height: u32) -> Self A target of width x height pixels in format.
fn size(&self) -> (u32, u32) The target's size in pixels.
fn view(&self) -> &TextureView The view to render the scene into.

ShaderPasses

struct. A window's shader textures, pipelines, and the passes that fill them.

Method Description
fn animated(&self) -> bool Whether a shader that ran in the last run is animated.
fn last_pass_count(&self) -> usize How many passes the last run recorded.
fn new(format: TextureFormat) -> Self Shader passes for a window whose surface is format.

ShaderTextures

struct. The nodes whose shader texture is current this frame, by texture size.

Implements: Default

Method Description
fn is_empty(&self) -> bool Whether any shader texture is ready.
fn none() -> Self No shader textures: nothing to draw.

TextPlacement

struct. Where and how wide to draw one text node.

Field Type Description
x f64 The left edge of the text, in the node's local coordinates.
y f64 The top edge of the text, in the node's local coordinates.
max_width f32 The node's taffy-computed box width.
color Color The color the text is drawn in.

TextRenderer

struct. Holds the font and text layout state that is kept between frames.

Implements: Default

Method Description
fn draw(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TextState, at: TextPlacement, node_id: NodeId) Shapes and wraps a text node's content and draws its glyphs into the scene.
fn draw_field(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TextFieldState, at: TextPlacement, show_caret: bool, node_id: NodeId) Draws an editable text field, including its selection and optionally its caret.
fn draw_terminal(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TerminalState, at: TextPlacement, show_caret: bool, node_id: NodeId) Draws a terminal's cell grid with backgrounds, glyphs and optionally the cursor.
fn evict_stale_layouts(&mut self, tree: &Tree) Drops cached text layouts belonging to nodes that no longer exist in the tree.
fn hit_test_position(&mut self, state: &TextFieldState, at: TextPlacement, point: Point) -> usize Returns the character index in a text field that a local point falls on.
fn measure(&mut self, content: &str, font: &FontSpec<'_>, max_width: Option<f32>) -> (f32, f32) Returns the width and height the content takes when laid out with the given font.
fn monospace_cell_size(&mut self, font_family: &str, font_size: f32) -> (f32, f32) Returns the width and height of one monospace cell at the given font and size.
fn new() -> Self Creates a text renderer with the bundled fonts loaded.
fn sync_registered_fonts(&mut self) -> bool Registers any fonts added to the process-global registry (fonts::register_font) since this renderer last synced.
fn terminal_hit_cell(&mut self, state: &TerminalState, point: Point) -> (u16, u16) Returns the terminal column and row that a local point falls on.

WindowRenderer

struct. Owns a window's renderer, caches and kept frame.

Events: takes the tracker's Damage (prepare, then draw)

Method Description
fn draw(&mut self, tree: &Tree, root: NodeId, width: u16, height: u16, damage: &Damage, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, surface: &Texture, surface_view: &TextureView) Draws the frame that the damage report calls for and presents it to the surface.
fn draw_damage_overlay(&mut self, damage: &Damage, width: u16, height: u16, device: &Device, queue: &Queue, surface_view: &TextureView) Tints the areas that were just redrawn so damage can be seen while debugging.
fn has_animated_shader(&self) -> bool Whether the last frame drew an animated shader, which keeps the window drawing frames.
fn has_persistent_target(&self) -> bool Whether frames go through a kept target, so partial redraw can apply.
fn new(device: &Device, format: TextureFormat, width: u32, height: u32, persistent: bool) -> Self Creates a renderer for a surface of the given size and format.
fn prepare(&mut self, tree: &Tree, root: NodeId, width: u16, height: u16, partial: bool, device: &Device, queue: &Queue) -> Damage Uploads images, drops stale caches and returns what changed since the last frame.
fn reset(&mut self) Makes the next frame a full one.
fn resize(&mut self, device: &Device, width: u32, height: u32) Resizes the kept target; a recreated one has lost its frame, so the next is drawn in full.
fn set_time(&mut self, seconds: f32) Sets the time, in seconds, the next frame's shaders see as frame.time.
fn shader_pass_count(&self) -> usize How many shader passes the last drawn frame ran.
fn text(&mut self) -> &mut TextRenderer The window's text shaper — the one painting uses, so hit-testing and font registration see the same layouts.

Damage

enum. What needs redrawing since the last frame.

Implements: Debug, Clone, PartialEq

Variant Payload Description
None Nothing changed, so the frame can be skipped.
Full The whole window must be redrawn.
Rects (Vec<Rect>) Only these window-pixel rectangles must be redrawn.

GpuReport

enum. Something the GPU reported about its own health.

Implements: Clone, Debug, PartialEq

Event type. What the GPU reported about its own health.

Event Payload Description
Lost { destroyed: bool, message: String } The device was lost, through a driver fault or a hang.
Error { message: String } The device reported an error and the draw that caused it is skipped.
Stalled { seconds: f64 } A submitted frame has not completed after the given number of seconds.

PresentChoice

enum. What an app asks of the swapchain.

Implements: Clone, Copy, Debug, Default, PartialEq, Eq

Variant Payload Description
Vsync One frame per display refresh, never tearing; the default.
LowLatency Shows the newest frame at once (Mailbox); the loop is not paced.
Method Description
fn from_name(name: &str) -> Option<Self> The choice a Python name stands for.
fn mode(self, supported: &[PresentMode]) -> PresentMode The present mode to configure a surface with, given the modes it supports.
fn name(self) -> &'static str The name Python uses.

Functions (engine-render)

Function Description
fn any_in_flight() -> bool Whether any device in this process has a submission still running.
fn build_rect_scene(width: u16, height: u16, color: Color, opacity: f64) -> Scene Builds a scene with one centered rounded rectangle in the given color and opacity.
fn build_shadow_scene(width: u16, height: u16, color: Color, corner_radius: f32, std_dev: f32) -> Scene Builds a scene with a blurred rounded-rect shadow in the given color.
fn build_tree_scene(tree: &Tree, root: NodeId, width: u16, height: u16, resources: &mut Resources, text: &mut TextRenderer, geometry: &mut GeometryCache) -> Scene Paints the whole node tree from the root into a scene.
fn build_tree_scene_in(tree: &Tree, root: NodeId, width: u16, height: u16, rects: &[Rect], resources: &mut Resources, text: &mut TextRenderer, geometry: &mut GeometryCache) -> Scene Paints only what falls inside the given rects, for a partial redraw.
fn build_tree_scene_shaded(tree: &Tree, root: NodeId, width: u16, height: u16, rects: Option<&[Rect]>, shaders: &ShaderTextures, resources: &mut Resources, text: &mut TextRenderer, geometry: &mut GeometryCache) -> Scene Paints the tree, drawing nodes that have a shader from that shader's texture.
fn register_font(data: Vec<u8>) -> Result<Vec<String>, NoFontFacesFound> Registers font file bytes for all text renderers and returns the family names found.
fn with_opacity(color: Color, opacity: f64) -> Color Returns the color with its alpha multiplied by the given opacity.

Constants (engine-render)

Constant Type Description
INITIAL_COLOR Color The purple used as the starting fill color of the demo scene.
MAX_IMAGE_DIMENSION u32 The largest image side, in pixels, that is uploaded to the GPU.
MAX_RECTS usize The most damage rects kept before the closest pairs are merged.
MONOSPACE_FONT_FAMILY &str The family name of the bundled monospace font.

engine-platform

The winit event loop, window creation, platform input translation and the accessibility adapter.

EventLoopWaker

struct. A thread-safe handle that background code uses to wake or steer the event loop.

Implements: Clone

Events: wakes an idle loop with a platform event from any thread (wake)

Method Description
fn close_window(&self, id: WindowId) Asks the loop to close a window as if the user had, letting the app veto it.
fn report_size(&self, id: WindowId) Asks the loop to report a window's current size as a resize event on its next turn.
fn wake(&self) Requests a redraw of every open window, doing nothing if the loop has exited.

IdleHooks

struct. Callbacks run around the loop's wait so the host can release a lock while idle.

Field Type Description
release Box<dyn FnMut()> Called just before the loop goes to wait, to release the host's lock.
reacquire Box<dyn FnMut()> Called right after the loop wakes, to take the host's lock back.

WindowConfig

struct. The title, size, frame limit and creation options for a window.

Field Type Description
title String The window title.
width u32 The initial inner width in pixels.
height u32 The initial inner height in pixels.
max_frames Option<u32> Closes the window after this many redraws, which keeps demos and tests self-ending.
options WindowOptions How the window is made beyond its title and size.

WindowOpener

struct. A handle for asking the loop to open new windows, valid only inside the setup callback.

Events: asks the loop to open a window (open_window)

Method Description
fn open_window(&self, request: WindowRequest) Asks the event loop to open a new window.

WindowOptions

struct. A window's creation settings beyond its title and size.

Implements: Clone, Debug, PartialEq, Default

Field Type Description
decorations bool Whether the OS draws the window's title bar and borders.
maximized bool Whether the window opens maximized.
fullscreen bool Whether the window opens fullscreen, borderless on its monitor.
min_size Option<(f64, f64)> The smallest inner size, (width, height) in logical pixels, the user can resize the window to.
icon Option<(Vec<u8>, u32, u32)> The window icon as straight-alpha RGBA8 bytes with width and height.

WindowRequest

struct. A request to open one window, tagged with a token the app can match later.

Field Type Description
config WindowConfig The configuration for the window to open.
token u64 A caller-chosen number passed back when the window is created.

WindowLifecycle

enum. A change in a window's life that the loop reports to the app.

Implements: Clone, Copy, Debug, PartialEq, Eq

Event type. A window lifecycle change the platform reports.

Event Payload Description
CloseRequested The user asked to close the window, and the app may keep it open.
Closed The window is closing now.

Functions (engine-platform)

Function Description
fn double_click_time() -> Duration Returns the longest gap between two presses that still counts as a double-click.
fn platform_name(window: Option<&Window>) -> &'static str Returns the windowing system the window runs on, such as wayland, x11, windows or macos.
fn run_windowed<F, A>(config: WindowConfig, on_frame: F, build_access_update: A) -> Result<(), EventLoopError> Runs an event loop for a single window that calls a per-frame callback.
fn run_windowed_multi<C, F, A, S, N, X, L>(on_window_created: C, on_frame: F, build_access_update: A, on_input: N, on_access_action: X, on_lifecycle: L, setup: S) -> Result<(), EventLoopError> Runs an event loop that manages any number of windows through callbacks.
fn run_windowed_multi_with<C, F, A, S, N, X, L>(on_window_created: C, on_frame: F, build_access_update: A, on_input: N, on_access_action: X, on_lifecycle: L, setup: S, idle: Option<IdleHooks>) -> Result<(), EventLoopError> Runs the multi-window loop with optional hooks around its idle wait.