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, plus the public items of engine-platform's layer, layer_config and outputs modules.
| 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.
AccessExtra¶
struct. How a range value is said, and the nodes a node is described by and controls.
Implements: Clone, Debug, Default
| Field | Type | Description |
|---|---|---|
value_text |
Option<String> |
|
described_by |
Vec<NodeId> |
|
controls |
Vec<NodeId> |
|
active_descendant |
Option<NodeId> |
TRE-REQ-023: the node a screen reader treats as this one's current item while keyboard focus stays here (a text field and the row selected in the… |
AccessLine¶
struct. One shaped line of a text node, for its accessibility runs (0.5.4, #153).
Implements: Clone, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
start |
usize |
The bytes of the node's content on this line. |
end |
usize |
|
x0 |
f64 |
The line's box in the node's own coordinates. |
y0 |
f64 |
|
x1 |
f64 |
|
y1 |
f64 |
|
chars |
Vec<(f32, f32)> |
For each character of content[start..end]: its left edge, measured from the line's x0, and its advance. |
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<Toggled> |
Whether a checkable node is checked. |
selected |
Option<bool> |
Whether a selectable node is selected. |
expanded |
Option<bool> |
Whether an expandable node is open. |
pressed |
Option<Toggled> |
A toggle button's state; wins over checked when set. |
invalid |
bool |
The value is not acceptable. |
busy |
bool |
The node is updating. |
current |
Option<AriaCurrent> |
The current item of a set (a page, a step...). |
extra |
Option<Box<AccessExtra>> |
The rarely set, larger accessibility data, boxed so a node that has none pays one pointer. |
set_size |
Option<usize> |
How many items the set this node holds. |
pos_in_set |
Option<usize> |
This node's 1-based place in its set (AccessKit's is zero-based, the tree builder subtracts one). |
orientation |
Option<Orientation> |
The axis of a slider, scrollbar, separator, toolbar... |
modal |
bool |
A dialog that blocks the content behind it. |
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 edit_extra(&mut self, change: impl FnOnce(&mut AccessExtra)) |
Changes the boxed extras; the box is dropped again when nothing is left in it. |
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. |
AnchorBox¶
struct. An anchor's box in window space (after its transform), the rectangle a node is placed against.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
x |
f64 |
|
y |
f64 |
|
w |
f64 |
|
h |
f64 |
Anchored¶
struct. A node placed against another node, wherever that is in the tree: after each layout the tree puts this node's box at placement of the anchor's…
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
anchor |
NodeId |
|
placement |
Placement |
|
offset |
(f64, f64) |
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<Box<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 set_now(&mut self, value: T) |
Sets the value outright, ending a running animation as cancelled. |
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. |
Arrow¶
struct. An arrow button at one end of a lane.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
rect |
Rect |
The painted square. |
hit |
Rect |
Where a press takes it: as long as the square, as wide as the hit strip. |
CalcLen¶
struct. A size that mixes units, percent of the parent's box plus px pixels: width="calc(100% - 16)" is percent: 1.0, px: -16.0.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
percent |
f32 |
A fraction: 1.0 is 100%. |
px |
f32 |
| Method | Description |
|---|---|
fn resolve(self, basis: f32) -> f32 |
The size when the percentage's base is basis pixels, never negative. |
CalcSize¶
struct. The sides of a node whose size is a CalcLen.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
width |
Option<CalcLen> |
|
height |
Option<CalcLen> |
| Method | Description |
|---|---|
fn any(self) -> bool |
Whether either side is a calc size. |
CancelledGesture¶
struct. What Tree::cancel_gesture ended.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
holder |
Option<NodeId> |
The node that held the pointer capture. |
pressed |
Option<NodeId> |
The node the press was on. |
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. |
Edges¶
struct. A distance for each side of a window, in layout pixels (viewport_margin).
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
left |
f64 |
|
top |
f64 |
|
right |
f64 |
|
bottom |
f64 |
| Method | Description |
|---|---|
fn all(distance: f64) -> Self |
The same distance on every side. |
FitContent¶
struct. Which sides of a text node are the size of its text, written width="fit-content" and height="fit-content".
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
width |
bool |
|
height |
bool |
| Method | Description |
|---|---|
fn any(self) -> bool |
Whether either side fits the text. |
Gesture¶
struct. A recognized gesture.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
kind |
GestureKind |
|
phase |
GesturePhase |
|
position |
Point |
The touch (or, for a pinch, the midpoint of the two) now. |
origin |
Point |
Where it started: the touch's first position, or the pinch's first midpoint. |
delta |
Vec2 |
How far position moved since the last event of this gesture. |
total |
Vec2 |
How far it has moved in all, from origin. |
scale |
f64 |
A pinch's distance between fingers now over what it was at the start (1.0 for any other gesture). |
scale_delta |
f64 |
A pinch's scale over the last event's: the step to apply (1.0 otherwise). |
velocity |
Vec2 |
A pan's speed when its fingers lift, in pixels per second; zero otherwise. |
rotation |
f64 |
A rotation's angle so far, in radians from where the fingers started, positive clockwise on the screen (y down); zero for any other gesture. |
rotation_delta |
f64 |
A rotation's step since the last event, in radians. |
GestureConfig¶
struct. How far, and how long, a touch has to go before it is one gesture and not another.
Implements: Clone, Copy, Debug, PartialEq, Default
| Field | Type | Description |
|---|---|---|
slop |
f64 |
A touch that stays within this distance of where it started can still be a tap or a long press; beyond it, it is a pan. |
long_press |
Duration |
How long a touch held in place becomes a long press. |
tap_max |
Duration |
A touch released within this is a tap; held longer (and not a long press because it moved a little) it is nothing. |
double_tap_gap |
Duration |
A second tap within this time and double_tap_distance of the first is a double tap. |
double_tap_distance |
f64 |
|
rotate_slop |
f64 |
How far two fingers have to turn, in radians, before it is a rotation (about 7 degrees): less is the wobble of a pinch. |
swipe_velocity |
f64 |
A pan is a swipe if it lifts at least this fast, in pixels a second, ... |
swipe_distance |
f64 |
... and has travelled at least this far, in pixels. |
GestureRecognizer¶
struct. Recognizes tap, long press, pan and pinch from touches.
Implements: Default
| Method | Description |
|---|---|
fn config(&self) -> GestureConfig |
Every threshold the recognizer uses. |
fn deadline(&self) -> Option<Instant> |
When poll next has something to say, if a touch is waiting to become a long press. |
fn is_active(&self) -> bool |
Whether any finger is down: the caller should keep polling while so. |
fn new(config: GestureConfig) -> Self |
|
fn poll(&mut self, now: Instant) -> Vec<Gesture> |
The time passing: a touch held in place for the long-press time becomes a long press. |
fn set_config(&mut self, config: GestureConfig) |
Replaces every threshold. |
fn set_slop(&mut self, slop: f64) |
The distance, in layout pixels, a touch may wander and still be a tap or a long press. |
fn slop(&self) -> f64 |
|
fn touch(&mut self, id: u64, phase: TouchPhase, position: Point, now: Instant) -> Vec<Gesture> |
Feeds one touch at now; returns the gestures it completes or advances. |
Gradient¶
struct. A gradient fill: a shape and at least two stops in increasing order, the ramp run repeat times across the shape's span.
Implements: Clone, Debug, PartialEq, Interpolate
| Method | Description |
|---|---|
fn animates_to(&self, other: &Self) -> bool |
Whether self can animate smoothly to other: the same kind of shape and the same number of stops. |
fn new(shape: GradientShape, stops: Vec<GradientStop>) -> Result<Self, String> |
A gradient of shape through stops. |
fn repeat(&self) -> f64 |
How many times the ramp runs across the span; 1.0 is one pass. |
fn resolve(&self, w: f64, h: f64) -> (Gradient, Affine) |
The gradient as peniko draws it for a box of w x h, in the box's own coordinates, and the transform to paint it under (the identity, except… |
fn shape(&self) -> &GradientShape |
|
fn solid(&self, color: Color) -> Self |
This gradient's shape and stop positions, every stop color: what a solid fill fades from or to. |
fn spread(&self) -> Spread |
|
fn stops(&self) -> &[GradientStop] |
|
fn with_repeat(self, repeat: f64, spread: Spread) -> Result<Self, String> |
This gradient with its ramp run repeat times across the span (a linear gradient's line, a radial one's radius, a sweep's full turn), spread… |
GradientStop¶
struct. A colour at a position along the gradient, offset in 0.0..=1.0.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
offset |
f32 |
|
color |
Color |
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. |
sampling |
ImageSampling |
How the pixels are sampled when the image is scaled. |
| 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. |
KeyChord¶
struct. A keyboard chord — the modifiers held plus one key — such as a terminal's escape_chord.
Implements: Clone, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
modifiers |
Modifiers |
|
key |
String |
The key's lowercase name, as InputEvent::Key names it ("escape", "f10", "k"). |
| Method | Description |
|---|---|
fn matches(&self, key: &str, held: Modifiers) -> bool |
Whether key (an InputEvent::Key name) pressed with exactly held is this chord. |
fn name(&self) -> String |
The chord as parse reads it, modifiers in the order ctrl, shift, alt, meta. |
fn parse(text: &str) -> Result<KeyChord, String> |
Parses ctrl+shift+escape. |
LayerDefaults¶
struct. The window-wide policy a layer follows when it sets none of its own (Window.layer_viewport_margin, Window.layer_flip_threshold).
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
viewport_margin |
Edges |
|
flip_threshold |
f64 |
LayoutAnim¶
struct. A running (or just finished) animation of one layout property.
| Field | Type | Description |
|---|---|---|
prop |
LayoutProp |
|
value |
Animated<f64> |
ListKey¶
struct. What Tree::list_selection_key did with a key.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
consumed |
bool |
The key was the list's: it must not also scroll the list, and a Space must not also click the row. |
focus |
Option<(Option<NodeId>, Option<NodeId>)> |
Focus moved from the first node to the second. |
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 |
Option<bool> |
Whether this node itself claims a hit in Tree::hit_test_at. |
sticky |
Option<f64> |
Some(inset) makes the node stick: inside a scrolling ancestor it stays inset pixels from the scroller's start edge once scrolled there, until… |
snap_align |
Option<SnapAlign> |
How this item lines up when its scroll view snaps; None takes the view's own scroll_snap. |
layout_anims |
Option<Box<Vec<LayoutAnim>>> |
Running animations of this node's layout properties, written into layout_style each tick. |
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. |
fit_content |
FitContent |
Which sides of a text node are the size of its text. |
calc_size |
CalcSize |
Which sides are a calc size. |
anchored |
Option<Box<Anchored>> |
Some places the node against another node in the tree. |
item_selectable |
bool |
item_selectable — whether the node, as a child of a container with a selection_mode, can be chosen. |
selection |
Option<Box<SelectionState>> |
Which children of this box, container or scroll view are chosen (selection_mode, selection, ...); the keys are the children's indices. |
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. |
origin |
(f64, f64) |
The point scale and rotation turn about, as fractions of the box ((0.5, 0.5), the centre, by default). |
| Method | Description |
|---|---|
fn to_affine(&self, width: f64, height: f64) -> Affine |
Returns the current transform for a box of the given size. |
Outline¶
struct. An outline ready to draw: the style in force, its colour resolved.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
width |
f64 |
|
offset |
f64 |
|
color |
Color |
|
gap_color |
Option<Color> |
|
radius |
Option<f64> |
| Method | Description |
|---|---|
fn inner_radii(&self, corners: [f64; 4]) -> [f64; 4] |
The radii [top_left, top_right, bottom_right, bottom_left] of the ring's inner edge for a box whose corners have corners: the box's own radius… |
fn outer_radii(&self, corners: [f64; 4]) -> [f64; 4] |
The radii of the ring's outer edge: the inner ones grown by width, so the two edges stay concentric. |
OutlineStyle¶
struct. One outline, as its properties say it.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
width |
f64 |
The ring's thickness in the node's own pixels. |
offset |
f64 |
The gap between the border box and the ring's inner edge. |
color |
Option<Color> |
None: the window scheme's OUTLINE_ROLE. |
gap_color |
Option<Color> |
Fills the gap between the box and the ring when set; None leaves it transparent. |
radius |
Option<f64> |
The corner radius of the ring's inner edge; None follows the node's own corner radius plus offset, so the ring stays concentric with the box. |
Outlines¶
struct. A node's two outline styles.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
always |
OutlineStyle |
Always shown (outline_*). |
focus |
OutlineStyle |
Shown instead of always while the node has visible keyboard focus (focus_outline_*). |
| Method | Description |
|---|---|
fn is_none(&self) -> bool |
Whether neither style draws anything. |
fn reach(&self) -> f64 |
How far past the border box the ring can reach, in either state: what a node's painted extent grows by. |
fn resolve(&self, focus_shown: bool, scheme: &SchemeColors) -> Option<Outline> |
The outline to draw now. |
OverlayMeta¶
struct. The settings of one open overlay or layer.
Implements: Clone, Copy, Debug, Default, PartialEq
| 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. |
offset |
(f64, f64) |
Moves the point of the anchor the layer attaches to, in the anchor's own coordinates (a scaled anchor scales it). |
no_flip |
bool |
true never flips the layer to the other side. |
no_shift |
bool |
true never moves the layer to keep it inside the window. |
align |
Align |
Which edge of the anchor the layer lines up with. |
viewport_margin |
Option<Edges> |
The distance the layer keeps from each window edge when it flips or shifts; None follows Tree::layer_defaults. |
flip_threshold |
Option<f64> |
The extra free space the preferred side needs before the layer stays on it; None follows Tree::layer_defaults. |
restore_focus |
Option<NodeId> |
The node to give focus back to when the overlay closes. |
Overrides¶
struct. What the user set: one slot per property, None for the default.
Implements: Clone, Copy, Debug, PartialEq, Default
| Method | Description |
|---|---|
fn choice(&self, prop: Prop) -> Option<u8> |
|
fn colour(&self, prop: Prop) -> Option<Color> |
|
fn easing(&self, prop: Prop) -> Option<Easing> |
|
fn flag(&self, prop: Prop) -> Option<bool> |
|
fn get(&self, prop: Prop) -> Option<Value> |
What is set for prop. |
fn number(&self, prop: Prop) -> Option<f64> |
|
fn pair(&self, prop: Prop) -> Option<(f64, f64)> |
|
fn set(&mut self, prop: Prop, value: Option<Value>) -> bool |
Sets prop to value, or back to its default with None. |
fn set_number(&mut self, prop: Prop, value: Option<f64>) -> bool |
set with a number; None unsets. |
PaintProperties¶
struct. The paint state every node has, whatever its kind.
| Field | Type | Description |
|---|---|---|
mask |
Option<Box<Mask>> |
The shape the node and its subtree are clipped to. |
scheme_fill |
bool |
A text node's glyph colour is the window's scheme (on_surface), resolved at paint time, while this is true; background is then not read. |
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. |
corner_concave |
[bool; 4] |
Which corners curve inward (corner_style), in the order top-left, top-right, bottom-right, bottom-left. |
hit_outline |
Option<Arc<BezPath>> |
A shape, in the node's own pixels, that pointer hits and a layer window's input region follow in place of the box (hit_path). |
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. |
gradient |
Option<Box<Animated<Gradient>>> |
A gradient painted in place of background's colour, which stays what a fill set back to a colour starts from. |
border_gradient |
Option<Box<Gradient>> |
A gradient painted in place of border_color, over the node's bounds (a path's stroke: over the stroke's own bounds). |
blur |
Animated<f64> |
A Gaussian blur of the node and its subtree, as a standard deviation in the node's own pixels. |
blend |
Blend |
How the node and its subtree mix with what is behind. |
backdrop_blur |
Animated<f64> |
Frosted glass — a Gaussian blur, standard deviation in the node's own pixels, of everything painted behind the node, shown inside its box. |
state_layer |
Option<Box<StateLayer>> |
The hover, pressed and focus overlays the engine draws and fades over the node's fill and border, under its children (hover_layer… |
outline |
Option<Box<Outlines>> |
The ring drawn outside the box (outline_*, focus_outline_*). |
| 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. |
1 |
MorphMode |
| Method | Description |
|---|---|
fn from_svg(data: &str) -> Result<Self, String> |
Parses SVG path data into a path, or returns an error message. |
fn same_structure(&self, other: &Self) -> bool |
Whether the two paths have the same sequence of commands (each M, L, Q, C, Z in the same place; an arc is already curves), so a structure… |
fn to_svg(&self) -> String |
Returns the path as SVG path data. |
fn with_mode(self, mode: MorphMode) -> Self |
The same data, morphed into by mode. |
PathState¶
struct. The state of a path node: shape, view box and stroke trim.
| Field | Type | Description |
|---|---|---|
data |
Animated<PathData> |
The path geometry, animatable. |
hit_shape |
HitShape |
Which part of the node takes pointer events and counts in an input_region="auto". |
morph |
MorphMode |
How an animation of data morphs (morph). |
template |
Option<PathTemplate> |
When set, data is this template filled in with params, and is evaluated again whenever a parameter moves. |
params |
Vec<(String, Animated<f64>)> |
The named numbers a template reads, each animatable. |
view_box |
Option<Rect> |
The region of path space fitted into the node's box; None uses pixels. |
stroke_style |
StrokeStyle |
The stroke's caps, joins, miter limit and dashes. |
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 param(&self, name: &str) -> Option<f64> |
A parameter's current value. |
fn reevaluate(&mut self) -> Result<(), String> |
Fills the template in with the parameters as they are now and makes the result the node's data. |
fn set_param(&mut self, name: &str, value: f64) |
Sets a parameter outright (ending its animation), adding it if new. |
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool |
Advances every animated field; true while any is still running. |
PathTemplate¶
struct. Path data with holes.
Implements: Clone, Debug, PartialEq
| Method | Description |
|---|---|
fn evaluate(&self, lookup: &dyn Fn(&str) -> Option<f64>) -> Result<PathData, String> |
The path data with every hole replaced by its value under lookup. |
fn is_template(text: &str) -> bool |
Whether text has a hole, so is meant as a template and not as plain path data. |
fn names(&self) -> Vec<&str> |
The parameter names it uses, each once, in order of first use. |
fn parse(text: &str) -> Result<Self, String> |
Parses a template: every { closes with a } and holds an expression. |
fn source(&self) -> &str |
The template as written. |
PlaceInput¶
struct. Everything place needs to put a layer against its anchor.
Implements: Clone, Copy, Debug
| Field | Type | Description |
|---|---|---|
window |
(f64, f64) |
The window's size. |
target |
AnchorBox |
The anchor's box in window space. |
size |
(f64, f64) |
The layer's size. |
offset |
(f64, f64) |
The anchor offset, already in window space. |
preferred |
Placement |
|
align |
Align |
|
flip |
bool |
The layer may go to the opposite side when the preferred one lacks room. |
shift |
bool |
The layer is moved to keep inside the window (less the margin). |
margin |
Edges |
The distance a flipped or shifted layer keeps from each window edge. |
flip_threshold |
f64 |
The extra free space the preferred side must have beyond the layer's own size before the layer stays on it. |
RangeSet¶
struct. A set of usize kept as sorted, disjoint, non-adjacent, non-empty ranges.
Implements: Clone, Debug, Default, PartialEq, Eq
| Method | Description |
|---|---|
fn clear(&mut self) |
|
fn clip(&mut self, len: usize) |
Takes out every index from len on. |
fn contains(&self, i: usize) -> bool |
|
fn first(&self) -> Option<usize> |
|
fn from_indices(items: impl IntoIterator<Item = usize>) -> Self |
The set of every index in items, each once, however they are ordered. |
fn insert(&mut self, range: Range<usize>) |
Adds every index of range. |
fn insert_except(&mut self, range: Range<usize>, except: &RangeSet) |
Adds every index of range that is not in except. |
fn is_empty(&self) -> bool |
|
fn iter(&self) -> impl Iterator<Item = usize> + '_ |
Every index, ascending. |
fn len(&self) -> usize |
How many indices the set holds. |
fn new() -> Self |
|
fn ranges(&self) -> &[Range<usize>] |
The ranges, ascending. |
fn remove(&mut self, range: Range<usize>) |
Takes out every index of range. |
fn subtract(&mut self, other: &RangeSet) |
Takes out every index of other. |
fn toggle(&mut self, i: usize) -> bool |
Adds i if it is not in the set and takes it out if it is; whether it is in now. |
ResolvedPalette¶
struct. A TerminalPalette with the scheme's colors filled in: what a terminal paints with.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
ansi |
[Color; 16] |
|
foreground |
Color |
|
background |
Color |
|
cursor |
Color |
|
selection |
Color |
| Method | Description |
|---|---|
fn background_of(&self, color: CellColor) -> Color |
|
fn foreground_of(&self, color: CellColor) -> Color |
|
fn indexed(&self, index: u8) -> Color |
One of the 256 indexed colors: the palette's 16, then the 6x6x6 color cube, then the 24-step grey ramp. |
RowAnswer¶
struct. The answer to a RowQuery: a byte offset in content, the x the caret was held at (for the next vertical move), and whether it moved to another…
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
offset |
usize |
|
goal_x |
f32 |
|
moved |
bool |
SchemeColors¶
struct. The resolved role table of one window: a baseline with overrides applied.
Implements: Clone, Debug, PartialEq, Default
| Method | Description |
|---|---|
fn baseline(scheme: Scheme) -> Self |
The published baseline of scheme, no overrides. |
fn caret(&self) -> Color |
A text input's caret with no caret_color, and a terminal's cursor. |
fn get(&self, role: Role) -> Color |
|
fn iter(&self) -> impl Iterator<Item = (Role, Color)> + '_ |
Every role with its colour, in the order of Role::ALL. |
fn placeholder(&self) -> Color |
A text input's placeholder with no placeholder_fill. |
fn scheme(&self) -> Scheme |
Which baseline this table started from. |
fn scrollbar_thumb(&self) -> Color |
A scroll view's thumb with no scrollbar_fill. |
fn selection(&self) -> Color |
The highlight behind selected text, with no selection_fill. |
fn set(&mut self, role: Role, color: Color) |
|
fn text(&self) -> Color |
The colour of the text a node with no fill paints. |
ScrollChange¶
struct. A scroll view's offset changed (Tree::take_scroll_changes): the main-axis offset before (old) and after (new), and where the content is now…
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
view |
NodeId |
|
old |
f64 |
|
new |
f64 |
|
x |
f64 |
|
y |
f64 |
ScrollViewState¶
struct. The state of a scroll view: offset, direction and scrollbar look.
Implements: Scroller
| Field | Type | Description |
|---|---|---|
scroll |
Animated<f64> |
The scroll offset in pixels, animatable. |
scroll_x |
Animated<f64> |
The horizontal offset of a both view (scroll_offset_x). |
snap |
Option<SnapAlign> |
When set, the view settles on the item nearest the alignment once the user stops scrolling it. |
horizontal |
bool |
Whether the view scrolls horizontally instead of vertically. |
both |
bool |
The view scrolls on both axes, with the spec scrollbar (see scrollbar.rs). |
bar |
Box<ScrollbarState> |
The scrollbar and scroll feel of the view. |
reported |
f64 |
The offset last reported to the app as a scroll event. |
reported_x |
f64 |
The same for scroll_x. |
| Method | Description |
|---|---|
fn animated(&mut self, axis: ScrollAxis) -> &mut Animated<f64> |
The animated offset along axis. |
fn axes(&self) -> &'static [ScrollAxis] |
The axes this view scrolls along, vertical first. |
fn main_axis(&self) -> ScrollAxis |
The axis scroll_offset is the offset of. |
fn near_insets(&self, size: (f64, f64), content: (f64, f64)) -> (f64, f64) |
The room the gutter takes at the near edge (left, top) of the view, (x, y): what the other axis' bar reserves there when it sits on that edge… |
fn new(horizontal: bool) -> Self |
Creates scroll state, horizontal or vertical. |
fn offset(&self, axis: ScrollAxis) -> f64 |
Where the content is scrolled to along axis: 0 for an axis the view does not scroll along. |
fn offsets(&self) -> (f64, f64) |
(x, y) — how far the content is scrolled right and down. |
fn offsets_at(&self, main: f64, x: f64) -> (f64, f64) |
offsets as they would be with the main offset at main and scroll_x at x. |
fn orientation(&self) -> ScrollOrientation |
|
fn overflows(&self, size: (f64, f64), content: (f64, f64)) -> [bool; 2] |
Which axes of this view overflow: those whose content is longer than the viewport, as measured. |
fn set_orientation(&mut self, orientation: ScrollOrientation) |
|
fn thumb_geometry(&self, viewport_extent: f64, content_extent: f64) -> (f64, f64, f64) |
Returns the scrollbar track length, thumb length and thumb position. |
fn thumb_geometry_at(&self, viewport_extent: f64, content_extent: f64, offset: f64) -> (f64, f64, f64) |
thumb_geometry as it would be at scroll offset offset (0.5.4, #126: where the thumb was, for a frame that moved it). |
fn thumb_opacity(&self, axis: ScrollAxis) -> f64 |
The thumb's opacity now, off its emphasis level. |
ScrollbarMetrics¶
struct. The measures a scrollbar and the scroll feel are built from, resolved: what the user set, else the defaults of the scroller (Defaults).
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
thickness |
f64 |
Painted size across the axis. |
hit |
f64 |
Pointer-sensitive size across the axis, centred on the thumb. |
margin |
f64 |
Between thumb and view edge, and thumb end and lane end. |
min_length |
f64 |
The shortest thumb. |
gutter |
f64 |
Reserved at the edge of an axis that overflows (see reserved_gutter). |
corner |
f64 |
How much a lane stops short when the other axis has a bar too. |
radius |
f64 |
The thumb's (and track's) corner radius. |
along_slop |
f64 |
How far past the thumb's ends still grabs it. |
opacity_rest |
f64 |
|
opacity_hover |
f64 |
|
opacity_drag |
f64 |
|
track_opacity |
f64 |
Multiplies the track fill's alpha. |
edges |
[Edge; 2] |
The edge each bar sits on, by ScrollAxis::index. |
show |
Show |
|
hide_delay_ms |
f64 |
|
fade_in_ms |
f64 |
|
fade_out_ms |
f64 |
|
hover_delay_ms |
f64 |
|
fade_easing |
Easing |
|
gutter_reserve |
bool |
Whether the gutter is reserved (true) or the thumb overlays content. |
arrows |
Arrows |
|
arrow_step |
f64 |
|
lane_click |
LaneClick |
|
wheel_notch |
f64 |
|
key_line |
f64 |
|
page_fraction |
f64 |
|
smooth_ms |
f64 |
|
scroll_easing |
Easing |
|
page_delay_ms |
f64 |
|
page_repeat_ms |
f64 |
|
snap_settle_ms |
f64 |
How long a snapping view waits after its last input before it settles. |
snap_duration_ms |
f64 |
How long the settle takes (nothing under reduced motion). |
snap_easing |
Easing |
|
fling_tau_ms |
f64 |
The time constant of a fling's decay, milliseconds. |
fling_stop_speed |
f64 |
A fling ends at this speed, pixels a second. |
fling_min_speed |
f64 |
A flick slower than this does not coast, pixels a second. |
edge_scroll |
bool |
Whether a held gesture near the view's edge scrolls it. |
edge_scroll_band |
f64 |
How far in from the edge the scrolling starts, dp. |
edge_scroll_speed |
(f64, f64) |
Dp per frame at 60 Hz at the band's inner edge and at the edge. |
| Method | Description |
|---|---|
fn arrow_len(&self) -> f64 |
The length of one arrow button along the lane: none without arrows. |
fn edge(&self, axis: ScrollAxis) -> Edge |
The edge the bar of axis sits on. |
fn get(&self, prop: Prop) -> Option<Value> |
What property prop reads: the value in force, for every property that is not a colour (colours and the side names are what the user set… |
fn opacity(&self, level: f64) -> f64 |
The thumb's opacity at emphasis level (0 rest, 1 hover, 2 drag; in between while it fades). |
fn reserved_gutter(&self) -> f64 |
What the gutter reserves along the edge of an overflowing axis: nothing when scrollbar_gutter_reserve is off (the thumb overlays content) or no… |
fn resolve(o: &Overrides, d: Defaults) -> Self |
What overrides and the defaults d make of every measure. |
fn shows(&self, viewport: f64, content: f64) -> bool |
Whether show lets a bar show for the axis of a view of viewport over content along it: never for never, always for always, else when the… |
fn smooth(&self, reduced: bool) -> Duration |
How long a smooth scroll takes: nothing under reduced motion. |
fn snap_duration(&self, reduced: bool) -> Duration |
How long a snap settle takes: nothing under reduced motion (the spec's AC-SCB-17). |
fn thumbs(&self, axes: &[ScrollAxis], size: (f64, f64), content: (f64, f64), offsets: (f64, f64)) -> [Option<Thumb>; 2] |
The thumbs, [vertical, horizontal], of a view of size over content scrolled to offsets (all (x, y)): one for each of axes whose bar… |
ScrollbarState¶
struct. The state a scroll view and a virtual list share for their scrollbar: what the user set, and how emphasised and how visible each bar is.
Implements: Default
| Field | Type | Description |
|---|---|---|
settings |
Overrides |
What the user set (Prop); the rest are defaults (Defaults). |
level |
[Animated<f64>; 2] |
How emphasised each thumb is, [vertical, horizontal]: 0 at rest, 1 with the pointer over its hit area, 2 while dragged. |
shown |
Animated<f64> |
How visible the bars are, 0 to 1: 1 unless scrollbar_show is auto_hide and the bars have faded out. |
hovered |
[bool; 2] |
Which thumb the pointer is over, and since when. |
drag_anchor |
Option<(f64, f64)> |
Some((pointer_coord, scroll_at_start)), set the instant a thumb drag begins and cleared when it ends: a relative-delta anchor, so grabbing the… |
drag_axis |
ScrollAxis |
Which thumb the drag in progress holds. |
| Method | Description |
|---|---|
fn get(&self, prop: Prop, d: Defaults) -> Option<Value> |
What property prop reads: the value in force, except for a colour and a side, which read what was set (None: the default). |
fn metrics(&self, d: Defaults) -> ScrollbarMetrics |
The measures in force for a scroller with defaults d. |
fn new() -> Self |
|
fn set_hover(&mut self, axis: ScrollAxis, on: bool, now: Instant) |
The pointer moved on or off the thumb of axis. |
fn sync_levels(&mut self, d: Defaults, now: Instant, reduced: bool) -> bool |
Starts fading each thumb to the emphasis it should have (level), by scrollbar_fade_in_ms going up and scrollbar_fade_out_ms coming down… |
fn thumb_color(&self, m: &ScrollbarMetrics, axis: ScrollAxis, default_fill: Color) -> Color |
The thumb's colour for axis now: fill, fill_hover or fill_drag by how emphasised it is (default_fill when none is set), at that level's… |
fn tick(&mut self, d: Defaults, offsets: (f64, f64), now: Instant, reduced: bool, completed: &mut Vec<CompletionHandle>) -> bool |
Advances the bar to now: the emphasis fades, and auto_hide's visibility. |
fn track_color(&self, m: &ScrollbarMetrics) -> Option<Color> |
The track's colour now, None when no scrollbar_track_fill is set (a track-less bar, the default). |
SelectionChange¶
struct. A list's chosen set changed (Tree::take_selection_changes).
Implements: Clone, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
list |
NodeId |
|
selected |
RangeSet |
|
anchor |
Option<usize> |
|
source |
SelectionSource |
SelectionState¶
struct. The selection of a virtual list (its rows) or of a container (its children).
Implements: Clone, Debug, Default
| Field | Type | Description |
|---|---|---|
mode |
SelectionMode |
|
select_all_key |
bool |
select_all_key: whether Ctrl+A selects every selectable row. |
select_on_focus |
bool |
select_on_focus: whether moving focus by Up, Down, Home, End, Page Up or Page Down also chooses the row focus lands on. |
active |
Option<usize> |
The row the keyboard is on while focus is not in a row (the list itself holds it). |
pending_focus |
Option<usize> |
The row focus should go to when it is built (Tree::focus_list_row). |
announce |
Option<String> |
selection_announce: the polite announcement made after a change, {count} being how many items are chosen then. |
announce_ms |
u32 |
selection_announce_ms: how long after the last change the announcement is made, so that a burst of changes is announced once. |
| Method | Description |
|---|---|
fn anchor(&self) -> Option<usize> |
|
fn announce_waiting(&self) -> bool |
Whether an announcement is waiting for its time. |
fn clear(&mut self, source: SelectionSource) |
Chooses no row. |
fn clip(&mut self, count: usize, source: SelectionSource) |
The list has count rows now: nothing past them stays chosen, anchored or active. |
fn ensure_anchor(&mut self, row: usize) |
row is the anchor if there is none. |
fn first_selectable(&self, count: usize) -> Option<usize> |
|
fn fits(&self, count: usize) -> bool |
Whether nothing chosen, unselectable, anchored or active lies past count items (clip would change nothing). |
fn has_pending(&self) -> bool |
Whether a change is waiting to be reported. |
fn is_selectable(&self, i: usize, count: usize) -> bool |
Whether row i of count can be chosen. |
fn is_selected(&self, i: usize) -> bool |
|
fn last_selectable(&self, count: usize) -> Option<usize> |
|
fn nearest_selectable(&self, i: usize, count: usize, forward: bool) -> Option<usize> |
The selectable row nearest i going forward (or back). |
fn next_selectable(&self, from: usize, count: usize) -> Option<usize> |
The first selectable row after from. |
fn note_reported(&mut self, now: Instant) |
A change was reported at now: the announcement, if the state has one and chooses, is due announce_ms after it (a later change moves it back). |
fn prev_selectable(&self, from: usize) -> Option<usize> |
The last selectable row before from. |
fn select_all(&mut self, count: usize, source: SelectionSource) |
Chooses every selectable row. |
fn select_only(&mut self, i: usize, count: usize, source: SelectionSource) |
Chooses row i and nothing else; it is the anchor. |
fn select_range(&mut self, to: usize, count: usize, add: bool, source: SelectionSource) |
Chooses every selectable row from the anchor to to. |
fn selected(&self) -> &RangeSet |
|
fn set_announce(&mut self, template: Option<String>) |
selection_announce: the template (or none). |
fn set_mode(&mut self, mode: SelectionMode, source: SelectionSource) |
selection_mode: None clears the set, Single keeps one row (the anchor if chosen, else the first). |
fn set_selected(&mut self, set: RangeSet, source: SelectionSource) |
selection: the set becomes exactly set, which the caller has checked. |
fn set_unselectable(&mut self, set: RangeSet, source: SelectionSource) |
unselectable_keys: those rows can no longer be chosen, and leave the set. |
fn take_announcement(&mut self, now: Instant) -> Option<String> |
The announcement to make at now, if its time has come; it is made only once. |
fn take_pending(&mut self) -> Option<SelectionSource> |
The change since the last call, if there is one, and what made it. |
fn toggle(&mut self, i: usize, count: usize, keep_anchor_off: bool, source: SelectionSource) |
Flips row i. |
fn unselectable(&self) -> &RangeSet |
Shader¶
struct. A validated WGSL shader with its uniforms, inputs and mode.
Implements: Debug
| Method | Description |
|---|---|
fn animate_uniform(self, name: &str, to: UniformValue, duration: Duration, curve: MotionCurve) -> Result<(), ShaderError> |
Moves uniform name to to over duration along curve, from where it is now, like a node's animate: asking again retargets from the current… |
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: tess_re's prelude, then the app's source. |
fn inputs(&self) -> &[(String, NodeId)] |
The named inputs, in the order their bindings are numbered. |
fn is_animating(&self) -> bool |
Whether a uniform animation is running or waiting to start. |
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. |
StateHolds¶
struct. Which of the three states hold for a node right now.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
hovered |
bool |
|
pressed |
bool |
|
focused |
bool |
Focus that shows a layer: the node has focus and either the focus is visible (keyboard or assistive technology) or the node asked for the layer on… |
StateLayer¶
struct. A node's state layers and the fade between them.
Implements: Default
| Field | Type | Description |
|---|---|---|
hover |
Option<Color> |
Drawn while the pointer is over the node or a descendant. |
pressed |
Option<Color> |
Drawn while a primary press that started on the node or a descendant is held. |
focus |
Option<Color> |
Drawn while the node has keyboard focus (see focus_any_modality). |
focus_any_modality |
bool |
Also draw focus when focus came from a pointer press (a text input). |
ms |
f64 |
How long a change of layer takes. |
easing |
Easing |
The curve of that change (the shared one, as with ms). |
hover_ms |
Option<f64> |
hover_layer_ms: None falls back to ms. |
pressed_ms |
Option<f64> |
pressed_layer_ms: None falls back to ms. |
focus_ms |
Option<f64> |
focus_layer_ms: None falls back to ms. |
hover_easing |
Option<Easing> |
hover_layer_easing: None falls back to easing. |
pressed_easing |
Option<Easing> |
pressed_layer_easing: None falls back to easing. |
focus_easing |
Option<Easing> |
focus_layer_easing: None falls back to easing. |
active |
Option<LayerState> |
The state whose colour shown is fading to, or from when it is fading out: the state last entered. |
shown |
Animated<Color> |
What is drawn now: the colour of the layer in force, fading in or out. |
| Method | Description |
|---|---|
fn sync(&mut self, target: Option<(LayerState, Color)>, now: Instant, reduced: bool) -> bool |
Starts the fade to target (None: nothing). |
fn target(&self, holds: StateHolds) -> Option<(LayerState, Color)> |
The layer that applies when holds, by the precedence pressed, focus, hover: the first whose state holds and that has a colour. |
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool |
Advances the fade; whether it is still running. |
fn timing(&self, state: LayerState) -> (f64, Easing) |
The duration (ms) and easing of state's fades: its own override, else the shared pair. |
fn visible(&self) -> Option<Color> |
The colour to draw now, if any. |
StrokeStyle¶
struct. How a path node's stroke is drawn beyond its width and colour: the line caps, the joins, the miter limit and the dash pattern.
Implements: Clone, Debug, PartialEq, Default
| Field | Type | Description |
|---|---|---|
cap |
Cap |
|
join |
Join |
|
miter_limit |
f64 |
How far a miter join may reach, as a multiple of half the width, before it is bevelled (the SVG stroke-miterlimit; at least 1). |
dash |
Vec<f64> |
Alternating on and off lengths in pixels; empty draws a solid line. |
dash_offset |
f64 |
How far into the pattern the stroke starts, in pixels. |
| Method | Description |
|---|---|
fn cap_name(cap: Cap) -> &'static str |
|
fn join_name(join: Join) -> &'static str |
|
fn parse_cap(name: &str) -> Option<Cap> |
The cap named name (butt, round, square). |
fn parse_join(name: &str) -> Option<Join> |
The join named name (miter, round, bevel). |
fn reach(&self, width: f64) -> f64 |
How far a stroke of width can reach from its centre line: half the width, more for a square cap's corners and a miter join's tips. |
fn stroke(&self, width: f64) -> Stroke |
The stroke of width in this style. |
SvgBitmap¶
struct. Pixels the caller decoded, straight-alpha RGBA8.
Implements: Debug
| Field | Type | Description |
|---|---|---|
image |
ImageData |
|
id |
u64 |
Unique to this bitmap: what the renderer keys its GPU texture by. |
| Method | Description |
|---|---|
fn new(rgba: Vec<u8>, width: u32, height: u32) -> Self |
SvgClip¶
struct. A clip path, already flattened to one outline in the clipped group's coordinates.
Implements: Debug
| Field | Type | Description |
|---|---|---|
path |
BezPath |
|
even_odd |
bool |
|
parent |
Option<Box<SvgClip>> |
The clip this one is itself clipped by. |
SvgDocument¶
struct. A parsed SVG document, ready to paint.
Implements: Debug
| Field | Type | Description |
|---|---|---|
width |
f64 |
The document's own size (width x height, or its viewBox's), which fits into the node's box. |
height |
f64 |
|
root |
SvgGroup |
|
revision |
u64 |
Unique per parse: the damage tracker's stand-in for hashing the whole scene. |
has_text |
bool |
Whether the document has text, so a change of fonts changes it. |
| Method | Description |
|---|---|
fn empty() -> Arc<Self> |
A document that draws nothing: what a node has until it is given one. |
fn fit(&self, w: f64, h: f64) -> Affine |
Uniformly scales and centres the document into a w x h box (SVG's default xMidYMid meet). |
fn parse(data: &[u8], fonts: &SvgFonts) -> Result<Arc<Self>, String> |
Parses an SVG (or gzip-compressed SVGZ) document, shaping its text with fonts. |
fn parse_full(data: &[u8], fonts: &SvgFonts, color: Option<Color>, images: &SvgImages) -> Result<Arc<Self>, String> |
parse_tinted, with the raster images the document refers to by href, already decoded by the caller (the engine decodes no image formats). |
fn parse_tinted(data: &[u8], fonts: &SvgFonts, color: Option<Color>) -> Result<Arc<Self>, String> |
parse, with currentColor resolving to color wherever the document doesn't set its own color on the root element. |
SvgFill¶
struct.
Implements: Debug
| Field | Type | Description |
|---|---|---|
paint |
SvgPaint |
|
even_odd |
bool |
SvgFonts¶
struct. The font files an SVG's text is shaped with, loaded once and shared by every parse.
Implements: Clone
| Method | Description |
|---|---|
fn new(files: &[Arc<Vec<u8>>], system_fonts: bool) -> Self |
system_fonts adds the machine's installed fonts to files. |
fn none() -> Self |
No fonts: text in a document draws nothing. |
SvgGroup¶
struct.
Implements: Debug
| Field | Type | Description |
|---|---|---|
transform |
Affine |
|
opacity |
f32 |
|
clip |
Option<SvgClip> |
|
blur |
Option<f32> |
A Gaussian blur's standard deviation, in the group's own units: the one filter drawn. |
shadow |
Option<Box<SvgShadow>> |
A drop shadow under the group: the filter's other drawable form. |
mask |
Option<Box<SvgMask>> |
The mask the group is drawn through. |
children |
Vec<SvgNode> |
SvgImage¶
struct. A raster image, drawn into a width x height box at the origin.
Implements: Debug
| Field | Type | Description |
|---|---|---|
bitmap |
Arc<SvgBitmap> |
|
width |
f64 |
|
height |
f64 |
SvgImages¶
struct. The images a document refers to, by the href it writes them under.
Implements: Clone, Debug, Default
| Field | Type | Description |
|---|---|---|
0 |
Arc<Vec<(String, Arc<SvgBitmap>)>> |
SvgMask¶
struct. A mask, already converted so that its shapes' alpha is the mask: a luminance mask's colours became their luminance.
Implements: Debug
| Field | Type | Description |
|---|---|---|
rect |
Rect |
|
root |
SvgGroup |
|
mask |
Option<Box<SvgMask>> |
A mask on the mask itself. |
SvgPath¶
struct.
Implements: Debug
| Field | Type | Description |
|---|---|---|
path |
BezPath |
|
fill |
Option<SvgFill> |
|
stroke |
Option<SvgStroke> |
|
stroke_first |
bool |
SVG's paint-order: stroke: the stroke goes under the fill. |
SvgPattern¶
struct. A tiled paint: root is drawn in tiles of rect's size, the first at rect's origin, all under transform.
Implements: Debug
| Field | Type | Description |
|---|---|---|
rect |
Rect |
|
transform |
Affine |
|
root |
SvgGroup |
SvgShadow¶
struct. A drop shadow: the group's shapes, already recoloured to the shadow's colour, drawn offset and blurred under the group.
Implements: Debug
| Field | Type | Description |
|---|---|---|
dx |
f64 |
|
dy |
f64 |
|
blur |
Option<f32> |
|
root |
SvgGroup |
SvgState¶
struct. NodeKind::Svg's own state.
| Field | Type | Description |
|---|---|---|
document |
Arc<SvgDocument> |
|
source |
Arc<Vec<u8>> |
What the document was parsed from, as it was given. |
source_is_text |
bool |
Whether source was given as text (and reads back as text). |
color |
Option<Color> |
What currentColor resolves to; None leaves the document's own. |
images |
SvgImages |
The raster images the caller decoded, by href. |
timeline |
Option<Arc<Timeline>> |
The document's SMIL animation, if it has any. |
time |
Animated<f64> |
The seconds into the animation the document is drawn at (svg_time). |
fonts |
Option<SvgFonts> |
The fonts a re-sample shapes text with. |
| Method | Description |
|---|---|
fn duration(&self) -> Option<f64> |
svg_duration: the seconds after which nothing changes (0 for a document without animation), or None when it repeats for ever. |
fn empty() -> Self |
A node with no document yet. |
fn keep_time_of(&mut self, old: SvgState) |
A colour or image change re-makes the state from the same source: the animation goes on where it was, running animation included. |
fn new(document: Arc<SvgDocument>, source: Vec<u8>, source_is_text: bool, color: Option<Color>, images: SvgImages, fonts: SvgFonts) -> Self |
A node whose document was parsed from source. |
fn reparse(&mut self, fonts: &SvgFonts) |
Parses the document again from the current text, because the fonts changed. |
fn set_time(&mut self, seconds: f64) |
svg_time: the seconds the animation is at, now. |
fn tick(&mut self, now: Instant, completed: &mut Vec<CompletionHandle>) -> bool |
Advances the svg_time animation; true while it runs. |
SvgStroke¶
struct.
Implements: Debug
| Field | Type | Description |
|---|---|---|
paint |
SvgPaint |
|
stroke |
Stroke |
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 |
Option<Color> |
The default text color. |
background |
Color |
The default background color. |
cursor |
Option<Color> |
The cursor color. |
selection |
Option<Color> |
The selection highlight color. |
| Method | Description |
|---|---|
fn resolve(&self, scheme: &SchemeColors) -> ResolvedPalette |
The palette with scheme's colors where this one has none. |
TerminalState¶
struct. A terminal's current cell grid, cursor, selection and fonts.
| 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. |
escape_chord |
Option<KeyChord> |
The chord that leaves this terminal, forward in tab order, without being sent to the shell (WCAG 2.1.2). |
escape_chord_reverse |
Option<KeyChord> |
The chord that leaves it backward; None (the default) has none. |
line_height |
Option<f32> |
A multiple of font_size for the height of a cell; None (the default) is the font's own line height. |
caret_shape |
CaretShape |
How the cursor is drawn: a box over the cell (the default, as it was), a bar at its left edge, or a line under it. |
caret_width |
f32 |
The bar's width, or the underline's thickness, in pixels. |
caret_blink_ms |
u32 |
Milliseconds between the cursor going off and on; 0 (the default) keeps it steady, and so does reduced motion. |
caret_on |
bool |
|
caret_epoch |
Option<Instant> |
|
caret_unfocused |
UnfocusedCursor |
What a terminal without focus shows of its cursor. |
bold_weight |
f32 |
The weight of a bold cell's glyphs (700, as it was). |
dim_opacity |
f32 |
The opacity a dim cell's glyphs are drawn with (0.6, as it was). |
underline_offset |
Option<f32> |
Where an underline starts, in pixels from the top of its cell; None (the default) is 0.85 of the cell's height, as it was. |
underline_thickness |
Option<f32> |
An underline's thickness in pixels; None (the default) is 0.06 of the cell's height, at least a pixel, as it was. |
selection_foreground |
Option<Color> |
The colour of the glyphs inside the selection; None keeps each cell's own. |
selection_radius |
f32 |
The corner radius of the selection's rectangles (one per row), in pixels. |
bar |
ScrollbarState |
The history scrollbar's settings and fades, the same as a scroll view's. |
history_len |
usize |
How many lines of history the session holds, and how many of them the view is scrolled back into (0 is the live screen). |
history_back |
usize |
|
line_px |
f32 |
One line, in pixels: the unit the bar's offsets are in. |
scroll |
Animated<f64> |
The view's top, in pixels from the top of the history (history_len * line_px is the live screen): what the bar's thumb shows and a drag, a lane… |
| Method | Description |
|---|---|
fn cell(&self, row: u16, col: u16) -> &TerminalCell |
Returns the cell at a row and column; panics when out of bounds. |
fn cell_size(&self, natural: (f32, f32)) -> (f32, f32) |
The size of one cell: the font's measured natural size, its height replaced by line_height times the font size when that is set. |
fn history_back_wanted(&self) -> usize |
How many lines back into the history the bar's offset asks the view to be: what a thumb drag, a lane click or an arrow set (history_back while no… |
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. |
fn set_history(&mut self, len: usize, back: usize) |
The session holds len lines of history and the view is back lines into it. |
TextFieldState¶
struct. The state of an editable text field: content, cursor, selection and styling.
Implements: Scroller
| 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. |
tint_scheme |
bool |
true while the field has no colour of its own: the window's scheme then decides it at paint time, and text_tint is not read. |
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 the scheme's on_surface_variant while tint_scheme, else text_tint at 60% alpha. |
caret_color |
Option<Animated<Color>> |
The caret's color; None is the scheme's primary while tint_scheme, else text_tint. |
max_length |
Option<usize> |
The most characters the field holds; typing, paste and IME commits that would pass it are cut short. |
read_only |
bool |
The text can be selected and copied but not edited. |
input_mode |
InputMode |
What kind of text the field takes, for a keyboard that can adapt to it. |
caret_visible |
bool |
Whether tess_re draws the caret; false leaves it to a framework that draws its own. |
caret_width |
f32 |
The bar's width in pixels (the thickness of an underline). |
caret_shape |
CaretShape |
|
caret_blink_ms |
u32 |
Milliseconds between the caret going off and on; 0 keeps it steady. |
caret_on |
bool |
|
caret_epoch |
Option<Instant> |
|
preedit_cursor |
Option<(usize, usize)> |
The IME's cursor range inside the preedit text, in bytes. |
last_inserted |
Option<Range<usize>> |
The bytes the last edit inserted, for caret_move. |
selection_fill |
Option<Color> |
The selection highlight's color; None is the scheme's primary at 30% while tint_scheme, else text_tint at 30% alpha. |
selection_foreground |
Option<Color> |
The colour of the selected glyphs; None keeps each glyph's own colour. |
selection_radius |
f32 |
The corner radius of the highlight, in pixels (one rectangle per line); 0 is square. |
obscured |
bool |
A password field — every character paints as a bullet, and its text never leaves through copy or cut. |
wrap |
Option<bool> |
Some(true) wraps a multiline input's lines at its width (by word); Some(false) keeps each line whole and scrolls sideways. |
overflow |
Option<FieldOverflow> |
How a single-line input shows a line longer than its box. |
follow_stamp |
u64 |
What follow_caret last saw, so a field that did not change is not shaped again. |
overwrite |
bool |
Overwrite mode (the Insert key toggles it): a typed character replaces the one after the caret instead of being added before it. |
tab_navigates |
bool |
T-018 (TRE-REQ-018): Tab and Shift+Tab move focus out of a multi-line input instead of typing a tab character, as they do from a single-line one. |
goal_x |
Option<f32> |
The x (in pixels along the text) Up, Down, Page Up and Page Down hold across a run of vertical moves, so passing a short row does not lose the column. |
vertical_align |
Option<VerticalAlign> |
Where the lines sit in the content box when it is taller than they are. |
letter_spacing |
f32 |
Extra space after each character, in pixels (as on a text node). |
line_height |
Option<f32> |
A line height as a multiple of the font size (as on a text node); None is the font's own. |
bar |
Box<ScrollbarState> |
The input's own scrollbar, the same state as a scroll view's. |
content_extent |
(f64, f64) |
How big the shaped text is, (width, height) in pixels, which the bar's thumb is sized from: measured by the window's text renderer, as only it has… |
extent_stamp |
u64 |
What content_extent was last measured from, so a field that did not change is not shaped again. |
| Method | Description |
|---|---|
fn bar_on(&self) -> bool |
Whether the input's bar is on: a multiline input that has scrollbar_show set to something but never. |
fn clips(&self) -> bool |
Whether the painted text is clipped to the box (every input but a legacy single line, which wraps inside it). |
fn effective_vertical_align(&self) -> VerticalAlign |
The vertical alignment in force: what was set, or Center for a single-line input (text in a field taller than its line sits in the middle, as in… |
fn fit<'a>(&self, text: &'a str) -> &'a str |
text cut to what room allows, on a character boundary. |
fn follows_caret(&self, focused: bool) -> bool |
Whether the scroll offsets follow the caret by the shaped layout (follow_caret), rather than the editor heuristic in… |
fn moves_by_rows(&self) -> bool |
Whether the caret keys move by the rows the shaped text shows (a multiline input that has a wrap, either value) and not by the logical lines of… |
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. |
fn resets_when_unfocused(&self) -> bool |
Whether a single-line input goes back to its start when it loses the focus. |
fn room(&self) -> usize |
How many more characters an insertion could add now, counting the selection as replaced. |
fn shaped_scroll(&self) -> bool |
Whether a multiline input's scroll follows its caret by the shaped layout: one that has a wrap, and one whose scrollbar is on (bar_on), whose… |
fn wraps(&self) -> bool |
Whether the input's lines are broken at its width (true) or each is laid out whole (false, and the box clips or scrolls it). |
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. |
spans |
Vec<TextSpan> |
Styles for ranges of the text, over the node's own. |
selectable |
bool |
Whether a press and drag on the text selects it, and Copy takes the selection. |
selection |
Option<(usize, usize)> |
The selected bytes as (anchor, focus), either order. |
vertical_align |
VerticalAlign |
Where the laid-out lines sit in the node's content box when the box is taller than they are. |
selection_fill |
Option<Color> |
The highlight behind selected text; None is the scheme's primary at 30% while the text has no fill of its own, else the text colour at 30%.… |
selection_foreground |
Option<Color> |
The colour of the selected glyphs; None keeps each glyph's own colour. |
selection_radius |
f32 |
The corner radius of the highlight, in pixels (one rectangle per line); 0 is square. |
| Method | Description |
|---|---|
fn same_layout(&self, other: &Self) -> bool |
Whether other shapes and lays out text the same way: every field but the selection state, which only changes what is painted over the glyphs, so a… |
TextSpan¶
struct. A style for the part of a text node's content from byte offset start to end (UTF-8 offsets, like a text input's selection and syntax_spans…
Implements: Clone, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
start |
usize |
|
end |
usize |
|
color |
Option<Color> |
The glyph colour. |
weight |
Option<f32> |
An OpenType weight (100.0..=950.0). |
italic |
Option<bool> |
Some(true) italic, Some(false) upright. |
underline |
bool |
|
strikethrough |
bool |
|
font_size |
Option<f32> |
The font size in pixels, for this range. |
font_family |
Option<String> |
The font family for this range. |
link |
Option<String> |
Makes the range a link: a click on it fires a link event carrying this string. |
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. |
Thumb¶
struct. One thumb, with the regions around it, all in the view's own coordinates.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
axis |
ScrollAxis |
|
thumb |
Rect |
The painted thumb. |
hit |
Rect |
Where a press grabs the thumb. |
lane |
Rect |
The strip along the axis a press pages in (the thumb is in it), between the arrows when there are any. |
track_rect |
Rect |
The painted track: the lane, as wide as the thumb. |
arrows |
Option<[Arrow; 2]> |
The arrow buttons at the lane's ends, [start, end], with scrollbar_arrows. |
track |
f64 |
The lane's length. |
length |
f64 |
The thumb's length. |
max_scroll |
f64 |
How far the content can scroll along this axis. |
| Method | Description |
|---|---|
fn arrow_at(&self, point: Point) -> Option<usize> |
The arrow button a press at point (view coordinates) is on: 0 for the one at the start of the lane, 1 for the end. |
fn lane_start(&self) -> f64 |
The lane's start along its axis. |
fn painted(&self, track: bool) -> impl Iterator<Item = Rect> |
Every region the bar paints: the track (when it has a fill, track), the thumb, the arrows. |
fn span(&self) -> (f64, f64) |
The thumb's span along its axis. |
fn travel(&self) -> f64 |
How far the thumb travels from one end of the lane to the other. |
Touched¶
struct. The nodes touched since the last take_touched.
| Field | Type | Description |
|---|---|---|
all |
bool |
Every node may have changed (a pass over all nodes was made, or too many were touched to list). |
ids |
Vec<NodeId> |
The touched nodes, possibly repeated and possibly since removed. |
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 adopt_text_selection(&mut self, id: NodeId) |
Makes text node id the owner of the static selection if it has one, or releases it if it was the owner and has none: for code that sets… |
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 anchor_cycle(&self, id: NodeId, anchor: NodeId) -> bool |
Whether anchoring id to anchor would be a cycle: it is id itself, or inside id's subtree (so its position would depend on where id is put). |
fn animate_layout(&mut self, id: NodeId, prop: LayoutProp, to: f64, duration: Duration, curve: MotionCurve, now: Instant, completion: Option<CompletionHandle>) -> Result<(), LayoutAnimError> |
Starts animating a layout property of id to to pixels. |
fn announce(&mut self, text: &str, assertive: bool) |
TRE-REQ-021: raises one live announcement through the accessibility tree, with no node of the caller's. |
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 bar_fields(&self) -> Vec<NodeId> |
The text inputs whose scrollbar is on: the ones the window's text renderer measures (set_text_field_extent). |
fn build_access_update(&self, root: NodeId) -> TreeUpdate |
Builds a fresh accessibility tree update from the current nodes. |
fn build_access_update_scaled(&self, root: NodeId, scale: f64) -> TreeUpdate |
build_access_update with every node's bounds multiplied by scale: layout is in logical pixels, and assistive technology wants the window's… |
fn build_access_update_titled(&self, root: NodeId, scale: f64, title: &str) -> TreeUpdate |
build_access_update_scaled, with the root named after the window's title (a LayerWindow's namespace) when the app gave it no label. |
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 can_scroll_axis(&self, id: NodeId, axis: ScrollAxis, delta: f64) -> bool |
can_scroll for scroller id along axis. |
fn cancel_gesture(&mut self, now: Instant) -> CancelledGesture |
Ends the gesture in progress without its release: the pointer capture and the press go, a held lane press stops, and a dragged scrollbar thumb puts… |
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 clear_text_selection(&mut self) |
Clears the selection in static text, wherever it is. |
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 container_items(&self, host: NodeId) -> &[NodeId] |
The items host chooses, in order: their indices are the keys. |
fn container_selection(&self, id: NodeId) -> Option<&SelectionState> |
id's selection, if it is a box, container or scroll view that has one. |
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 edit_state_layer(&mut self, id: NodeId, edit: impl FnOnce(&mut StateLayer)) |
Edits id's state layers through edit (given the existing ones, or fresh defaults, with which a node starts having any) and looks at them again… |
fn extend_static_selection(&mut self, key: Key) -> bool |
extend_static_selection_by by one character. |
fn extend_static_selection_by(&mut self, key: Key, by_word: bool) -> bool |
Shift+Left, Shift+Right, Shift+Home or Shift+End in static text (by_word: with Ctrl, Left and Right move a word): moves the selection's focus end… |
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 extend_text_selection(&mut self, id: NodeId, focus: usize) -> bool |
Moves the focus end of the selection to focus in text node id, keeping its anchor (a drag), even if that is another text node; starts a… |
fn fling_scroll(&mut self, from: NodeId, velocity: Vec2, now: Instant) -> bool |
Lets the scroller under a lifted finger coast. |
fn focus_visible(&self) -> bool |
Whether the current focus is "visible": it came from the keyboard or assistive technology, not a pointer press. |
fn focused(&self) -> Option<NodeId> |
Returns the node that currently has keyboard focus, if any. |
fn gesture_active(&self) -> bool |
Whether a gesture the engine can cancel is held: a captured pointer, a scrollbar thumb drag, or one set_gesture_hold was told of (a dock drag). |
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_images(&self) -> bool |
Every real Image node currently in this tree. |
fn has_input_grab(&self) -> bool |
Whether an open layer wants presses outside itself: a dismissible or modal one. |
fn has_pending_announcements(&self) -> bool |
Whether an announcement is waiting for an update (so the window wakes to send it). |
fn has_shaders(&self) -> bool |
Returns whether any node has a shader. |
fn has_svgs(&self) -> bool |
Whether the tree holds any Svg node. |
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 holds_items(kind: &NodeKind) -> bool |
Whether a node of kind can have its children chosen: a box, a container, a scroll view. |
fn hovered(&self) -> Option<NodeId> |
update_hover's own transition half, split out so InputEvent::PointerLeft can clear hover without a hit-test. |
fn image_nodes(&self) -> impl Iterator<Item = (NodeId, &ImageState)> |
Iterates every image node in the tree with its image state. |
fn input_region(&self, root: NodeId, bounds: (f64, f64), max_rects: usize) -> Vec<(i32, i32, i32, i32)> |
The rectangles, in logical pixels inside bounds (the surface's (width, height)), where a click lands on something drawn: every visible… |
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_dirty(&self) -> bool |
Whether a frame is owed, without taking the flag. |
fn is_layer(&self, id: NodeId) -> bool |
Returns whether a node is an open layer or overlay. |
fn item_parent(&self, host: NodeId) -> Option<NodeId> |
The node whose children are the items host chooses: host itself, or, for a scroll view, the one child that holds its content. |
fn layer_defaults(&self) -> LayerDefaults |
The policy a layer follows when it sets no viewport margin or flip threshold of its own. |
fn layout(&self, id: NodeId) -> &Layout |
Returns a node's computed layout box from the last layout pass. |
fn layout_epoch(&self) -> u64 |
How many times a layout has been computed. |
fn layout_target(&self, id: NodeId, prop: LayoutProp) -> Option<f64> |
Where id's running animation of prop is heading. |
fn list_selection_key(&mut self, key: Key, shift: bool) -> ListKey |
The key key (with the held modifiers) pressed while focus is in a list that chooses rows (AC-SLT-2, 3, 5): Up, Down, Home, End, Page Up and Page… |
fn local_to_window(&self, id: NodeId, point: Point) -> Point |
Converts a point in a node's own space into window space. |
fn margin_drag_allowed(&self) -> bool |
|
fn mark_dirty(&mut self) |
Marks the tree as needing a frame. |
fn mark_state_layer(&mut self, id: NodeId) |
For Window.set after a layer property or disabled changed on id: its layers are looked at again on the next tick. |
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 max_scroll_axis(&self, view: NodeId, axis: ScrollAxis) -> Option<f64> |
max_scroll along axis. |
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 node_count(&self) -> usize |
How many nodes the tree holds. |
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 outline_of(&self, id: NodeId) -> Option<Outline> |
The outline id draws now, if any: its focus_outline_* while it has keyboard focus that is visible, else its outline_*. |
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 reduced_motion(&self) -> bool |
Whether motion is reduced: the window's own say (Window.reduced_motion) if it has one, else the OS's. |
fn reduced_motion_override(&self) -> Option<bool> |
The window's own say, if it has one. |
fn refresh_selection_host(&mut self, id: NodeId) |
Keeps selection_hosts right about id, after a property of it changed or its change was reported: a container is in it while its mode is not… |
fn relayout(&mut self, id: NodeId) |
Marks id for layout again: its text, font or fit changed, and a fit side's size depends on all of those. |
fn remove(&mut self, id: NodeId) -> bool |
Removes a node and its whole subtree, detaching it from its parent. |
fn reparse_svgs(&mut self, fonts: &SvgFonts) |
Every SVG node whose document has text is parsed again with fonts. |
fn resolve_list_focus(&mut self) -> Vec<(Option<NodeId>, Option<NodeId>)> |
Moves focus into the rows focus_list_row was waiting for and that are built now (call it after layout), as long as focus is still in their list or… |
fn resolve_text_part(&self, id: NodeId) -> Option<TextPart> |
What the synthetic accessibility id id stands for, if it is the run or link of one of this tree's text nodes (0.5.4, #151). |
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 scheme_colors(&self) -> &SchemeColors |
The scheme colours a node with no colour of its own paints in. |
fn scheme_revision(&self) -> u64 |
How many times the scheme colours changed. |
fn scroll_axis_by(&mut self, id: NodeId, axis: ScrollAxis, delta: f64) |
scroll_scroll_view_by along one axis. |
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_shift(&self, id: NodeId) -> (f64, f64) |
How far id's parent scrolls it, as the translation to add to its layout location when painting and hit-testing: the single child of a ScrollView… |
fn scroll_thumbs(&self, view: NodeId) -> Option<[Option<Thumb>; 2]> |
The scrollbar thumbs [vertical, horizontal] of scroller view (a scroll view or a virtual list), in its own coordinates and by its live offsets… |
fn scroll_thumbs_at(&self, view: NodeId, offsets: (f64, f64)) -> Option<[Option<Thumb>; 2]> |
scroll_thumbs as they would be with the content scrolled to offsets ((x, y)): where the thumbs were, for a frame that moved them. |
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 scroll_virtual_list_to_index(&mut self, list: NodeId, index: usize, align: ScrollAlign) -> Option<bool> |
Scrolls virtual list list so row index shows as align says, from the offsets the list knows. |
fn scrollbar_pressed(&self) -> bool |
Whether the last primary press landed on a scrollbar and was used up by it, so whatever sits under the bar (a terminal's cell selection) is not to… |
fn select_across(&mut self, anchor: (NodeId, usize), focus: (NodeId, usize)) -> bool |
Selects from anchor to focus, each a text node and a byte offset (clamped to a character boundary). |
fn select_all_in_focused_list(&mut self) -> bool |
Ctrl+A: chooses every selectable row of the multiple selection list focus is in, if it has select_all_key. |
fn select_all_static_text(&mut self) -> bool |
Ctrl+A in static text: selects all of the text node the selection started in. |
fn select_all_text_field(&mut self, field: NodeId) -> bool |
Selects all the text in a text field. |
fn select_text_field_unit(&mut self, field: NodeId, character: usize, row_start: usize, row_end: usize, triple: bool) -> bool |
A double or triple click in a text input selects around the character the pointer is on, inside the visual row row_start..row_end (the row's text… |
fn set_access(&mut self, id: NodeId, access: AccessNodeData) |
Sets a node's accessibility role, label and actions. |
fn set_anchor(&mut self, id: NodeId, anchored: Option<Anchored>) -> bool |
Places id against another node in the tree (Some), or puts it back in the flow (None). |
fn set_calc_size(&mut self, id: NodeId, height: bool, calc: Option<CalcLen>) |
Makes one side of id's size a calc (or, with None, an ordinary size again). |
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_drag_start_px(&mut self, px: f64) |
drag_start_px of the window, which the window sets before each event. |
fn set_field_rows(&mut self, rows: FieldRows) |
Installs what answers a text input's questions about its shaped rows. |
fn set_fit_content(&mut self, id: NodeId, fit: FitContent) |
Sets which sides of text node id take the text's own size. |
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_focus_visible(&mut self, visible: bool) |
See Tree::focus_visible. |
fn set_gesture_hold(&mut self, hold: bool) |
Tells the tree a gesture it cannot see (a dock drag) starts or ends, which is what edge auto-scroll waits for. |
fn set_held_modifiers(&mut self, held: Modifiers) |
Tells the tree which modifier keys are held; the window calls it before each event. |
fn set_hit_testable(&mut self, id: NodeId, hit_testable: Option<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_layer_defaults(&mut self, defaults: LayerDefaults) |
Sets that policy; every layer without its own is placed again at the next layout. |
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_margin_drag_allowed(&mut self, allowed: bool) |
|
fn set_os_reduced_motion(&mut self, reduced: bool) |
What the OS asks for (the window reads it at creation and on each change, InputEvent::ReducedMotionChanged). |
fn set_pointer_capture(&mut self, node: Option<NodeId>) |
Routes all later pointer events to a node until capture is cleared. |
fn set_reduced_motion_override(&mut self, reduced: Option<bool>) |
The window's own say, None to follow the OS. |
fn set_scheme_colors(&mut self, colors: SchemeColors) -> bool |
Sets the scheme colours; true when they changed, in which case every node is repainted at the next frame. |
fn set_sticky(&mut self, id: NodeId, inset: Option<f64>) |
Advances every running animation to now. |
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_access_lines(&mut self, lines: HashMap<NodeId, Vec<AccessLine>>) |
Hands the tree the shaped lines of its text nodes, for their runs' bounds and character positions (the text renderer makes them; see AccessLine). |
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_text_field_extent(&mut self, id: NodeId, extent: (f64, f64), stamp: u64) |
Sets how big the shaped text of input id is, (width, height) in pixels, and the stamp of what it was measured from… |
fn set_text_field_scroll(&mut self, id: NodeId, horizontal: f64, vertical: f64, stamp: u64) |
Sets text input id's scroll offsets (and the stamp of what they were worked out from), touching the node only when something changed, so a settled… |
fn set_text_measure(&mut self, measure: TextMeasure) |
Sets how text is measured for FitContent. |
fn set_text_selection(&mut self, id: NodeId, anchor: usize, focus: usize) -> bool |
Selects anchor..focus (bytes, either order, clamped to character boundaries) in a text node, clearing any other selection first. |
fn set_text_selection_from_access(&mut self, selection: &TextSelection) -> bool |
A screen reader's SetTextSelection: selects the range it names in the one text node both ends are in. |
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 set_window_drag_allowed(&mut self, allowed: bool) |
The tree of a layer surface refuses window_region="drag". |
fn shader_cycle(&self, id: NodeId, shader: &Shader) -> bool |
Returns whether giving a node a shader would make a shader depend on itself. |
fn shader_frame_owed(&self) -> bool |
Whether a shader this tree draws has moved, or is moving, since the tree last looked: a frame is owed that nothing in the tree itself asked for. |
fn shaped_fields(&self) -> Vec<NodeId> |
The text inputs the window's text renderer must shape to work something out for, which engine-core cannot do (no font): those whose scroll follows… |
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 static_selected_text(&self) -> Option<String> |
The text a Copy of the static selection would take, the nodes' pieces joined by newlines: None for no selection or an empty one. |
fn static_selection_ends(&self) -> Option<((NodeId, usize), (NodeId, usize))> |
The selection's anchor and its moving end: a text node and a byte offset each. |
fn static_selection_vertical_edge(&self, forward: bool) -> Option<(NodeId, usize)> |
Where Shift+Up (forward == false) or Shift+Down goes when the text has no line to move to: the start or end of the text, and from there into the… |
fn stop_layout_anims(&mut self, id: NodeId, props: &[LayoutProp]) |
Stops id's animations of props where they are (each ends as cancelled). |
fn stop_scroll_animation(&mut self, from: NodeId) |
Stops a fling (or any scroll animation) in the scrollers around from, leaving them where they are: a finger landing on moving content catches it. |
fn svg_bitmaps(&self) -> Vec<Arc<SvgBitmap>> |
Every raster image the tree's SVG nodes were given, for the renderer to upload as textures. |
fn take_anchor_conflicts(&mut self) -> Vec<NodeId> |
The anchored nodes compute_layout gave up on since this was last called: their anchors depend on each other with no solution (A is placed against… |
fn take_calc_conflicts(&mut self) -> Vec<(NodeId, bool)> |
The calc sizes compute_layout gave up on since this was last called, as (node, is_height). |
fn take_caret_changes(&mut self) -> Vec<(NodeId, Option<Range<usize>>)> |
|
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_edge_scrolled(&mut self) -> Option<Point> |
Where the pointer was when edge auto-scroll last moved a view, once (the caller re-reads hover and the dock target there). |
fn take_layout_changes(&mut self) -> Vec<LayoutChange> |
Every watched node whose laid-out size has changed since this was last asked, as (node, old, new) with old None the first time. |
fn take_overwrite_changes(&mut self) -> Vec<(NodeId, bool)> |
The text fields whose caret moved, or whose text changed, since the last call, each with the bytes the edit inserted, if it did. |
fn take_scroll_changes(&mut self) -> Vec<ScrollChange> |
Returns each scroll view whose offset changed since the last call, as (view, old, new). |
fn take_selection_changes(&mut self) -> Vec<SelectionChange> |
The lists and containers whose chosen set changed since the last call, each with the whole set. |
fn take_touched(&self) -> Touched |
The nodes handed out mutably since the last call (see Touched), and a fresh start. |
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 text_link_at(&self, id: NodeId, offset: usize) -> Option<&str> |
The link at byte offset of text node id (the last span covering it that has one), if any. |
fn text_nodes_needing_access_lines(&self) -> Vec<NodeId> |
The text nodes that are exposed as text containers, which are the ones set_text_access_lines wants lines for. |
fn text_selected_text(&self, id: NodeId) -> Option<String> |
The selected text of text node id, if any is selected. |
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 update_layer(&mut self, id: NodeId, edit: impl FnOnce(&mut OverlayMeta)) -> bool |
Replaces the open layer id's placement policy (viewport_margin, flip_threshold, align, no_flip, no_shift; the rest of its meta is kept)… |
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_selection(&self, list: NodeId) -> Option<&SelectionState> |
list's selection, if it is a virtual list. |
fn virtual_list_visible(&self, list: NodeId) -> Range<usize> |
Returns the range of rows a virtual list's viewport currently shows. |
fn watch_layout(&mut self, id: NodeId, on: bool) |
Starts (or, with false, stops) reporting id's laid-out size through take_layout_changes. |
fn window_drag_allowed(&self) -> bool |
|
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.
Implements: Scroller
| 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. |
bar |
Box<ScrollbarState> |
The scrollbar and scroll feel of the list. |
reported |
f64 |
The offset last reported as a scroll event (see ScrollViewState::reported). |
selection |
Box<SelectionState> |
Which rows are chosen (selection_mode, selection, ...). |
| Method | Description |
|---|---|
fn index_at(&self, y: f64) -> usize |
The row that holds offset y: the last whose top is at or before it (row 0 for any offset before the first row; the last row past the end). |
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 thumb_geometry_at(&self, viewport_extent: f64, offset: f64) -> (f64, f64, f64) |
thumb_geometry as it would be at scroll offset offset. |
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. |
Align¶
enum. Which edge of the anchor a layer placed on one of its sides lines up with, on the axis along that side: Start (left or top, the default and what…
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Start |
||
Center |
||
End |
Arrows¶
enum. scrollbar_arrows: buttons at the ends of the lane.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
None |
||
Both |
| Method | Description |
|---|---|
fn from_index(index: u8) -> Self |
|
fn index(self) -> u8 |
BarSide¶
enum. Where the bar of an axis sits, as a user names it.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
End |
||
Start |
||
Left |
||
Right |
||
Top |
||
Bottom |
| Method | Description |
|---|---|
fn edge(self, axis: ScrollAxis, direction: Direction) -> Edge |
Which edge this names for the bar of axis (a vertical bar sits at the left or right edge, a horizontal one at the top or bottom): **the one place… |
fn from_index(axis: ScrollAxis, index: u8) -> Option<Self> |
The side named by index index of axis' name list (VERTICAL_SIDE_NAMES, HORIZONTAL_SIDE_NAMES). |
Blend¶
enum. How a node mixes with what is behind it (CSS mix-blend-mode).
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Normal |
||
Multiply |
||
Screen |
||
Overlay |
||
Darken |
||
Lighten |
||
ColorDodge |
||
ColorBurn |
||
HardLight |
||
SoftLight |
||
Difference |
||
Exclusion |
||
Hue |
||
Saturation |
||
Color |
||
Luminosity |
| Method | Description |
|---|---|
fn from_name(name: &str) -> Option<Blend> |
|
fn name(self) -> &'static str |
CaretShape¶
enum. How a text input's caret is drawn.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Bar |
A thin vertical bar before the character. | |
Block |
A box over the character the caret is before. | |
Underline |
A line under the character the caret is before. |
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. |
ComposePhase¶
enum. Where an IME composition is.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Start |
||
Update |
||
End |
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. | |
Custom |
(u64) |
A cursor image the app registered (engine_platform:: cursors), by id. |
| 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. |
Direction¶
enum. The direction text and inline content run.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
LeftToRight |
||
RightToLeft |
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. |
Submitted |
(NodeId) |
Enter in a single-line text field. |
Composed |
{ node: NodeId, phase: ComposePhase, text: String, cursor: Option<(usize, usize)> } |
An IME composition began, changed or ended in a text field. |
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, gradient: Option<Gradient> } |
Fills a rectangle with a color. |
FillCircle |
{ cx: f64, cy: f64, radius: f64, color: Color, gradient: Option<Gradient> } |
Fills a circle with a color. |
StrokePath |
{ path: BezPath, color: Color, width: f64, gradient: Option<Gradient> } |
Strokes a path with a color and line width. |
Easing¶
enum. An easing a property names: a preset or a cubic bezier.
Implements: Clone, Copy, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Linear |
||
Bezier |
(f64, f64, f64, f64) |
A CSS cubic-bezier(x1, y1, x2, y2); x1 and x2 lie in 0..=1. |
| Method | Description |
|---|---|
fn bezier(x1: f64, y1: f64, x2: f64, y2: f64) -> Option<Self> |
A bezier with these control points, if they are a valid curve: finite, with x1 and x2 in 0..=1 (the precondition of CSS and of… |
fn curve(self) -> MotionCurve |
The animation curve. |
fn from_name(name: &str) -> Option<Self> |
The preset called name. |
fn name(self) -> Option<&'static str> |
The preset name of this easing, if it is one. |
fn names() -> String |
The preset names, comma separated, for an error message. |
Edge¶
enum. The edge of the view a bar sits on: the left or top (Near) or the right or bottom (Far).
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Near |
||
Far |
FieldOverflow¶
enum. How a single-line text input shows a line longer than its box (it is one line, however long): Scroll keeps the caret in view, Ellipsis cuts the…
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Scroll |
||
Ellipsis |
||
Clip |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
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). |
GestureKind¶
enum. What kind of gesture.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Tap |
{ count: u8 } |
A quick touch and release in place. |
LongPress |
A touch held in place past the long-press time. | |
Pan |
One finger dragging. | |
Pinch |
Two fingers moving together or apart (and, with them, across). | |
Rotate |
Two fingers turning about their midpoint, once past the rotation slop. | |
Swipe |
{ direction: SwipeDirection } |
A pan that lifted fast and far enough to be a flick in one direction. |
GesturePhase¶
enum. Where a pan or a pinch is in its life.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Began |
||
Changed |
||
Ended |
||
Cancelled |
GradientShape¶
enum. Where a gradient's colours run.
Implements: Clone, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Linear |
{ angle_deg: f64 } |
Along a line through the box's centre at angle_deg (0 up, 90 right, 180 down), as long as the box is along that direction, as CSS's… |
Radial |
{ center: (f64, f64), radius: f64 } |
Outward from center (fractions of the box, (0.5, 0.5) its middle). |
Sweep |
{ center: (f64, f64), start_deg: f64 } |
Around center, starting start_deg clockwise from up. |
HitShape¶
enum. What a path node is hit by.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Box |
The node's box, with its corners rounded as painted: how every node was hit before, and the default. | |
Painted |
What is painted: the fill region (when the fill has colour or a gradient) united with the stroke (when the stroke has width and colour), so a click… |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
ImageSampling¶
enum. How an image node's pixels are sampled when it is drawn at another size.
Implements: Clone, Copy, Debug, PartialEq, Eq, Default
| Variant | Payload | Description |
|---|---|---|
Linear |
Bilinear: the default, and what every image was drawn with before. | |
Nearest |
The nearest pixel: hard edges, for pixel art and exact pixel grids. | |
Cubic |
Bicubic: sharper than bilinear when an image is scaled down. |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
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 |
|---|---|---|
ReducedMotionChanged |
{ reduced: bool } |
The OS's reduced-motion preference changed. |
HighContrastChanged |
{ high: bool } |
The OS's increased-contrast preference changed. |
FileHovered |
{ path: PathBuf, position: Point } |
The OS is dragging a file over the window. |
FileHoverCancelled |
The drag left the window or was abandoned. | |
FileDropped |
{ path: PathBuf, position: Point } |
A file was dropped on the window (one per file). |
Touch |
{ id: u64, phase: TouchPhase, position: Point } |
One finger on a touch screen. |
TrackpadPinch |
{ delta: f64, phase: TouchPhase, position: Point } |
A trackpad's pinch (macOS and iOS report one directly, as a magnification step: 1.0 + delta is the scale to apply). |
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, Option<(usize, usize)>) |
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. |
Occluded |
{ occluded: bool } |
The OS says the window is completely hidden (true) or showing again. |
ActivationToken |
{ token: String } |
T-051: the OS answered Window.request_activation_token with this token (winit::WindowEvent::ActivationTokenDone). |
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. |
InputMode¶
enum. What kind of text a text input takes (HTML's inputmode).
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Text |
||
Numeric |
||
Decimal |
||
Email |
||
Phone |
||
Url |
||
Search |
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. | |
Insert |
The Insert key: in a text input it toggles insert and overwrite mode. |
LaneClick¶
enum. scrollbar_lane_click: what a press on the lane beside the thumb does.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Page |
Scroll one page toward the press, repeating while held. | |
Jump |
Put the thumb's centre at the press and carry on dragging. | |
None |
Nothing: the press goes to what is under the lane. |
| Method | Description |
|---|---|
fn from_index(index: u8) -> Self |
|
fn index(self) -> u8 |
LayerState¶
enum. One of the three layers.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Hover |
||
Pressed |
||
Focus |
LayoutAnimError¶
enum. Why a layout animation could not start.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Missing |
The node is gone. | |
NoStart |
The property is auto or a percentage, with no pixel value to start from. |
LayoutProp¶
enum. One layout property that can be animated.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Width |
||
Height |
||
MinWidth |
||
MinHeight |
||
MaxWidth |
||
MaxHeight |
||
X |
||
Y |
||
PaddingTop |
||
PaddingRight |
||
PaddingBottom |
||
PaddingLeft |
||
MarginTop |
||
MarginRight |
||
MarginBottom |
||
MarginLeft |
||
RowGap |
||
ColumnGap |
||
FlexBasis |
| Method | Description |
|---|---|
fn from_name(name: &str) -> Vec<LayoutProp> |
The properties a Python property name stands for: one, or the sides of a shorthand (padding, margin, gap). |
fn name(self) -> &'static str |
The Python property name of this one property. |
fn non_negative(self) -> bool |
Whether the property can't be negative. |
fn read(self, style: &Style) -> Option<f64> |
The property's value in pixels, or None when it is auto or a percentage. |
fn write(self, style: &mut Style, pixels: f64) |
Writes pixels into the style as the property's value. |
Mask¶
enum. A shape a node and its subtree are clipped to, in the node's own coordinates (so it follows the node's transform).
Implements: Clone, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Circle |
The circle inscribed in the node's box, centred; an ellipse if the box is not square would be a different shape, so this one stays round. | |
Rounded |
(CornerRadii) |
The box with these corner radii (top-left, top-right, bottom-right, bottom-left), independent of the node's own corner_radius. |
Path |
{ data: PathData, view_box: Rect } |
Any path, fitted into the box by view_box like a path node's own. |
MorphMode¶
enum. How a path's data morphs into other data.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Resample |
Both paths are resampled by arc length: any two paths morph, and mid-frames are polygons. | |
Structure |
Two paths with the same sequence of commands morph number by number, so lines, curves and arcs stay what they are and every mid-frame is exact; any… | |
Strict |
As Structure, but a pair with different command sequences is an error, not a resample. |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
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). |
Decay |
(f64) |
Exponential decay, the shape of a flick coming to rest: fast at the start, easing out with no overshoot. |
Spring |
{ omega: f64, zeta: f64, v0: f64, settle: f64 } |
A damped spring from 0 to 1, in real time. |
| Method | Description |
|---|---|
fn spring(omega: f64, zeta: f64, v0: f64) -> Self |
A spring with natural frequency omega and damping ratio zeta starting at v0 (see Spring); computes how long it takes to settle. |
fn spring_for(duration: Duration, bounce: f64) -> Self |
A spring described the way people think of one: it takes about duration for one cycle of its main motion, and bounce says how much it… |
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 |
(Box<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. |
Svg |
(SvgState) |
A whole SVG document, parsed once and painted as one retained scene, fitted into the node's box. |
Terminal |
(Box<TerminalState>) |
A terminal screen showing a grid of character cells. |
ScrollView |
(ScrollViewState) |
A scrollable viewport over one oversized child. |
| Method | Description |
|---|---|
fn name(&self) -> &'static str |
The kind's name as window.create takes it (0.5.4, #135: one list, for get("kind") and for statistics by kind). |
fn scroller(&self) -> Option<&dyn Scroller> |
The scrollbar-carrying view of a scroll view or a virtual list. |
fn scroller_mut(&mut self) -> Option<&mut dyn Scroller> |
|
fn takes_scroll_keys(&self) -> bool |
Whether the arrow, Page and Home/End keys move this scroller when it holds the focus (Tree::scroll_view_for_key): not a terminal's (the shell's)… |
fn takes_wheel(&self) -> bool |
Whether the wheel over this scroller moves it (Tree::dispatch): a scroll view, a virtual list, and a text input whose bar is on… |
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. | |
TopStart |
The node's centre on the anchor's top-start corner, for a badge or a marker. | |
TopEnd |
||
BottomStart |
||
BottomEnd |
||
Center |
The node's centre on the anchor's centre. |
| Method | Description |
|---|---|
fn is_point(self) -> bool |
Whether this names a point of the anchor (a corner or its centre) rather than a side of it. |
fn opposite(self) -> Self |
Returns the placement on the opposite side of the anchor. |
fn origin(self, anchor: AnchorBox, w: f64, h: f64) -> (f64, f64) |
Where a node w x h goes against anchor, as its top-left corner, before any offset. |
fn origin_aligned(self, anchor: AnchorBox, w: f64, h: f64, align: Align) -> (f64, f64) |
origin with the node aligned to the anchor's align edge (or its middle) on the axis along the anchor's side; a point ignores it. |
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. |
PropKind¶
enum. How a property's value is checked, and what its names are.
Implements: Clone, Copy, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Number |
{ min: f64, max: f64 } |
A finite number from min to max. |
Colour |
A colour. | |
Flag |
true or false. |
|
Choice |
(&'static [&'static str]) |
One of these names, by index. |
Easing |
A preset name or a cubic bezier (Easing). |
|
Pair |
{ min: f64, max: f64 } |
Two finite numbers, each from min to max. |
| Method | Description |
|---|---|
fn accepts(self, value: &Value) -> bool |
Whether value is one this kind takes. |
PropValue¶
enum. A property's value: what a Kind checks.
Implements: Clone, Copy, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Number |
(f64) |
|
Colour |
(Color) |
|
Flag |
(bool) |
|
Choice |
(u8) |
The index into the property's Kind::Choice names. |
Easing |
(Easing) |
|
Pair |
(f64, f64) |
RowQuery¶
enum. A question about the rows a text input's shaped text shows, which engine-core (with no font) puts to whatever the window installed…
Implements: Clone, Copy, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Start |
The start of the row the caret is in. | |
End |
The end of that row: after its last character that is not a space or a line break. | |
Vertical |
{ down: bool, page: bool, goal_x: Option<f32> } |
The caret one row up or down (page: as many rows as the box shows), at the x goal_x (None: where the caret is now). |
Scheme¶
enum. The two baselines.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq, Hash
| Variant | Payload | Description |
|---|---|---|
Light |
||
Dark |
| Method | Description |
|---|---|
fn from_name(name: &str) -> Option<Self> |
|
fn name(self) -> &'static str |
SchemeRole¶
enum. One named colour of the scheme.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Primary |
||
OnPrimary |
||
PrimaryContainer |
||
OnPrimaryContainer |
||
InversePrimary |
||
PrimaryFixed |
||
PrimaryFixedDim |
||
OnPrimaryFixed |
||
OnPrimaryFixedVariant |
||
Secondary |
||
OnSecondary |
||
SecondaryContainer |
||
OnSecondaryContainer |
||
SecondaryFixed |
||
SecondaryFixedDim |
||
OnSecondaryFixed |
||
OnSecondaryFixedVariant |
||
Tertiary |
||
OnTertiary |
||
TertiaryContainer |
||
OnTertiaryContainer |
||
TertiaryFixed |
||
TertiaryFixedDim |
||
OnTertiaryFixed |
||
OnTertiaryFixedVariant |
||
Error |
||
OnError |
||
ErrorContainer |
||
OnErrorContainer |
||
SurfaceDim |
||
Surface |
||
SurfaceTint |
||
SurfaceBright |
||
SurfaceContainerLowest |
||
SurfaceContainerLow |
||
SurfaceContainer |
||
SurfaceContainerHigh |
||
SurfaceContainerHighest |
||
OnSurface |
||
OnSurfaceVariant |
||
Outline |
||
OutlineVariant |
||
InverseSurface |
||
InverseOnSurface |
||
SurfaceVariant |
||
Background |
||
OnBackground |
||
Shadow |
||
Scrim |
| Method | Description |
|---|---|
const fn baseline(self, scheme: Scheme) -> Color |
The baseline colour of this role in scheme. |
fn from_name(name: &str) -> Option<Self> |
|
fn name(self) -> &'static str |
The role's snake-case name, as Python spells it. |
ScrollAlign¶
enum. Where Tree::scroll_virtual_list_to_index puts a row in the viewport.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Nearest |
The least scroll that shows the whole row; none if it is already shown. | |
Start |
The row's top at the viewport's top (as far as the list can scroll). | |
Center |
The row's middle at the viewport's middle. | |
End |
The row's bottom at the viewport's bottom. |
| Method | Description |
|---|---|
fn from_name(name: &str) -> Option<Self> |
"nearest", "start", "center" or "end". |
ScrollAxis¶
enum. One of a scroll view's two axes.
Implements: Clone, Copy, Debug, PartialEq, Eq, Hash
| Variant | Payload | Description |
|---|---|---|
Vertical |
||
Horizontal |
| Method | Description |
|---|---|
fn index(self) -> usize |
0 for vertical, 1 for horizontal: the index into [vertical, horizontal] pairs. |
fn other(self) -> ScrollAxis |
|
fn pick(self, (x, y): (f64, f64)) -> f64 |
This axis' share of an (x, y) pair. |
ScrollDefaults¶
enum. Which defaults a scroller's unset properties take.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Spec |
The Tesserae UX spec: a both scroll view. |
|
Legacy |
What a vertical or horizontal scroll view always had: a 4 px thumb with the colour's own alpha, a 6 px slop, no lane click, a page that is the… |
|
List |
What a virtual list always had: the legacy bar, and a page of nine tenths of the viewport. | |
Terminal |
A terminal's history bar. | |
Field |
A multiline text input's own bar (tree/field_bar.rs). |
| Method | Description |
|---|---|
fn is_opt_in(self) -> bool |
Whether the bar is off until scrollbar_show is set (a terminal's, a text input's). |
fn is_spec(self) -> bool |
Whether the measures are the Tesserae UX spec's (a both scroll view, a terminal, a text input). |
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). |
ScrollOrientation¶
enum. The axes a scroll view moves along: orientation.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Vertical |
||
Horizontal |
||
Both |
ScrollProp¶
enum. A scrollbar or scroll-feel property.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Width |
||
HitWidth |
||
Margin |
||
MinLength |
||
Gutter |
||
Corner |
||
Radius |
||
Opacity |
||
OpacityHover |
||
OpacityDrag |
||
Fill |
||
FillHover |
||
FillDrag |
||
TrackFill |
||
TrackOpacity |
||
SideV |
||
SideH |
||
Show |
||
HideDelay |
||
FadeIn |
||
FadeOut |
||
HoverDelay |
||
FadeEasing |
||
GutterReserve |
||
Arrows |
||
ArrowStep |
||
LaneClick |
||
WheelNotch |
||
KeyLine |
||
PageFraction |
||
ScrollSmooth |
||
ScrollEasing |
||
PageRepeatDelay |
||
PageRepeat |
||
SnapSettle |
||
SnapDuration |
||
SnapEasing |
||
FlingTau |
||
FlingStop |
||
FlingMin |
||
EdgeScroll |
||
EdgeScrollBand |
||
EdgeScrollSpeed |
| Method | Description |
|---|---|
fn applies_to_terminal(self) -> bool |
Whether a terminal's history bar takes the property (0.6.12, UXREQ-006): the bar's measures, colours, fades, arrows and lane, and the page and its… |
fn applies_to_text_input(self) -> bool |
Whether a multiline text input's own bar takes the property (0.6.13): the bar's measures, colours, fades, arrows and lane, the page and its repeat… |
fn choices(self) -> Option<&'static [&'static str]> |
The choice names of the property, for a Kind::Choice one. |
fn from_name(name: &str) -> Option<Self> |
The property called name. |
const fn kind(self) -> Kind |
How its value is checked. |
const fn name(self) -> &'static str |
The node property's name. |
SelectionMode¶
enum. How a list's rows are chosen.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
None |
Nothing is chosen by the engine: no keys, clicks or set (the default). | |
Single |
At most one row. | |
Multiple |
Any set of rows. |
SelectionSource¶
enum. What made the selection change.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Pointer |
||
Keyboard |
||
Api |
A property: selection, selection_mode, unselectable_keys, item_count. |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
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. |
Show¶
enum. When the bar shows: scrollbar_show.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Overflow |
Whenever the axis overflows (the default). | |
Always |
Always, even without overflow (then a thumb as long as the lane). | |
AutoHide |
When it overflows, fading out after scrollbar_hide_delay_ms of nothing happening to it, and back in on scroll, hover and drag. |
|
Never |
Never: the view still scrolls. |
| Method | Description |
|---|---|
fn from_index(index: u8) -> Self |
|
fn index(self) -> u8 |
SnapAlign¶
enum. A real, general scrollable viewport over exactly one child, grounded directly in the sibling pyCopper project's own real ScrollViewElement…
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Start |
||
Center |
||
End |
Spread¶
enum. What a gradient does past one pass of its ramp (TRE-REQ-006): hold the last colour, start the ramp again, or run it back.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Pad |
||
Repeat |
||
Reflect |
SvgNode¶
enum.
Implements: Debug
| Variant | Payload | Description |
|---|---|---|
Group |
(SvgGroup) |
|
Image |
(Box<SvgImage>) |
|
Path |
(Box<SvgPath>) |
SvgPaint¶
enum. A paint, with the object's opacity already folded into its alpha.
| Variant | Payload | Description |
|---|---|---|
Color |
(Color) |
|
Gradient |
(Gradient, Affine) |
A gradient and the transform it is painted under. |
Pattern |
(Arc<SvgPattern>) |
SwipeDirection¶
enum. The way a swipe went: the pan's dominant axis.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Left |
||
Right |
||
Up |
||
Down |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
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. |
TextPart¶
enum. What a synthetic accessibility id of a text node stands for.
Implements: Clone, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Run |
{ owner: NodeId, start: usize, end: usize } |
A run of text: bytes start..end of the node's content. |
Link |
{ owner: NodeId, href: String, start: usize, end: usize } |
A link: its href and bytes. |
TouchPhase¶
enum. Where a touch is in its life.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Started |
||
Moved |
||
Ended |
||
Cancelled |
The system took the touch away (a palm, a gesture of its own). |
UnfocusedCursor¶
enum. What a terminal that does not have focus draws of its cursor.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Hidden |
Nothing (the default, as it was). | |
Outline |
A one-pixel frame of the cursor's box: a block is hollow, a bar or an underline is drawn as when focused. |
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. |
VerticalAlign¶
enum. Where text sits in the vertical room its node's content box leaves it: at the top, centred, or at the bottom.
Implements: Clone, Copy, Debug, PartialEq, Eq, Hash
| Variant | Payload | Description |
|---|---|---|
Start |
||
Center |
||
End |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn offset(self, box_height: f32, text_height: f32) -> f32 |
How far down from the top of a box box_height tall text of text_height sits. |
fn parse(name: &str) -> Option<Self> |
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. | |
DragMargin |
A press here, or on a non-interactive node inside, moves a layer surface by its margins (0.5.8, #205). |
Interpolate¶
trait. A value type that can be blended between two values, so it can be animated.
Implemented by: CornerRadii, Gradient, 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. |
fn scalar(&self) -> Option<f64> |
The value as one number, for the types that are one (f64): what lets a spring carry its velocity into a retarget. |
Scroller¶
trait. A node that scrolls and carries a scrollbar: a scroll view or a virtual list, so the bar's geometry, hit-testing, hover, drag and fade are one…
Implemented by: ScrollViewState, TerminalState, TextFieldState, VirtualListState
| Method | Description |
|---|---|
fn bar(&self) -> &ScrollbarState |
|
fn bar_mut(&mut self) -> &mut ScrollbarState |
|
fn defaults(&self) -> Defaults |
Which defaults its unset properties take. |
fn scroll_axes(&self) -> &'static [ScrollAxis] |
The axes it scrolls along, vertical first. |
fn scroll_offsets(&self) -> (f64, f64) |
(x, y): how far its content is scrolled right and down. |
fn offset_anim(&mut self, axis: ScrollAxis) -> &mut Animated<f64> |
The animated offset along axis (only called for one of scroll_axes). |
fn metrics(&self) -> ScrollbarMetrics |
The measures in force. |
fn thumbs(&self, size: (f64, f64), content: (f64, f64), offsets: (f64, f64)) -> [Option<Thumb>; 2] |
The thumbs, [vertical, horizontal], for a view of size over content scrolled to offsets. |
Functions (engine-core)¶
| Function | Description |
|---|---|
fn animations_started() -> u64 |
The number of animations started so far (see STARTED). |
fn box_outline(w: f64, h: f64, radii: [f64; 4], concave: [bool; 4], inset: f64) -> BezPath |
The outline of a w by h box, drawn inset inside its edges (a border's path is inset by half its width), with corner radii in the order… |
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, scale: 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 place(input: &PlaceInput) -> (f64, f64, Placement) |
Where a layer goes, as its top-left corner in window space, and the side it ended on. |
fn shader_animations_pending() -> bool |
Whether any shader has a uniform animation running or waiting to start. |
fn take_cancelled(owned: impl Fn(CompletionHandle) -> bool) -> Vec<CompletionHandle> |
Takes the cancelled-animation handles owned claims; the rest stay for their own window. |
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 |
|---|---|---|
EASINGS |
[(&str, Easing); 11] |
The presets, by the name a property takes. |
FIT_CONTENT_SLACK |
f32 |
Pixels added to a fit width. |
FRAME_BLOCK_SIZE |
usize |
The size in bytes of the per-frame shader uniform block. |
HORIZONTAL_SIDE_NAMES |
[&str; 4] |
The names scrollbar_side_h takes. |
KEY_LINE |
f64 |
How far an arrow key, or a click on an arrow button, scrolls: key_line, scrollbar_arrow_step. |
KEY_SCROLL_LINE |
f64 |
How far an arrow key scrolls a scroll view, in pixels. |
MAX_SCROLL_MILLIS |
f64 |
The most a time property takes: an hour, in milliseconds. |
OUTLINE_ROLE |
SchemeRole |
The role an outline with no colour of its own takes from its window's scheme: the focus ring of the UX specification (Focus Ring, "Colour: role… |
PAGE_DELAY |
Duration |
A press on the lane pages again after this long, then every PAGE_REPEAT: page_repeat_delay_ms, page_repeat_ms. |
PAGE_FRACTION |
f64 |
How much of the viewport a page (Page Up/Down, a click on the lane) scrolls: the viewport less a tenth, so a line of context stays: page_fraction. |
PAGE_REPEAT |
Duration |
|
SCROLLBAR_FADE |
Duration |
A thumb changes opacity over this long (Motion short2): scrollbar_fade_in_ms, scrollbar_fade_out_ms. |
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. |
STATE_LAYER_MS |
f64 |
The fade, in milliseconds: the UX spec's Motion short2. |
VERTICAL_SIDE_NAMES |
[&str; 4] |
The names scrollbar_side_v takes, in BarSide order of VERTICAL_SIDES. |
WHEEL_NOTCH |
f64 |
How far one wheel notch scrolls, in pixels (Lines deltas; Pixels deltas are taken as they come): wheel_notch. |
Re-exports (engine-core)¶
Types re-exported from other crates:
ActionfromaccessActionDatafromaccessAriaCurrentfromaccessLivefromaccessOrientationfromaccessRolefromaccessToggledfromaccess
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 extents(&self) -> Option<Extents<'_>> |
What each node and its subtree paint, as of the last damage call, for a paint walk to skip a subtree that misses the damage. |
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_scale(&mut self, scale: f64) |
Sets the display scale (default 1). |
fn set_scroll_blit_min_nodes(&mut self, nodes: usize) |
Sets how many nodes must move with a scroll for it to be carried by a copy (default SCROLL_BLIT_MIN_NODES); 0 always carries it. |
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. |
fn take_shift(&mut self) -> Option<Shift> |
The scroll shift the last damage call found, if any: apply it to the kept frame before redrawing that call's damage (which is Rects whenever… |
fn visited(&self) -> usize |
How many nodes the last damage call walked. |
fn with_verification() -> Self |
A tracker that also walks the whole tree on every call, and panics when what the incremental walk reports misses a change the full walk finds. |
fn without_scroll_blit() -> Self |
A tracker that walks the whole tree and never plans a scroll shift, to compare against. |
fn without_shortcuts() -> Self |
A tracker that walks the whole tree on every call (no shortcut), for comparing against. |
Extents¶
struct. Each node's subtree extent (see DamageTracker::extents).
FieldColors¶
struct. The three colours a text input paints besides its text: what draw_field_with takes.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
placeholder |
Color |
|
caret |
Color |
|
selection |
Color |
| Method | Description |
|---|---|
fn from_scheme(state: &TextFieldState, scheme: &SchemeColors, alpha: f64) -> Self |
A field with no colour of its own: each of the three is the field's own setting, or the scheme's role. |
fn from_tint(state: &TextFieldState, text: Color) -> Self |
A field with a colour of its own: each of the three is the field's own setting, or text at 60% (placeholder), as it is (caret) and at 30%… |
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. |
FrameProfile¶
struct. A frame's scene-building time, attributed.
Implements: Clone, Debug, Default
| Field | Type | Description |
|---|---|---|
by_kind |
Vec<(&'static str, KindCost)> |
Per kind, in the order first met. |
slowest |
Vec<NodeCost> |
The slowest nodes, slowest first. |
reached |
usize |
Nodes the walk reached, and the time spent in all of them. |
time |
Duration |
| Method | Description |
|---|---|
fn add(&mut self, id: NodeId, kind: &'static str, drawn: bool, time: Duration) |
Adds one node's time. |
FrameRenderer¶
struct. Wraps the vello renderer together with the resources it needs on every render call.
| Method | Description |
|---|---|
fn new(device: &Device, queue: &Queue, config: &RenderTargetConfig) -> Self |
Creates a renderer for the given device and render target configuration. |
fn render(&mut self, scene: &Scene, encoder: &mut CommandEncoder, target: &TextureView) |
Renders scene into target via encoder. |
fn render_into(&mut self, scene: &Scene, encoder: &mut CommandEncoder, 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, encoder: &mut CommandEncoder, target: &TextureView) |
Renders a scene on top of the target's existing pixels without clearing anything. |
fn resources_mut(&self) -> RefMut<'_, 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, scale: f64, 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 set_backdrop(&mut self, color: Color) -> bool |
The colour the frame is cleared to before the scene paints (default transparent); returns whether it changed, in which case the whole frame is out… |
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 sharing(shared: &SharedRenderer, format: TextureFormat) -> Self |
A FrameRenderer that draws with shared's renderer and resources (0.5.9, #235), for a surface of format (the format shared was made for). |
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 concave_box(&mut self, id: NodeId, w: f64, h: f64, radii: [f64; 4], concave: [bool; 4], inset: f64, border: bool) -> &BezPath |
The outline of a box with a concave corner, for a fill (border false) or a border stroke inset by inset (border true). |
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. |
GpuHub¶
struct. A device's health, installed once right after the device is made, and handed out as one GpuWatch per window that draws with it.
Implements: Clone
| Method | Description |
|---|---|
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 to anyone (it is known only once some window has polled the device). |
fn watch(&self) -> GpuWatch |
A watch for one more window on this device. |
GpuTimer¶
struct. Measures GPU time per frame.
| Method | Description |
|---|---|
fn begin(&mut self, encoder: &mut CommandEncoder, frame: u64) |
Starts timing frame's commands: call before recording them. |
fn collect(&mut self, device: &Device) -> Vec<(u64, Duration)> |
The results that have arrived since the last call: (frame, GPU time). |
fn end(&mut self, encoder: &mut CommandEncoder) |
Ends the frame's timing: call after recording its last command, before finishing the encoder. |
fn new(device: &Device, queue: &Queue) -> Option<Self> |
A timer for device, or None when it was not created with required_features. |
fn submitted(&mut self) |
The frame's encoder was submitted: ask for its result. |
GpuWatch¶
struct. One window's view of its device's health.
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 |
A device used by one window: a GpuHub and its only watch. |
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. |
KindCost¶
struct. What nodes of one kind cost in a frame.
Implements: Clone, Copy, Debug, Default, PartialEq
| Field | Type | Description |
|---|---|---|
reached |
usize |
Nodes of the kind the walk reached. |
drawn |
usize |
Of those, how many drew themselves (the rest were outside the damage). |
time |
Duration |
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. |
NodeCost¶
struct. One node's own time.
Implements: Clone, Copy, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
id |
NodeId |
|
kind |
&'static str |
|
drawn |
bool |
|
time |
Duration |
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 shift_region(&mut self, device: &Device, encoder: &mut CommandEncoder, region: (u32, u32, u32, u32), dx: i32, dy: i32) |
Moves region (x0, y0, x1, y1, in pixels) of the kept frame by (dx, dy): what stays inside the region lands dx, dy further on, and the rest… |
fn size(&self) -> (u32, u32) |
The target's size in pixels. |
fn view(&self) -> &TextureView |
The view to render the scene into. |
ResizePacing¶
struct. Whether a window is being resized, and so presents without vsync for the moment.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Method | Description |
|---|---|
fn active(&self) -> bool |
Whether resize pacing is in effect (a resize is in progress, or ended less than RESIZE_HOLD ago). |
fn choice(&self, steady: PresentChoice) -> PresentChoice |
What to present with, given the app's steady choice: low latency while resizing, the app's choice otherwise. |
fn presented(&mut self, now: Instant) |
The window presented at now. |
fn resized(&mut self, now: Instant) |
The window is being given a new size at now. |
fn settle(&mut self, now: Instant) -> bool |
Ends resize pacing once now is RESIZE_HOLD past the last resize. |
fn throttle(&self, now: Instant) -> Option<Duration> |
How long the window must still wait before it may present again at now: None when it may present now (not resizing, nothing presented yet, or… |
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. |
SharedRenderer¶
struct. A vello_gpu renderer that several windows draw with (0.5.9, #235).
Implements: Clone
| Method | Description |
|---|---|
fn downgrade(&self) -> WeakSharedRenderer |
A handle that does not keep the renderer alive, for a registry of the renderers windows can still take. |
fn for_format(device: &Device, queue: &Queue, format: TextureFormat, width: u32, height: u32) -> Self |
Like new from plain values: a renderer for surfaces of format, starting at width x height (clamped to what the renderer takes). |
fn holders(&self) -> usize |
How many `FrameRenderers` draw with this one (itself included). |
fn new(device: &Device, queue: &Queue, config: &RenderTargetConfig) -> Self |
A renderer for config.format on device. |
Shift¶
struct. A scroller's content moved as a block.
Implements: Debug, Clone, Copy, PartialEq
| Field | Type | Description |
|---|---|---|
region |
Rect |
|
dx |
f64 |
|
dy |
f64 |
Snapshot¶
struct. A rendered frame: width * height pixels, row by row, four bytes (R, G, B, A) each, with no row padding.
Implements: Debug, Clone, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
width |
u32 |
|
height |
u32 |
|
rgba |
Vec<u8> |
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. |
box_height |
Option<f32> |
The height of the node's content box, when the text is to be aligned vertically in it (the node's own vertical_align: the lines' own height is… |
TextRenderer¶
struct. Holds the font and text layout state that is kept between frames.
Implements: Default
| Method | Description |
|---|---|
fn access_lines(&mut self, node_id: NodeId, state: &TextState, at: TextPlacement) -> Vec<AccessLine> |
The shown lines of a static text node, with where each character sits, for its accessibility runs. |
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_field_with(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TextFieldState, at: TextPlacement, show_caret: bool, node_id: NodeId, colors: FieldColors) |
draw_field with the placeholder, caret and selection colours given, for a field whose colours the window's scheme decides… |
fn draw_painted(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TextState, at: TextPlacement, node_id: NodeId, gradient: Option<&Gradient>, selection_fill: Option<Color>) |
draw, with the glyphs painted by a gradient (0.5.4, #129) instead of the flat at.color, resolved against the shaped text's own extent (not the… |
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 draw_terminal_with(&mut self, scene: &mut Scene, resources: &mut Resources, state: &TerminalState, at: TextPlacement, show_caret: bool, node_id: NodeId, palette: &ResolvedPalette) |
draw_terminal with the palette resolved by the caller: the terminal's own colours and, where it has none, its window's scheme… |
fn evict_stale_layouts(&mut self, tree: &Tree) |
Drops cached text layouts belonging to nodes that no longer exist in the tree. |
fn field_caret_rect(&mut self, state: &TextFieldState, at: TextPlacement) -> Rect |
The caret's rectangle in the field's own coordinates (at placing the text in the node, scroll offsets already in it): the bar's, with… |
fn field_content_extent(&mut self, state: &TextFieldState, viewport: (f32, f32)) -> Option<((f64, f64), u64)> |
How big the shaped text of input state is, (width, height) in pixels, for a content box viewport wide (a wrapped input's lines break at it)… |
fn field_range_rects(&mut self, state: &TextFieldState, at: TextPlacement, start: usize, end: usize) -> Vec<Rect> |
The rectangles covering start..end (bytes of state.content), one per line it crosses, in the field's coordinates. |
fn field_rows(&mut self, state: &TextFieldState, viewport: (f32, f32), query: RowQuery) -> Option<RowAnswer> |
Answers a engine_core::RowQuery about text input state shown in a content box of viewport (width, height), by the shaped rows (the same layout… |
fn field_unit_at(&mut self, state: &TextFieldState, at: TextPlacement, point: Point) -> Option<(usize, usize, usize)> |
For a double or triple click at point (in the same space as at, which places the text in the node, scroll included): the byte offset in… |
fn follow_caret(&mut self, state: &TextFieldState, viewport: (f32, f32)) -> Option<(f64, f64, u64)> |
Where text input state's scroll offsets should be so its caret is in view, for a content box of viewport (width, height) and the offsets it has… |
fn glyph_cache(&self) -> bool |
|
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 hit_test_text(&mut self, node_id: NodeId, state: &TextState, at: TextPlacement, point: Point) -> usize |
The byte offset in a text node's content nearest point, a local point in the node, resolved against the layout the node paints (draw): how a… |
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 move_focus_lines(&mut self, node_id: NodeId, state: &TextState, at: TextPlacement, anchor: usize, focus: usize, delta: isize) -> usize |
Where the selection's moving end goes when moved delta lines (negative up) in a static text node, keeping the horizontal place it was at: the new… |
fn new() -> Self |
Creates a text renderer with the bundled fonts loaded. |
fn set_glyph_cache(&mut self, on: bool) |
Draws glyphs from a cache of rendered glyph images (the renderer's glyph atlas) instead of drawing every glyph's outline every frame. |
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. |
fn text_offset_under(&mut self, node_id: NodeId, state: &TextState, at: TextPlacement, point: Point) -> Option<usize> |
The byte offset of the character under point (a local point in the node), or None when the point is past the text. |
fn text_range_at(&mut self, node_id: NodeId, state: &TextState, at: TextPlacement, point: Point, line: bool) -> (usize, usize) |
The bytes of the word (lines == false) or the visual line (lines == true) at point, for a double or triple click. |
WeakSharedRenderer¶
struct. A SharedRenderer that is freed when the windows using it are.
Implements: Clone
| Method | Description |
|---|---|
fn upgrade(&self) -> Option<SharedRenderer> |
The renderer, if some window still uses it. |
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 last_shift(&self) -> Option<Shift> |
The scroll shift the last prepare found and draw applied, if any. |
fn new(device: &Device, queue: &Queue, 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_backdrop(&mut self, color: Color) |
The colour every frame is cleared to before the scene paints over it (default transparent). |
fn set_glyph_cache(&mut self, on: bool) |
Draws text from the glyph cache (see TextRenderer::set_glyph_cache). |
fn set_persistent(&mut self, device: &Device, width: u32, height: u32, on: bool) -> bool |
Keeps the frame or lets it go, live. |
fn set_profiling(&mut self, on: bool) |
Turns the per-node timing of the paint walk on or off (default off: it costs two clock reads a node). |
fn set_scale(&mut self, scale: f64) |
Sets the display scale (default 1.0): layout stays in logical pixels and everything drawn, culled and damaged is in physical ones. |
fn set_scroll_blit_min_nodes(&mut self, nodes: usize) |
How many nodes must move with a scroll for it to be carried by a copy instead of redrawn (default SCROLL_BLIT_MIN_NODES); 0 always does. |
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 sharing(device: &Device, format: TextureFormat, width: u32, height: u32, persistent: bool, shared: &SharedRenderer) -> Self |
Like new, drawing with shared's vello_gpu renderer instead of making one (0.5.9, #235). |
fn take_profile(&mut self) -> Option<FrameProfile> |
What the last draw spent per node, when profiling was on for it. |
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 all_fonts() -> (u64, Vec<Arc<Vec<u8>>>) |
Every face text can use — the bundled ones, then the registered ones — as raw font files, for something outside the renderer that shapes text itself… |
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]>, extents: Option<Extents<'_>>, profile: Option<&mut FrameProfile>, shaders: &ShaderTextures, scale: f64, 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 font_generation() -> u64 |
Current registry generation. |
fn gpu_timer_features() -> Features |
The features a device needs for GpuTimer. |
fn linear_surface_format(supported: &[TextureFormat]) -> Option<TextureFormat> |
The surface format to render into, out of those it supports. |
fn notify_flight() |
Wakes the threads in wait_while_idle to look again: a submission was made, or one of them is to give up. |
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 set_system_fonts(enabled: bool) |
Lets (or stops) every TextRenderer in this process use the system's installed fonts. |
fn snapshot(device: &Device, queue: &Queue, tree: &Tree, root: NodeId, width: u32, height: u32, scale: f64, time: f32) -> Result<Snapshot, String> |
Renders tree (already laid out) as root's window of width x height physical pixels at display scale, with shaders seeing time seconds. |
fn snapshot_with(device: &Device, queue: &Queue, tree: &Tree, root: NodeId, width: u32, height: u32, scale: f64, time: f32, glyph_cache: bool) -> Result<Snapshot, String> |
snapshot, drawing text from the glyph cache when glyph_cache (0.5.4, #127), as a window that has it on does. |
fn system_fonts() -> bool |
Whether system fonts are on (set_system_fonts). |
fn transparent_alpha_mode(supported: &[CompositeAlphaMode]) -> Option<CompositeAlphaMode> |
The alpha mode for a see-through window, out of those the surface supports, or None where it can't blend with the desktop at all. |
fn wait_while_idle(give_up: &AtomicBool) |
Blocks while no submission is in flight and give_up is false, with no timer: a host's helper thread that must watch the GPU only while it works… |
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. |
PROFILE_SLOWEST |
usize |
How many of the slowest nodes a profile keeps. |
RESIZE_HOLD |
Duration |
How long after the last resize a window keeps its resize pacing: long enough that a sweep with brief pauses is one resize, short enough that an… |
SCROLL_BLIT_MIN_NODES |
usize |
How many nodes must move with a scroll before it is carried by a copy rather than redrawn. |
engine-platform¶
The winit event loop, window creation, platform input translation and the accessibility adapter.
Anchors¶
struct. The screen edges a surface is anchored to, as the protocol's bit field.
Implements: Clone, Copy, Debug, Default, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
0 |
u8 |
| Method | Description |
|---|---|
fn can_reserve(self) -> bool |
Whether the protocol gives a positive exclusive zone to this anchor set: one edge alone, or one edge with both edges across it (a bar anchored top… |
fn contains(self, edge: u8) -> bool |
|
fn edge(name: &str) -> Option<u8> |
|
fn is_empty(self) -> bool |
|
fn names(self) -> Vec<&'static str> |
The edge names set, in the order top, bottom, left, right. |
ConfigError¶
struct. Why a configuration was refused: the Python-level key, and what is wrong.
Implements: Clone, Debug, PartialEq, Eq, Display, Error
| Field | Type | Description |
|---|---|---|
key |
&'static str |
|
message |
String |
ConfigWarning¶
struct. Something the protocol accepts but that probably is not what was meant.
Implements: Clone, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
key |
&'static str |
|
message |
String |
EdgeFit¶
struct. What the positioner is given for a popup with an edge_margin.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
applied |
(i32, i32, i32, i32) |
The margin that fits in the surface, (top, right, bottom, left). |
geometry |
Rect |
The window geometry and positioner size: the body grown by applied. |
anchor_rect |
Rect |
The anchor rectangle, moved so the body, not the grown rectangle, lands where the unmargined popup would, flipped or not. |
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 open_layer(&self, request: LayerRequest) |
Asks the loop to open a layer surface while it runs, or before (WindowOpener); the result reaches the LayerHooks. |
fn open_window(&self, request: WindowRequest) |
Asks the loop to open another window while it runs. |
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 stop(&self) -> bool |
Asks the loop to end: every window and layer surface is closed (each hears closed; close_requested is skipped) and the loop returns. |
fn wake(&self) |
Requests a redraw of every open window, doing nothing if the loop has exited. |
fn watch_outputs(&self) |
Asks the loop to start reporting output changes to the LayerHooks, if it is not already. |
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. |
ImeInfo¶
struct. What the input method needs to know about the focused text input of a layer surface.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
area |
(i32, i32, i32, i32) |
The caret's box (x, y, width, height) in surface-local logical pixels, where the input method puts its candidate window. |
password |
bool |
A password field: the input method should not learn or suggest from it. |
LayerConfig¶
struct. Everything that makes a layer surface what it is.
Implements: Clone, Debug, PartialEq, Eq, Default
| Field | Type | Description |
|---|---|---|
namespace |
String |
What the surface is for ("tesserae-shell.bar"): the protocol's namespace. |
layer |
LayerKind |
|
anchor |
Anchors |
|
size |
(u32, u32) |
(width, height) in logical pixels; 0 on an axis stretches between the two edges anchored on it. |
exclusive_zone |
i32 |
Pixels to reserve along the anchored edge; 0 reserves none; -1 ignores other surfaces' zones. |
exclusive_edge |
Option<u8> |
For a surface anchored to a corner: which edge its positive zone is for. |
margin |
(i32, i32, i32, i32) |
(top, right, bottom, left), in logical pixels. |
keyboard |
KeyboardMode |
|
output |
Option<String> |
A connector name ("DP-1"); None lets the compositor choose. |
input_region |
Option<Vec<Rect>> |
Where the compositor delivers pointer and touch input, as (x, y, width, height) rectangles in logical pixels from the surface's top-left. |
| Method | Description |
|---|---|
fn validate(&self) -> Result<Vec<ConfigWarning>, ConfigError> |
Refuses what the protocol would answer with a fatal error, naming the key; for what it accepts but ignores, returns a warning. |
LayerController¶
struct. A handle that sends requests to the layer thread; cheap to clone.
Implements: Clone
| Method | Description |
|---|---|
fn begin_margin_drag(&self, id: u64) |
Starts moving the surface by its margins with the pointer, which must be pressed on it: the layer thread follows the pointer and ends the drag on… |
fn create(&self, id: u64, config: LayerConfig) |
Makes the surface id from config; its events follow. |
fn create_popup(&self, id: u64, config: PopupConfig) |
Makes the popup surface id from config; its events follow. |
fn destroy(&self, id: u64) |
Destroys the surface; the wgpu surface must be dropped first. |
fn frame_pending(&self, id: u64) -> bool |
Whether a frame callback asked for by request_frame is out. |
fn request_activation_token(&self, id: u64, request: u64, app_id: Option<String>) |
T-051: asks the compositor for an xdg_activation_v1 token for the surface id, so an app this one starts (XDG_ACTIVATION_TOKEN) can take focus. |
fn request_frame(&self, id: u64) |
Asks the compositor for a frame callback with the next commit of the surface id, which the caller's present makes. |
fn set_cursor(&self, id: u64, icon: CursorIcon) |
Sets the pointer's shape over the surface. |
fn set_ime(&self, id: u64, info: Option<ImeInfo>) |
Tells the input method about the surface's focused text input (None: none has focus): the layer thread enables text input for the surface, places… |
fn set_input_region(&self, id: u64, region: Option<Vec<Rect>>) |
Sets only the input region (None: the whole surface) and applies it at once, with a commit of its own: an idle surface draws no frame to carry it. |
fn set_margin(&self, id: u64, margin: (i32, i32, i32, i32)) |
Sets only the margin (top, right, bottom, left) and commits it at once: one cheap commit per animation step, with no other property re-sent. |
fn set_size(&self, id: u64, size: (u32, u32)) |
TRE-REQ-022: asks the compositor for a new size (logical pixels) for the surface id and nothing else; the compositor answers with a configure… |
fn update(&self, id: u64, config: LayerConfig) |
Applies config to the surface id in one commit. |
LayerHooks¶
struct. The host's side of the loop for layer surfaces.
| Field | Type | Description |
|---|---|---|
on_created |
Box<dyn FnMut(WindowId, u64, LayerSurfaceInfo) -> bool> |
The surface has a size: build the GPU side from the info. |
on_notice |
Box<dyn FnMut(WindowId, u64, LayerNotice)> |
(id, token, notice). |
on_output |
Box<dyn FnMut(OutputEvent)> |
An output appeared, changed or went (only when watch_outputs is set, or a layer window has made the layer thread start). |
watch_outputs |
bool |
Start the layer thread at once, to report outputs, even with no layer window. |
on_shutdown |
Box<dyn FnMut()> |
The loop is ending: drop every GPU surface made from a layer surface now, while the Wayland connection is still alive (it is gone once the loop… |
LayerHost¶
struct. The layer thread and its connection.
Implements: Drop
| Method | Description |
|---|---|
fn controller(&self) -> LayerController |
|
fn display(&self) -> RawPtr |
|
fn start(display: NonNull<c_void>, on_event: impl Fn(LayerEvent) -> bool + Send + 'static) -> Result<Self, LayerError> |
Starts the layer thread on winit's wl_display. |
LayerRequest¶
struct. A request to open a layer surface: what engine-py hands the loop.
| Field | Type | Description |
|---|---|---|
token |
u64 |
Which registered window this is; handed back in the hooks. |
config |
LayerConfig |
|
popup |
Option<PopupConfig> |
A popup, not a layer surface: config is then unused. |
max_frames |
Option<u32> |
Auto-exit after this many frames (a self-asserting demo or test), as a window's. |
LayerSurfaceInfo¶
struct. What a host needs to draw a layer surface once the compositor has sized it.
| Field | Type | Description |
|---|---|---|
id |
u64 |
|
display |
RawPtr |
|
surface |
RawPtr |
|
width |
u32 |
The buffer's size in physical pixels (logical * scale). |
height |
u32 |
|
scale |
f64 |
|
controller |
LayerController |
For update, set_cursor and destroy. |
LoopOptions¶
struct. How the loop behaves when it has nothing to draw.
Implements: Default
| Field | Type | Description |
|---|---|---|
keep_alive |
bool |
Keep running when no window and no layer surface is open: a desktop shell that waits for an output to come back. |
on_wake |
Option<Box<dyn FnMut()>> |
Runs on a EventLoopWaker::wake that no window answers with a frame (not once the loop is exiting). |
OutputInfo¶
struct. One output, as of the moment it was read.
Implements: Clone, Debug, PartialEq
| Field | Type | Description |
|---|---|---|
name |
String |
The connector name ("DP-1", "HDMI-A-1"): stable across runs, unlike the compositor's own numbering. |
description |
String |
|
x |
i32 |
The output's top-left in the desktop's logical layout. |
y |
i32 |
|
width |
u32 |
The output's logical size. |
height |
u32 |
|
scale_factor |
f64 |
Physical over logical pixels. |
transform |
String |
"normal", "90", "180", "270", or one of those with "flipped_" before it. |
PopupConfig¶
struct. A popup (xdg_popup) parented to a layer surface or to another popup.
Implements: Clone, Debug, PartialEq, Eq
| Field | Type | Description |
|---|---|---|
parent |
u64 |
The parent surface's number (the layer thread's id for it). |
size |
(u32, u32) |
(width, height) in logical pixels: the positioner needs it before the popup exists. |
anchor_rect |
(i32, i32, i32, i32) |
A rectangle in the parent's surface coordinates the popup is placed against. |
anchor |
PopupEdge |
The point on that rectangle the popup attaches to. |
gravity |
PopupEdge |
The direction the popup extends from that point. |
adjustments |
u32 |
What the compositor may do to keep it on screen (adjust bits). |
offset |
(i32, i32) |
A fixed shift after placement, in logical pixels. |
grab |
bool |
Whether the popup grabs the keyboard and pointer, so an outside click ends it (Escape does not: the popup gets the key, on KWin and sway alike). |
geometry |
Option<Rect> |
The popup's body, (x, y, width, height) in the popup's own pixels, inside size. |
edge_margin |
(i32, i32, i32, i32) |
(top, right, bottom, left), the distance in logical pixels the compositor keeps between the body and the edge of the output when it flips or… |
input_region |
Option<Vec<Rect>> |
Where the compositor delivers input, (x, y, width, height) rectangles in the popup's own logical pixels (margin included). |
| Method | Description |
|---|---|
fn edge_fit(&self) -> EdgeFit |
The window geometry, positioner size and anchor rectangle that give the body edge_margin of clearance from the output's edge: the body grown by… |
fn validate(&self) -> Result<(), ConfigError> |
Refuses what the protocol would answer with a fatal error, naming the key. |
RawPtr¶
struct. A pointer to the process's wl_display, or to one of its wl_surfaces: what a wgpu surface is made from.
Implements: Clone, Copy, Debug
| Field | Type | Description |
|---|---|---|
0 |
NonNull<c_void> |
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_layer(&self, request: LayerRequest) |
Queues a layer surface to open as the loop starts. |
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. |
transparent |
bool |
Whether the window can be see-through: asks the OS for a window with an alpha channel. |
blur |
bool |
Asks the compositor to blur what is behind the window, where it can (Wayland with KDE's blur protocol, macOS). |
click_through |
bool |
The window ignores the pointer: clicks, scrolls and hover pass to whatever is behind it. |
position |
Option<(f64, f64)> |
Where the window's top-left corner opens, in logical pixels on the desktop; None lets the system place it. |
always_on_top |
bool |
Keep the window above others (a hint on X11; ignored on Wayland). |
resizable |
bool |
Whether the user can resize the window. |
skip_taskbar |
bool |
Keep the window off the taskbar (Windows only). |
undecorated_shadow |
bool |
Keep the OS's shadow around an undecorated window (Windows only; a decorated window has it anyway, and elsewhere the compositor decides). |
start_hidden |
bool |
Leave the window hidden after it is made; the host shows it (Window::set_visible(true)) once its first frame is presented, so the OS never shows… |
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. |
Availability¶
enum. Whether layer surfaces can be made here.
Implements: Clone, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Supported |
The compositor offers zwlr_layer_shell_v1. |
|
Headless |
No display at all (a CI run): a layer window can be built and driven with simulate, advance and snapshot, but not opened. |
|
Unsupported |
(String) |
A display with no layer shell (X11, GNOME's Mutter, Windows, macOS); the string says why. |
CloseReason¶
enum. Why a layer surface ended.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Compositor |
The compositor closed it. | |
OutputRemoved |
The output it was bound to went away. | |
App |
The app closed it. | |
Dismissed |
A popup the compositor ended: an outside click, or its parent going away (Escape does not end a grabbing popup: the popup hears the key and nobody… |
KeyboardMode¶
enum. How the surface takes the keyboard.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
None |
Never: it gets no key events. | |
OnDemand |
Whenever the user focuses it (a click, say). | |
Exclusive |
At once, and no other surface gets keys until it lets go. |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
LayerError¶
enum. Why the layer side could not start.
Implements: Clone, Debug, PartialEq, Eq, Display, Error
| Variant | Payload | Description |
|---|---|---|
Unsupported |
(String) |
Not a Wayland session, or the compositor has no layer shell. |
LayerEvent¶
enum. What the layer thread tells the loop.
Implements: Debug
| Variant | Payload | Description |
|---|---|---|
Created |
{ id: u64, display: RawPtr, surface: RawPtr } |
The surface exists: build its wgpu surface from display and surface. |
Configure |
{ id: u64, width: u32, height: u32, scale: f64 } |
The compositor assigned a size (width x height, logical pixels) and the surface's scale is scale: the buffer is width * scale by `height *… |
Rescale |
{ id: u64, width: u32, height: u32, scale: f64 } |
The surface's scale changed with the size staying the same. |
FrameDone |
{ id: u64 } |
The compositor answered the frame callback asked for with the surface's last frame: it may be drawn again. |
Closed |
{ id: u64, reason: CloseReason } |
The surface is gone. |
Failed |
{ id: u64, message: String } |
The surface could not be made (an output name that matches nothing, say). |
Input |
{ id: u64, event: InputEvent } |
Input for the surface, in physical pixels like the winit path's. |
OutputChanged |
{ id: u64, name: String } |
The surface entered the output with this connector name. |
Output |
(OutputEvent) |
An output appeared, changed or went away (not sent for the ones that existed when the layer thread started). |
MarginMoved |
{ id: u64, margin: (i32, i32, i32, i32) } |
A margin drag the engine ran ended; margin is (top, right, bottom, left). |
PopupPlaced |
{ id: u64, x: i32, y: i32 } |
Where the compositor placed a popup, in its parent's surface coordinates (logical px). |
Warning |
{ id: u64, key: &'static str, message: String } |
A setting this compositor cannot take (an older layer shell): the surface opens anyway. |
ActivationToken |
{ id: u64, request: u64, token: Option<String> } |
T-051: the answer to LayerController::request_activation_token: the token, or None when the compositor has no xdg_activation_v1. |
LayerKind¶
enum. The stacking layer: what the surface sits above and below.
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
Background |
||
Bottom |
||
Top |
||
Overlay |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
LayerNotice¶
enum. Something that happened to a layer surface that is not input or a frame.
Implements: Debug
| Variant | Payload | Description |
|---|---|---|
Closed |
(CloseReason) |
|
OutputChanged |
(String) |
|
Failed |
(String) |
It could not be made. |
MarginMoved |
((i32, i32, i32, i32)) |
A margin drag ended: the final (top, right, bottom, left). |
PopupPlaced |
(i32, i32) |
Where the compositor placed a popup (parent coordinates, logical px). |
Warning |
(&'static str, String) |
A setting the compositor cannot take: (key, message). |
ActivationToken |
(u64, Option<String>) |
T-051: the answer to an activation-token request: (request, token), None when the compositor has no xdg_activation_v1. |
OutputEvent¶
enum. What changed in the set of outputs.
Implements: Clone, Debug, PartialEq
| Variant | Payload | Description |
|---|---|---|
Added |
(OutputInfo) |
|
Updated |
(OutputInfo) |
Moved, resized, rescaled or rotated. |
Removed |
(OutputInfo) |
PopupEdge¶
enum. A point on a rectangle, or the direction a popup extends from one (xdg_positioner's anchor and gravity share these nine values).
Implements: Clone, Copy, Debug, PartialEq, Eq
| Variant | Payload | Description |
|---|---|---|
None |
||
Top |
||
Bottom |
||
Left |
||
Right |
||
TopLeft |
||
BottomLeft |
||
TopRight |
||
BottomRight |
| Method | Description |
|---|---|
fn name(self) -> &'static str |
|
fn parse(name: &str) -> Option<Self> |
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 availability() -> Availability |
Where this process stands on layer surfaces, as first found out. |
fn availability_with(refresh: bool) -> Availability |
As availability; refresh asks the compositor again instead of using the remembered answer. |
fn default_output(outputs: &[(String, i32, i32)]) -> Option<usize> |
Which output a surface with no output goes to, given each output's (name, x, y): the one at (0, 0), else the first by name. |
fn double_click_time() -> Duration |
Returns the longest gap between two presses that still counts as a double-click. |
fn effective_scale(mode: Option<(i32, i32)>, logical: Option<(i32, i32)>, transform: &str, integer_scale: i32) -> f64 |
The effective scale: the current mode's physical size over the logical size, rounded to 1/120 (the unit the fractional-scale protocol speaks), so… |
fn layer_window_id(n: u64) -> WindowId |
The WindowId the loop uses for layer surface number n. |
fn outputs() -> Vec<OutputInfo> |
The outputs this session's compositor has, read now on a connection of its own, in order of position (top to bottom, left to right). |
fn parse_anchor<'a>(names: impl IntoIterator<Item = &'a str>) -> Result<Anchors, ConfigError> |
The edge names the Python layer accepts for anchor and exclusive_edge. |
fn platform_name(window: Option<&Window>) -> &'static str |
Returns the windowing system the window runs on, such as wayland, x11, windows or macos. |
fn region_from_floats(rects: &[(f64, f64, f64, f64)]) -> Result<Vec<Rect>, ConfigError> |
Explicit rectangles as given (floats, logical pixels) to whole-pixel ones, rounded outward so a rectangle never shrinks: a click on a pixel the app… |
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>, layers: Option<LayerHooks>, options: LoopOptions) -> Result<(), EventLoopError> |
Runs the multi-window loop with optional hooks around its idle wait. |
fn supported(refresh: bool) -> bool |
Whether this session's compositor offers zwlr_layer_shell_v1: false off Wayland, on X11, and on a compositor without it (GNOME's). |
fn transform_name(value: u32) -> &'static str |
The names the Python layer shows for a Wayland transform, by its protocol value (wl_output.transform: 0 normal, 1 to 3 rotations, 4 flipped, 5 to… |
fn turn_instant() -> Instant |
The instant the loop's current turn began, or the real clock off the loop (headless). |
Constants (engine-platform)¶
| Constant | Type | Description |
|---|---|---|
MAX_REGION_RECTS |
usize |
The most rectangles one input region may have. |