Skip to main content

Crate remedy_ui

Crate remedy_ui 

Source
Expand description

RemedyUI for apps.

use remedy_ui::{App, AppConfig, WindowSpec};

remedy_ui::run(AppConfig::new("Example"), |app: &App| {
    app.open(WindowSpec::new("Hello"), |ui, _window| {
        ui.root().child(ui.el("label").text("Hello"));
    });
})
.ok();

run starts the platform’s bridge (Windows, macOS, Linux, Android, or a browser page with the web feature, where it returns once the app has started) and drives every window: input goes to the window’s Ui, each frame runs the view pipeline into the window’s compositor, and frames are presented with the GPU renderer (feature gpu, on by default) or, when no GPU works, the CPU renderer with damage-only presents. App code acts through an App handle and Window handles; what they ask happens right after the event that asked. Window geometry can persist under a key, timers run app code later, and the app keeps running with no windows when it says so (tray apps).

The guide holds the guides, porting guides and recipes, starting with guide::getting_started.

Re-exports§

pub use remedy_ui_core as core;
pub use remedy_ui_text as text;

Modules§

a11y
Semantics: roles, names, states and actions that screen readers, tests and agents read (Semantics, Role, Action). RemedyUI accessibility.
forms
RemedyUI’s form widgets, built on the public view API and the core widgets.
gpu
The GPU renderer’s own bounds (feature gpu): errors kept, the health file, how long it waits for swapchains, presents and video (gpu::set_gpu_limits). What both renderers draw is bounded by paint::set_paint_limits.
guide
Guides, porting guides and recipes.
host
RemedyUI’s host model.
i18n
RemedyUI localization.
input
RemedyUI input.
layout
RemedyUI layout.
motion
Motion: elements animate a property, style value, offset or scale to a target with a spring or an easing curve on the frame clock (El::animate), interruptibly and instantly under reduced motion; Transitions for content that appears and leaves.
nav
RemedyUI’s navigation widgets, built on the public view API and the core widgets.
paint
Drawing: display lists, paths, brushes, transforms and images, for painters (El::paint), canvases and page sources. RemedyUI display lists.
reactive
Reactive state for RemedyUI.
router
Routes: which page the app shows, as an address (/settings/2), with back and forward.
style
RemedyUI styling: themes, derived tokens, states and style resolution.
themes
The Remedy theme set, shared by every Remedy app.
view
RemedyUI’s view layer.
widgets
RemedyUI’s core widgets, the pack every app uses.

Structs§

App
The app, as its code sees it. Requests take effect right after the current event.
AppConfig
App-wide settings.
BackgroundJob
Work App::background started: cancel it when its result is no longer wanted.
Cancelled
Whether a background job was cancelled, for its work to check between steps.
CaughtError
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. A failure an error boundary caught: what failed, where in the tree, and where in the source.
Completion
A result for the UI thread, completed from any thread: see App::completion.
ConfirmSpec
What App::confirm asks: a title, the text, and the buttons’ words.
El
An element being built or bound. Cheap to clone.
GeometryStore
Window positions and sizes by key. Natively a small text file in the app’s data directory (GeometryStore::open): each line is x y width height key; keys may contain spaces; written to a temporary file and renamed, so a crash never leaves a torn file. In a browser page, where the app has no files, an entry of the app’s PersistStore (its localStorage; GeometryStore::persisted_in), so floating windows come back where they were after a reload.
GraphicsAdapter
A graphics adapter as people read it (App::graphics_adapter).
InstanceReply
What the app answers a later launch with (App::on_second_instance): a code now, or one it sends later from any thread (InstanceReply::later). A handler that returns nothing answers 0.
Movable
Content that can move to a window of its own and back. Cheap to clone.
PaintCx
What a custom painter gets: the list to record into (local coordinates, origin at the element’s top-left), the element’s size, its resolved style and the theme.
PointerCaps
What the pointer in use can do: widgets show hover-only affordances where it hovers, and larger targets where it is coarse.
ReplyLater
The code an InstanceReply::later answers with, sent from any thread.
Retry
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. Retries an error boundary: its content is built again.
Runner
Drives an app on a host. run uses it with the platform bridge; tests use it with the headless bridge.
Show
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. Content shown while a condition holds (show): built when the condition becomes true, disposed when it becomes false, with an optional fallback in between and transitions in and out. It becomes an element with Show::el (or El::from, so it can be passed to El::child).
SuspenseBoundary
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. A boundary that shows a placeholder while resources read inside its content are still loading (suspense).
TextField
A handle to a text field element.
Ui
One window’s UI. Cloning gives another handle to the same UI.
Window
A window, as app code sees it.
WindowSpec
How to open a window.

Enums§

CloseReason
Why a window is asked to close (Window::on_close_request).
Edition
Editions: which default behaviors the app follows (AppConfig::edition). A set of default behaviors, named by the year it was introduced.
EnterKey
What a touch keyboard’s Enter key says and does (the web’s enterkeyhint, Android’s IME action). Next and Previous move focus as Tab and Shift+Tab do; the others press Enter, which submits a one-line field.
FieldKind
What kind of field.
InputPurpose
What a text field holds: picks the touch keyboard’s layout, the input method’s mode, and what password managers and autofill offer.
Leaving
Why the app may be ended (App::on_leave).
RendererChoice
Which renderer draws an app’s windows.
RendererKind
The renderer drawing a window now.
RunError
Why the app could not run.
WindowDirection
Where a window’s layout direction comes from (Ui::set_direction).

Constants§

GEOMETRY_KEY
The key window geometry is kept under in a PersistStore (GeometryStore::persisted_in).
GPU_PROMOTE_FRAME_COST
The average CPU frame cost past which an RendererChoice::Auto window moves to the GPU.
GPU_PROMOTE_FRAME_STALL
A single CPU frame this slow moves an RendererChoice::Auto window to the GPU at once.
SINGLE_INSTANCE_REPLY
How long a later launch waits for the running instance’s reply when AppConfig::single_instance_await_exit turns replies on without a wait of its own.

Statics§

STRINGS
The runner’s own words (what the place of content popped out to its own window says) in every language the engine ships, from i18n/remedy-ui/*.ftl. Apps reword them, or add a language, with remedy_ui_engine::view::strings::add_messages under the name remedy-ui.

Functions§

bundled_fonts
The fonts every window starts with (AppConfig::fonts by default): the bundled faces, with the script faces as fallbacks for their scripts (Arabic, Devanagari and Bengali; Chinese and Japanese by language, loaded when text first needs them), and the system’s fonts after them with system-fonts. In a browser page the script faces are files beside the page, each fetched the first time text needs it (remedy_ui_fonts::Face::is_remote); the text that waited is drawn again once it arrives.
catch_errors
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. An error boundary: shows what child builds, and when building it, or any handler, binding, effect or painter inside it, panics, unmounts that content and shows what fallback builds from the error and a Retry. The rest of the window carries on. The error also goes to the window’s failure list and error hook (Ui::set_error_hook).
movable
Content built by build, shown in ui’s window until popped out to a window titled title. Put the returned element where the content belongs.
run
Runs the app on this platform’s bridge until it quits. setup runs once the platform is ready, to open the first windows.
show
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. Shows what build makes while when is true: a signal, a closure or a constant. The content is built in a scope of its own each time it appears and disposed (its effects, signals and resources with it) when it goes. While it shows nothing (no fallback, nothing leaving), it takes no room and no gap in its row or column.
suspense
Content that comes and goes, fails or loads, where apps build screens: show (content shown while a condition holds), catch_errors (an error boundary that takes a builder closure for its content, so a retry builds it again) and suspense (a placeholder while resources load), with what they return and hand to callbacks. Shows what child builds once every resource read inside it has loaded, and what placeholder builds while one is loading. The content is built (hidden) at once, so its resources start fetching; the placeholder appears only after SUSPENSE_DELAY and stays at least SUSPENSE_MIN_SHOWN, so quick loads show nothing and slow ones never flash.