Skip to main content

Crate drawnui

Crate drawnui 

Source
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.ts has 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 Ui into 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 (for Mut<T>), both implemented for every T: Has<Part>.

Structs§

AccessibilityNode
One control of the accessibility snapshot (React AccessibilityNode): what the host’s overlay renders as an ARIA element over the canvas.
AccessibilityTextLine
One laid-out text line of a control with accessibility_text_selectable (React AccessibilityTextLine). Points, from the node’s top-left.
AccessibilityValue
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.
AnimationId
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).
BakeRequest
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 assign hands out a real handle.
ContextMenu
A context menu request (React ContextMenuEventArgs).
ControlId
ControlProps
CornerRadius
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.
FramePlayer
FrameStats
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.
GestureCx
Given to on_gesture. The control’s own node is in the tree, minus its kind.
Gpu
Handle
Typed, copyable reference to a control. Default points at nothing.
Host
Requests from the app to the host.
ImageRequest
What the manager asks a host for: the picture of source, decoded, no larger than it takes to cover width x height pixels with its aspect kept (a 0 side does not count, both 0 = the full size), never enlarged. With frames, every frame of an animated file at full size. The answer is App::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.
LayoutCx
Given to measure and arrange. 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.
SkiaGradient
DrawnUI SkiaGradient. Start and end are ratios of the rect the gradient fills.
SkiaShadow
DrawnUI SkiaShadow: a blurred copy of the shape behind it. Offsets and blur are points.
Thickness
Tree
Ui
ValueAnimator
What a value animator runs (DrawnUI SkiaValueAnimator: mMinValue, mMaxValue, Speed, Easing, Repeat; Start(delayMs); PingPongAnimator).
VelocityAccumulator
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§

CacheType
What a control keeps between frames instead of painting again (DrawnUI SkiaCacheType).
ContextMenuSource
Where a context menu request came from (React ContextMenuSource).
Cursor
The mouse cursor the app asks the host for (React: cursor: pointer over interactive controls).
GestureKind
GesturesMode
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).
GradientType
Handled
What a control did with a gesture.
HistoryOp
A change to the browser’s history (React SkiaShell UseBrowserHistory); the desktop has none.
KeyKind
What a keyboard event is.
LayoutOptions
Where a control sits inside the box its parent gives it.
LockTouch
Which gestures a control lets through to its children.
MouseButton
Which mouse button pressed (AppoMobi.Gestures MouseButton). A touch or pen is Left.
PointerKind
RenderingModeType
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 InputKey values.
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
FramesBuild
FramesSet
Has
Self carries the properties part P, directly or through its inner chain.
IntoChildren
IntoProp
Conversion accepted by property builders and setters, so 16, 16.0 and "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 of KEY_CODES.
max_fps
The frame-rate cap set with set_max_fps; 0 = none.
run
run_sized
run with 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.

Type Aliases§

Easing
Maps linear progress 0..1 to eased progress (MAUI Easing).
InputKey
A key by its DOM code name: "KeyA", "Digit1", "ArrowLeft", "Space", "Enter", "Backspace", "ShiftLeft", "F1", … "Unknown" for a key the host has no name for.