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 bypaint::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.
- Background
Job - Work
App::backgroundstarted: cancel it when its result is no longer wanted. - Cancelled
- Whether a background job was cancelled, for its work to check between steps.
- Caught
Error - 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) andsuspense(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. - Confirm
Spec - What
App::confirmasks: a title, the text, and the buttons’ words. - El
- An element being built or bound. Cheap to clone.
- Geometry
Store - Window positions and sizes by key. Natively a small text file in the app’s data
directory (
GeometryStore::open): each line isx 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’sPersistStore(itslocalStorage;GeometryStore::persisted_in), so floating windows come back where they were after a reload. - Graphics
Adapter - A graphics adapter as people read it (
App::graphics_adapter). - Instance
Reply - 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.
- Pointer
Caps - What the pointer in use can do: widgets show hover-only affordances where it hovers, and larger targets where it is coarse.
- Reply
Later - The code an
InstanceReply::lateranswers 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) andsuspense(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.
runuses 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) andsuspense(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 withShow::el(orEl::from, so it can be passed toEl::child). - Suspense
Boundary - 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) andsuspense(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). - Text
Field - 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.
- Window
Spec - How to open a window.
Enums§
- Close
Reason - 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. - Enter
Key - What a touch keyboard’s Enter key says and does (the web’s
enterkeyhint, Android’s IME action).NextandPreviousmove focus as Tab and Shift+Tab do; the others press Enter, which submits a one-line field. - Field
Kind - What kind of field.
- Input
Purpose - 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). - Renderer
Choice - Which renderer draws an app’s windows.
- Renderer
Kind - The renderer drawing a window now.
- RunError
- Why the app could not run.
- Window
Direction - 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::Autowindow moves to the GPU. - GPU_
PROMOTE_ FRAME_ STALL - A single CPU frame this slow moves an
RendererChoice::Autowindow 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_exitturns 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, withremedy_ui_engine::view::strings::add_messagesunder the nameremedy-ui.
Functions§
- bundled_
fonts - The fonts every window starts with (
AppConfig::fontsby 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 withsystem-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) andsuspense(a placeholder while resources load), with what they return and hand to callbacks. An error boundary: shows whatchildbuilds, and when building it, or any handler, binding, effect or painter inside it, panics, unmounts that content and shows whatfallbackbuilds from the error and aRetry. 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 inui’s window until popped out to a window titledtitle. Put the returned element where the content belongs. - run
- Runs the app on this platform’s bridge until it quits.
setupruns 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) andsuspense(a placeholder while resources load), with what they return and hand to callbacks. Shows whatbuildmakes whilewhenis 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) andsuspense(a placeholder while resources load), with what they return and hand to callbacks. Shows whatchildbuilds once every resource read inside it has loaded, and whatplaceholderbuilds while one is loading. The content is built (hidden) at once, so its resources start fetching; the placeholder appears only afterSUSPENSE_DELAYand stays at leastSUSPENSE_MIN_SHOWN, so quick loads show nothing and slow ones never flash.