Expand description
2D scene graph of oxframe.
Status: oxframe is under very active development. The API is not stable yet and may change from version to version. Pin the exact version in your Cargo.toml and check the changelog before upgrading.
Scene code creates nodes with builders (Rect::new().width(100.0)) and
adds them with Node::add (view.add(..)), which returns a Copy
handle whose zero-argument methods of the same names return
Signals:
ⓘ
let r = view.add(Rect::new().size(200.0).x(-300.0));
r.x().to(300.0, 1.0).await;Renderers consume a flat DrawItem list produced by
SceneGraph::draw_list, so every backend draws exactly the same thing.
Re-exports§
pub use builder::CameraBuilder;pub use builder::CircleBuilder;pub use builder::CodeBuilder;pub use builder::CustomBuilder;pub use builder::GridBuilder;pub use builder::GroupBuilder;pub use builder::ImgBuilder;pub use builder::LayoutBuilder;pub use builder::LineBuilder;pub use builder::NodeBuilder;pub use builder::ParticlesBuilder;pub use builder::PathBuilder;pub use builder::PolygonBuilder;pub use builder::RectBuilder;pub use builder::StarBuilder;pub use builder::TxtBuilder;pub use graph::Direction;pub use graph::InspectNode;pub use graph::Justify;pub use graph::LayoutAlign;pub use graph::NodeId;pub use graph::SceneGraph;pub use theme::Corner;pub use theme::Ink;pub use theme::Ink::Accent;pub use theme::Ink::Background;pub use theme::Ink::Danger;pub use theme::Ink::Muted;pub use theme::Ink::OnAccent;pub use theme::Ink::Success;pub use theme::Ink::Surface;pub use theme::Ink::Text;pub use theme::Ink::Warning;pub use theme::IntoPaint;pub use theme::Len;pub use theme::Motion;pub use theme::Pace;pub use theme::Pace::Fast;pub use theme::Pace::Normal;pub use theme::Pace::Slow;pub use theme::Scale;pub use theme::ShadowSpec;pub use theme::Step;pub use theme::Step::Lg;pub use theme::Step::Md;pub use theme::Step::Sm;pub use theme::Step::Xl;pub use theme::Step::Xs;pub use theme::Theme;pub use theme::TypeRole;pub use theme::TypeScale;pub use theme::TypeStyle;
Structs§
- Camera
- Handle to a
Cameranode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Camera
Builder - A camera: everything added to it is seen through it, so animating its
x/y(the point it looks at),zoomandrotationpans, zooms and turns the view. Nodes added to the view itself stay on screen (titles, captions, a HUD). - Circle
- Handle to a
Circlenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Circle
Builder - Builder for a
Circlenode: set the initial values, then pass it toadd. - Code
- Handle to a
Codenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Code
Builder - Builder for a
Codenode: set the initial values, then pass it toadd. - Code
Text - The source of a
Codenode. - Code
Theme - Colors of a code theme.
- Code
Tween - Diff tween returned by
CodeText::to,Code::insert,Code::removeandCode::replace. - Color
- sRGB color with straight (non-premultiplied) alpha, components in
0..=1. - Custom
- Handle to geometry drawn by a closure. Derefs to
Node. - Custom
Builder - Builder for a
Customnode. - DrawCtx
- What a
crate::Customnode draws into. Coordinates are the node’s own: the origin is the node center, positive x is right, positive y is down. - Draw
Item - One thing to paint, in local coordinates of
transform. Paints already include the node’s opacity (unless the node draws into a layer). - DrawRng
- A generator from
DrawCtx::rng. - Gradient
- A gradient in the node’s local coordinates (origin at the node center).
- Grid
- Handle to a
Gridnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Grid
Builder - Builder for a
Gridnode: set the initial values, then pass it toadd. - Group
- Handle to a
Groupnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Group
Builder - Builder for a
Groupnode: set the initial values, then pass it toadd. - Img
- Handle to a
Imgnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - ImgBuilder
- Builder for a
Imgnode: set the initial values, then pass it toadd. - Inspect
Node - A node as
oxframe inspectand the visual linter see it. - Layer
- Everything drawn until the matching
Primitive::PopLayeris rendered into its own buffer, filtered, clipped and composited as a whole. - Layout
- Handle to a
Layoutnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Layout
Builder - Places children in a row or column. Children’s
x/ybecome offsets from their layout position. - Line
- Handle to a
Linenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Line
Builder - Builder for a
Linenode: set the initial values, then pass it toadd. - Motion
- Durations in seconds and the eases for entering, leaving and emphasis.
- Node
- Untyped node handle with the properties every node has.
- NodeId
- Index of a node in its
SceneGraph. Assigned in creation order, so it is deterministic too. - Particles
- Handle to a
Particlesnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Particles
Builder - Builder for a
Particlesnode. - Path
- Handle to a
Pathnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Path
Builder - Builder for a
Pathnode: set the initial values, then pass it toadd. - Pen
- A shape just added to a
DrawCtx, waiting for a fill or a stroke. - Polygon
- Handle to a
Polygonnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Polygon
Builder - Builder for a
Polygonnode: set the initial values, then pass it toadd. - Raster
Image - Decoded raster image: sRGB RGBA8, straight alpha.
- Rect
- Handle to a
Rectnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Rect
Builder - Builder for a
Rectnode: set the initial values, then pass it toadd. - Rich
Span - A run of text with its own look; unset fields use the node’s style.
- Safe
Area - The rectangle
to_edgekeeps inside, in scene coordinates (origin at the center, y down). - Scale
- Five pixel sizes, smallest to largest.
- Scene
Graph - Arena of nodes for one scene run. Node 0 is the view (root).
- Shadow
- Drop shadow of a layer.
- Shadow
Spec - A drop shadow.
- Signal
- A reactive value.
- Star
- Handle to a
Starnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Star
Builder - Builder for a
Starnode: set the initial values, then pass it toadd. - Stroke
Style - How an outline is drawn.
- Svg
- Handle to a
Svgnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Theme
- Colors, type, space, radii, shadows and motion for one look.
- Txt
- Handle to a
Txtnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - TxtBuilder
- Builder for a
Txtnode: set the initial values, then pass it toadd. - Type
Scale - Display, headings, body, caption and code.
- Type
Style - One text role: size in pixels, weight 100..=900, line height as a multiple.
- Vector
Image - SVG converted to filled/stroked paths (gradients become their first stop color in v1).
- Vector
Shape - One painted path of a
VectorImage. - View
- Root of a scene. Origin is the center of the frame, y points down.
Enums§
- Blend
Mode - How a node’s layer is composited onto what is below it.
- Direction
- Main axis of a
Layout. - Edge
- An edge of a node or of the safe area.
- Gradient
Kind - Shape of a
Gradient. - Image
Source - Decoded image data for an
Imgnode. - Ink
- A color role. Use it wherever a
Coloris accepted:.fill(Accent). - Justify
- Main-axis distribution of children; only matters with a fixed size.
- Lang
- Language for syntax highlighting.
- Layout
Align - Cross-axis alignment of children in a
Layout. - LineCap
- Shape of the ends of open outlines.
- Line
Join - Shape of outline corners.
- Pace
- How long a motion token lasts:
.to(1.0, Normal). - Paint
- What a shape is filled or stroked with.
- Place
- How a node is placed. Resolved every frame; not set by scene code directly.
- Primitive
- A drawing operation in a
DrawItem. - Side
- Which side of a neighbor
Node::next_touses. - Span
- A length in pixels, or a percentage of the frame (or of a sized parent).
- Step
- A step on the space, radius and shadow scales:
.padding(Md),.radius(Lg). - Text
Align - Horizontal alignment of lines.
- Type
Role - Which type role
.display(),.h1()and the others select.
Constants§
- MONO
- Built-in monospace family (JetBrains Mono).
- SANS
- Built-in sans-serif family (Inter).
- SLIDE_
DISTANCE - How far
Node::slide_instarts from the node’s place, in pixels.
Traits§
- Corner
- A corner radius: pixels, or a
Stepon the radius scale. - Into
Paint - Something that can be used as a color: a
Coloror anInk. - Len
- A padding, gap or margin: pixels, or a
Stepon the space scale. - Node
Builder - Describes a node before it is added to the scene.
- Percent
- A number that can be a percentage.
pct(80)andpct(80.0)are the same.
Functions§
- current_
theme - Theme of the scene that is running, or the dark theme outside one.
The theme of the scene that is running, or
Theme::darkoutside one. - enter_
theme - Installs
themefor the duration off. - pct
80percent of the frame, or of the parent when it has a fixed size.- span
- Shorthand for
RichSpan::new. - trim
- The part of
pathbetween fractionsstartandendof its total length (0 ≤ start ≤ end ≤ 1), as used by thestart/endsignals.