Expand description
DrawnUI for Rust: a Skia-drawn UI engine. A tree of controls is measured, arranged and painted each frame; hosts supply the window or canvas, the GPU surface, input and assets.
Re-exports§
pub use skia_safe as skia;
Modules§
- controls
- easing
- The MAUI easing set (React
Easing.tshas Linear, the cubics, SinIn, SinOut and Default). - effects
- Visual effects (DrawnUI VisualEffects): objects attached to a control through
Base::visual_effects. A post renderer draws over what the control painted (SkiaShaderEffect: an SkSL shader over the control’s output), an effect may report a margin it paints outside the rect, and it may take the control’s gestures before the control does (ISkiaGestureProcessor). - prelude
- Everything an app needs:
use drawnui::prelude::*; - testing
- Headless host: renders a
Uiinto CPU memory, drives frames and pointer input, reads pixels. No window, no GPU. The same role as DrawnUi.Net HeadlessCanvasHost + GestureRobot. Frame time is a synthetic clock that only the test moves, so animations are deterministic.
Macros§
- props
- Declares one properties part of a control: the struct with defaults, a builder trait (for
Build<T>) and a setter trait (forMut<T>), both implemented for everyT: Has<Part>.
Structs§
- Accessibility
Node - One control of the accessibility snapshot (React AccessibilityNode): what the host’s overlay renders as an ARIA element over the canvas.
- Accessibility
Text Line - One laid-out text line of a control with
accessibility_text_selectable(React AccessibilityTextLine). Points, from the node’s top-left. - Accessibility
Value - The value of a range control (a slider, a progress bar): what a screen reader reads and adjusts. UI Automation RangeValue, NSAccessibility value, aria-valuenow / min / max / valuetext.
- Animation
Id - A started animation. Stale once it finished or was stopped; using it then does nothing.
- Aria
- ARIA role and live-region names for
accessibility_role/accessibility_live(DrawnUI Aria). - Bake
Request - A picture for a worker to draw into a CPU bitmap.
- Base
- State every control has: the common properties and the layout results.
- Build
- A control under construction. Its id is reserved already, so
assignhands out a real handle. - Context
Menu - A context menu request (React ContextMenuEventArgs).
- Control
Id - Control
Props - Corner
Radius - Corner radii in points, in the order of the MAUI constructor.
- Cx
- What a handler may reach besides its own control and the app state.
- Decoded
- A picture the host decoded, ready to draw.
- Detached
- A type-erased subtree, ready to mount.
- Dirty
- What a property change invalidates.
- Fonts
- The registered font faces: by alias, several weights per alias.
- Frame
- Everything an app may touch while drawing one frame.
- Frame
Player - Frame
Stats - Timing of the drawn frames (React Canvas.FrameTime / FPS), for an app’s diagnostics.
- Frames
- The frames of an animated picture (a GIF), decoded once and shared by the controls that play it.
- Gesture
- One gesture event. Locations and distances are canvas pixels.
- Gesture
Cx - Given to
on_gesture. The control’s own node is in the tree, minus its kind. - Gpu
- Handle
- Typed, copyable reference to a control.
Defaultpoints at nothing. - Host
- Requests from the app to the host.
- Image
Request - What the manager asks a host for: the picture of
source, decoded, no larger than it takes to coverwidthxheightpixels with its aspect kept (a 0 side does not count, both 0 = the full size), never enlarged. Withframes, every frame of an animated file at full size. The answer isApp::image(id, ..). - Images
- The image manager of a tree:
Tree::images. - KeyEvent
- One keyboard event as controls and app handlers see it. Nothing in it is allocated.
- Keyboard
- The keyboard state the engine keeps (React KeyboardManager): the modifiers and which keys
are held. Read it from a key event or from
Ui::keyboard. - Layout
Cx - Given to
measureandarrange. The control’s own node is in the tree, minus its kind. - Modifiers
- The modifier keys held during an event.
- Mut
- Write access to a mounted control. Setters compare, and mark the control dirty on a change.
Dereferences to the control for reading.
Mut<dyn Control>reaches the common properties of a control of any type. - PaintCx
- Given to
paint. Nodes are read-only; only caches and render matrices are written. - Skia
Gradient - DrawnUI SkiaGradient. Start and end are ratios of the rect the gradient fills.
- Skia
Shadow - DrawnUI SkiaShadow: a blurred copy of the shape behind it. Offsets and blur are points.
- Thickness
- Tree
- Ui
- Value
Animator - What a value animator runs (DrawnUI SkiaValueAnimator: mMinValue, mMaxValue, Speed, Easing,
Repeat;
Start(delayMs); PingPongAnimator). - Velocity
Accumulator - The release velocity of a pan (DrawnUI VelocityAccumulator): the average of the last moves, newer ones weighing more. The control that flings owns one and decides which moves count.
Enums§
- Cache
Type - What a control keeps between frames instead of painting again (DrawnUI SkiaCacheType).
- Context
Menu Source - Where a context menu request came from (React ContextMenuSource).
- Cursor
- The mouse cursor the app asks the host for (React:
cursor: pointerover interactive controls). - Gesture
Kind - Gestures
Mode - What the canvas does with gestures the page could take too (DrawnUI
Canvas.Gestures). The browser host acts on it; the native hosts own their window and ignore it. - GpuBackend
- The GPU API the canvas draws with (DrawnUi.Rust; DrawnUI picks per platform itself).
- Gradient
Type - Handled
- What a control did with a gesture.
- History
Op - A change to the browser’s history (React SkiaShell UseBrowserHistory); the desktop has none.
- KeyKind
- What a keyboard event is.
- Layout
Options - Where a control sits inside the box its parent gives it.
- Lock
Touch - Which gestures a control lets through to its children.
- Mouse
Button - Which mouse button pressed (AppoMobi.Gestures MouseButton). A touch or pen is
Left. - Pointer
Kind - Rendering
Mode Type - Where the canvas draws (DrawnUI
Canvas.RenderingMode; Accelerated by default as in DrawnUi.React, C# defaults to Default).
Constants§
- ACCESSIBILITY_
INTERVAL_ MS - How often the accessibility snapshot is rebuilt at most (React MinUpdateIntervalMs).
- KEY_
CODES - Every key name, as
InputKeyvalues. - LONG_
PRESS_ MS - A press held this long without moving past the tap threshold is a LongPressing (DrawnUI
TouchEffect.LongPressTimeMsDefault, the desktop head; React produces none). - VERSION
- The version of this crate (an app’s “about” line).
Traits§
- App
- Container
- Controls that host children.
- Control
- Frames
Build - Frames
Set - Has
Selfcarries the properties partP, directly or through its inner chain.- Into
Children - Into
Prop - Conversion accepted by property builders and setters, so
16,16.0and"text"all work.
Functions§
- key_
name - The static name of a key the host reports as text (a DOM
code);"Unknown"when it is not one ofKEY_CODES. - max_fps
- The frame-rate cap set with
set_max_fps; 0 = none. - run
- run_
sized runwith the desktop window’s first size in points; the web canvas keeps the page’s size.- set_
max_ fps - The frame-rate cap (DrawnUI
Super.MaxFps). 0, the default: the display’s own rate, 120 Hz on a ProMotion iPhone. 60 keeps such a phone at 60. A cap the display cannot present is snapped to a whole divisor of its rate (120 Hz: 120, 60, 40, 30…). Can change at any time. The iOS host paces its display link with it; the other hosts do not read it yet.