Expand description
GPUI is a Rust framework for building interfaces on macOS, Windows, Linux, and the web. It lays out element trees on the CPU and paints them with a GPU renderer. You keep application state in entities, build the interface from that state, and notify GPUI after changes that should appear on screen.
GPUI was built by Zed Industries to make the Zed editor.
This crate is GPUI Community Edition (GPUI-CE), a fork maintained for
standalone applications. It is published as gpui-ce and imported as gpui.
This program opens a window containing a counter. The click handler increments
the count and calls notify; the next render puts the new count in the button:
use gpui::{App, Context, Window, WindowOptions, div, prelude::*, rgb};
struct Counter {
count: usize,
}
impl Render for Counter {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.flex()
.items_center()
.justify_center()
.bg(rgb(0xf5f5f4))
.child(
div()
.id("button")
.px_4()
.py_2()
.rounded_md()
.bg(rgb(0x2563eb))
.text_color(rgb(0xffffff))
.cursor_pointer()
.child(format!("Clicked {} times", self.count))
.on_click(cx.listener(|counter, _event, _window, cx| {
counter.count += 1;
cx.notify();
})),
)
}
}
fn main() {
gpui_platform::application().run(|cx: &mut App| {
cx.open_window(WindowOptions::default(), |_window, cx| {
cx.new(|_cx| Counter { count: 0 })
})
.unwrap();
cx.activate(true);
});
}The counter also runs without a display. TestApp sends two clicks to a
headless window, and the assertion checks the resulting state:
use gpui::{MouseButton, TestApp, point, px};
let mut app = TestApp::new();
let mut window = app.open_window(|_window, _cx| Counter { count: 0 });
window.simulate_click(point(px(10.), px(10.)), MouseButton::Left);
window.simulate_click(point(px(10.), px(10.)), MouseButton::Left);
assert_eq!(window.read(|counter, _cx| counter.count), 2);§Overview
The counter uses three parts of GPUI: an entity to hold the count, a view to read it, and elements to display it and receive clicks. Their lifetimes differ: the entity survives between frames, while each render builds a new element tree.
Appowns entity state.App::newstores a value and returns anEntity<T>: a cloneable handle for reading and updating it through a context. Entities connect shared state to observers and dependent views; ownership explains their lifetimes.- A view is an entity that can
Render. When a view renders, it builds a fresh tree of elements. A view keeps its state between frames; the elements it returns are thrown away after they’re drawn. - Elements describe the interface.
divis the workhorse: a box with children, styles and event handlers. Text,img,svg,uniform_listandcanvascover the rest, and you can write your own by implementingElement. Style them withStyledmethods named after Tailwind CSS classes, such as.flex(),.p_4()and.rounded_md(), and GPUI lays them out with flexbox and grid. - Contexts give you access. Callbacks receive the access they need:
Appfor application-wide services,Context<T>while you work on one entity, andWindowfor the window being drawn or handling input. - Changes need notification. Mutating an entity’s fields alone doesn’t
schedule a redraw.
Context::notifyinforms observers and marks dependent windows for redraw. The frame cycle connects this notification to layout and painting. - Input follows hit testing and focus. Mouse dispatch uses element hitboxes; keyboard dispatch follows the path to the focused element. Key bindings map keystrokes to typed actions. Input dispatch explains capture, bubbling, and propagation.
The concepts section explains each of these ideas in depth.
§Getting started
Add GPUI and its platform crate to Cargo.toml. The platform crate picks the
right windowing and rendering backends for the target you build for:
[dependencies]
gpui = { package = "gpui-ce", version = "0.2" }
gpui_platform = { package = "gpui_ce_platform", version = "0.1" }Then follow the tutorial, which builds a todo app one idea at a time. Start a project covers system requirements for each platform.
The rest of this page is a map of GPUI:
- How do I… answers common questions with short examples.
- The API at a glance groups the crate’s items by what they’re for.
- Crate features lists the optional parts of GPUI.
- Documentation points to everything else.
§How do I…
These snippets cover common tasks. Each links to a guide with setup and related behavior.
§Respond to a click
Give the element an id so GPUI can track it
between frames, then register a handler. Context::listener gives the
handler mutable access to your view:
div()
.id("increment")
.child("Add one")
.on_click(cx.listener(|counter, _event, _window, cx| {
counter.count += 1;
cx.notify();
}))§Bind a keyboard shortcut
Declare an action, bind a keystroke to it, and handle it on an element that has focus or contains the focused element:
use gpui::{App, KeyBinding, actions};
actions!(editor, [Save]);
fn bind_keys(cx: &mut App) {
cx.bind_keys([KeyBinding::new("cmd-s", Save, Some("Editor"))]);
}div()
.key_context("Editor")
.track_focus(&self.focus_handle)
.on_action(cx.listener(Editor::save))See keyboard input.
§Run work without freezing the window
Context::spawn runs async code on the main thread, where it can update
entities. Move expensive work to a thread pool with
background_spawn and await the result:
impl Report {
fn refresh(&mut self, text: String, cx: &mut Context<Self>) {
self.task = Some(cx.spawn(async move |this, cx| {
let summary = cx.background_spawn(async move { summarize(&text) }).await;
this.update(cx, |report, cx| {
report.summary = Some(summary);
cx.notify();
})
.ok();
}));
}
}Dropping a Task cancels it, so storing it in the view ties the work’s
lifetime to the view’s. See async work.
§Show a list of ten thousand rows
uniform_list builds rows for the viewport and a small buffer. This limits
element construction even when the data contains thousands of rows:
uniform_list(
"log",
self.lines.len(),
cx.processor(|log, range: std::ops::Range<usize>, _window, _cx| {
range
.map(|index| div().h(px(20.)).child(log.lines[index].clone()))
.collect::<Vec<_>>()
}),
)
.h_full()See lists and scrolling.
§Animate a change
Wrap any element with with_animation. The
closure receives the eased progress, from 0.0 to 1.0, and returns the
element as it should look at that point:
use gpui::{Animation, AnimationExt, ease_in_out, millis};
div()
.child("Saved")
.with_animation(
"fade-in",
Animation::new(millis(300)).with_easing(ease_in_out),
|element, progress| element.opacity(progress),
)See animation.
§Draw a custom shape
canvas gives you a callback with the element’s bounds and direct access
to the window’s paint methods:
canvas(
|_bounds, _window, _cx| {},
|bounds, _state, window, _cx| {
window.paint_quad(fill(bounds, rgb(0x2563eb)));
},
)
.size(px(64.))See custom drawing.
§The API at a glance
Most application-facing items are exported from the crate root. These tables group the main types and functions by purpose.
Applications and windows
| Item | Purpose |
|---|---|
Application | Starts the event loop. Get one from gpui_platform::application(). |
App | The application context: windows, globals, key bindings, platform services. |
Window, WindowOptions | One window: its size, focus, input and drawing. |
WindowHandle, AnyWindowHandle | Refer to a window from outside it. |
State
| Item | Purpose |
|---|---|
Entity, WeakEntity | Handles to state owned by the app. |
Context | Access to one entity while you update it. |
AppContext | The operations every context supports: create, read and update entities. |
EventEmitter, Subscription | Typed events between entities. |
Global | Application-wide singletons such as settings. |
Views and elements
| Item | Purpose |
|---|---|
Render | A stateful view: an entity that renders elements. |
RenderOnce, IntoElement | A stateless component, built and consumed in one frame. |
div, Div | The general-purpose container element. |
StyledText, img, svg, canvas | Text runs, images, vector icons, custom painting. |
uniform_list, list | Virtualized lists of equal or varying row heights. |
anchored, deferred | Popovers and overlays that escape their parent. |
Element, AnyElement | The low-level element protocol, for custom layout and painting. |
Style and layout
| Item | Purpose |
|---|---|
Styled | Tailwind-style builder methods for layout, color, borders, shadows and text. |
Style, StyleRefinement | The full style, and a partial one that overrides it. |
px, rems, relative | Lengths in logical pixels, root ems and fractions. |
Hsla, Rgba, rgb, hsla | Colors. |
Bounds, Point, Size, Pixels | Geometry. |
Input
| Item | Purpose |
|---|---|
InteractiveElement, StatefulInteractiveElement | Mouse, keyboard, focus, hover and drag handlers on elements. |
FocusHandle, Focusable | Keyboard focus. |
Action, actions!, KeyBinding | Keystrokes mapped to typed commands. |
ClickEvent, MouseDownEvent, KeyDownEvent, … | The events your handlers receive. |
Motion
| Item | Purpose |
|---|---|
Animation, AnimationExt | Animate an element over time. |
StyleTransitions | Animate style changes such as hover colors. |
Transition, SpringConfig | Animate values toward a moving target. |
Async and time
| Item | Purpose |
|---|---|
Task | A handle to running async work; dropping it cancels the work. |
AsyncApp, AsyncWindowContext | Contexts you can hold across .await. |
BackgroundExecutor, ForegroundExecutor | Spawn work on a thread pool or the main thread. |
Testing
| Item | Purpose |
|---|---|
TestApp | A headless app for driving views with simulated input. |
TestAppContext, #[gpui::test] | Async tests with a deterministic scheduler. |
§Crate features
| Feature | Default | Effect |
|---|---|---|
wayland, x11 | yes | Include the Wayland and X11 code paths on Linux and FreeBSD. |
font-kit | yes | Legacy dependency feature retained for compatibility. The macOS backend discovers fonts through its shared Parley font database. |
windows-manifest | yes | Embed an application manifest in Windows executables. |
test-support | no | TestApp, TestAppContext and other testing tools. |
inspector | no | The element inspector, for debugging layout in a running app. |
profiler | no | Frame, input-latency and task profiling, with an on-screen overlay. |
hot-patching | no | Patch render code into a running app with Dioxus’ dx. See hot reload. |
embedded-assets | no | Embed an asset directory in the binary with rust-embed. |
leak-detection | no | Report entity handles that outlive their app, with backtraces. |
screen-capture | no | Capture screen contents as a surface on Windows. |
custom-gpu | no | Exposes custom GPU drawing APIs. The renderer also needs device-sharing support; see platform features. |
wgpu-surfaces | no | Compatibility marker for Windows surface imports in gpui_wgpu. Enable the renderer’s feature of the same name to compile that integration. |
stacker | no | Grow the stack on demand for very deep element trees. |
bench-support | no | Helpers for Criterion benchmarks of GPUI code. |
bench | no | Compatibility alias for bench-support. |
Cargo combines features requested by all dependencies. For example, turning off default features on one dependency does not remove a backend that another dependency enables. Platform selection and renderer features belong to their respective crates; the platforms page explains those relationships.
§Documentation
- The tutorial builds a complete app.
- The guides solve specific problems.
- The concepts explain how GPUI works.
- The examples are complete programs you can run, many of them live in your browser.
- Design explains why GPUI is the way it is, comparison weighs it against other Rust toolkits, platforms describes what runs where, and upstream lists the differences from Zed’s GPUI.
Re-exports§
pub use test::TestScreenCaptureSource;pub use test::TestScreenCaptureStream;pub use proptest;pub use accesskit;pub use profiler::*;pub use test::*;
Modules§
- _documentation
- Tutorials, guides and background reading for GPUI applications.
- colors
- The default colors used by GPUI.
- http_
client - HTTP client abstraction for making requests.
- inspector_
reflection - Runtime descriptions of trait methods, generated by
#[derive_inspector_reflection]. - layer_
shell - popup
- Types for configuring parent-anchored popup windows such as menus, dropdowns and tooltips.
- prelude
- The GPUI prelude is a collection of traits and types that are widely used throughout the library. It is recommended to import this prelude into your application to avoid having to import each trait individually.
- profiler
- Profiling utilities for task, frame, and thread performance tracking. Timing for tasks, actions and window frames.
- queue
- A queue with three priority levels. A sender can be shared by reference across threads, while cloning a receiver adds another consumer of the same queue.
- styled_
reflection - Implements function reflection
- test
- Support for the
#[gpui::test]macro, and streams for observing entities in tests.
Macros§
- actions
- Declares unit structs that are actions, and registers them with the app.
- bench_
group - Defines a Criterion benchmark group for benchmarks annotated with
gpui::bench. - bench_
main - Defines the entry point for GPUI Criterion benchmark groups.
- border_
style_ methods - Generates the border methods for
Styled, such asborder_1andborder_color. - box_
shadow_ style_ methods - Generates the box-shadow and corner methods for
Styled. - cursor_
style_ methods - Generates the cursor methods for
Styled, such ascursor_pointer. - margin_
style_ methods - Generates the margin methods for
Styled, such asm_4andmx_auto. - overflow_
style_ methods - Generates the overflow methods for
Styled, such asoverflow_hidden. - padding_
style_ methods - Generates the padding methods for
Styled, such asp_4andpx_2. - position_
style_ methods - Generates the position methods for
Styled, such asrelativeandabsolute. - register_
action - Registers a type that implements
gpui::Actionby hand. - text
- Creates a
Textelement that has an ID, so that screen readers can read it. - visibility_
style_ methods - Generates the
visibleandinvisiblemethods forStyled.
Structs§
- A11y
Callbacks - The callbacks an accessibility adapter uses to talk to the application.
- A11y
Subtree Builder - Adds accessibility nodes for things an element draws but doesn’t model as elements.
- Action
Binding Collection - A set of actions and the keystrokes that trigger each one, to be bound together in one key context.
- Activity
Guard - Keeps an operating system activity, such as an idle sleep inhibitor, alive until dropped.
- Anchored
- An element that places its children at an anchor point, and keeps them inside the window.
- Anchored
State - The layout state of an
Anchoredelement: the layout ids of its children. - Animated
- A value that animates toward a target, and keeps the state it needs to change course.
- Animated
Sample - A value sampled from an
Animated, together with its activity and progress. - Animation
- A timed change to an element, applied with
AnimationExt::with_animation. - Animation
Element - The element returned by
AnimationExt::with_animationandAnimationExt::with_animations. - Animation
Phase - An animation coordinate that can go past zero and one.
- AnyDrag
- The state of a drag in progress, started by dragging an element in a window.
- AnyElement
- An element with its concrete type erased, so that elements of different types can share one type.
- AnyEntity
- A handle to an entity whose type is erased.
- AnyImage
Cache - A type-erased
ImageCache, so oneimgcan hold any cache type. - AnyTooltip
- The state of a tooltip that is currently shown.
- AnyView
- A type-erased handle to a view.
- AnyWeak
Entity - A type-erased handle to an entity that doesn’t keep it alive.
- AnyWeak
View - A weak, type-erased handle to a view.
- AnyWindow
Handle - A handle to an open window whose root view type isn’t known at compile time.
- App
- The state of a running application: its entities, windows, globals and key bindings.
- Application
- The entry point for a GPUI application. Configure it, then call
Application::run. - Application
Handle - A strong handle to an
Applicationstarted withApplication::run_embedded. - Arena
Clear Needed - Returned when the element arena has been used and so must be cleared before the next draw.
- Asset
Registry - The named assets that the app loads by path, such as images, SVGs and fonts.
- Async
App - A handle to the app that you can hold across
.awaitpoints. - Async
Window Context - A handle to the app and one window, for use across
.awaitpoints. - Atlas
Texture Id - Identifies one texture in an atlas.
- Atlas
Tile - Where a glyph, SVG or image sits in an atlas texture.
- Backdrop
Filter - A filter applied to the content already painted behind
bounds, composited into a rounded rectangle. A blur gives the frosted-glass effect. - Background
- A fill for a shape: a solid color, a linear gradient, or a pattern.
- Background
Executor - Runs
Sendfutures on GPUI’s background executor. - Binding
Index - The position of a binding in a
Keymap, counted in the order bindings were added. - Bounds
- A rectangle, defined by its top left corner and its size.
- Bounds
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - BoxShadow
- The values accepted by an element’s box-shadow style.
- Canvas
- An element that runs custom drawing code, created with
canvas. - Capslock
- The state of the caps lock key at some point in time.
- Caret
Movement - The destination of a caret movement, and the column to keep across vertical moves.
- Caret
Position - A position between characters, given as a UTF-8 byte index plus the side it attaches to.
- Caret
Selection - A text selection with an anchor and a caret, each with its own affinity.
- Cascade
- A cascade of refinements that can be merged in priority order.
- Cascade
Slot - A handle to a specific slot in a cascade.
- Clipboard
Item - Something to put on the clipboard, or something read from it.
- Clipboard
String - A string on the clipboard, with optional metadata.
- Container
Query - A container query element, created with
container_query. - Content
Mask - The visible region of the window, which clips what is painted and hit-tested.
- Context
- A mutable handle to the
Appthat also knows which entityTyou are working on. - Context
Entry - One identifier or key-value pair in a
KeyContext. - Corners
- The values at the four corners of a box, such as a border radius.
- Corners
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Debug
Below - Lets a custom element read the
debug_belowsetting in debug builds. - Dedicated
Executor - A handle to one long-lived session. Every future spawned on it runs on that session’s single thread, never on the background pool.
- Deferred
- An element that draws its child after the rest of the tree, in priority order.
- Deferred
Scroll ToItem - A scroll request that waits for the next prepaint.
- Device
Pixels - A whole number of physical pixels on the display.
- Dismiss
Event - The event a
ManagedViewemits to ask its owner to close it. - Dispatch
Event Result - The outcome of
Window::dispatch_event. - Display
Changes - The properties of a display that a
DisplayEvent::Changedreports. - Display
Id - An identifier for a display that is valid for the current session.
- Div
- The all-in-one element for building most user interfaces. Create one with
div. - DivFrame
State - The layout state a
Divkeeps between its layout and prepaint phases. - DivInspector
State - The interactivity state of an element, as shown and edited by the inspector.
- Drag
Move Event - A pointer move during a drag of type
T, passed toInteractiveElement::on_drag_movelisteners. - Drawable
- An
Elementtogether with the state GPUI keeps while drawing it in one frame. - Drop
Listener - Handles drags of a single type over an element: whether they can be dropped, how the element looks while they are over it, and what happens when they are released.
- Dummy
Keyboard Mapper - A
PlatformKeyboardMapperthat changes nothing. - Duplicate
Asset Path - Returned when a path is already registered in an
AssetRegistry. It holds the duplicated path. - Duration
Description - The timing of a duration-based
Motion: its passes, delay and playback. - Easing
- An easing function that maps linear pass time to eased progress.
- Edges
- The sizes of the four sides of a box, such as its padding or margin.
- Edges
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Element
Clicked State - Whether an element, or a group that contains it, is pressed by the mouse.
- Element
Hover State - Whether an element, or a group that contains it, is hovered.
- Element
Input Handler - Connects an
EntityInputHandlerview to the platform’s text input. - Empty
- An element that draws nothing and takes up no space.
- Empty
View - A view that renders nothing.
- Entity
- A handle to state owned by the
App. - Entity
Id - Identifies an entity within the app.
- External
Paths - The file paths carried by a file drop.
- Fallback
Prompt Renderer - The view that
fallback_prompt_renderershows inside the window. - Fallible
Task - A
Taskthat resolves toOption<T>, and toNoneinstead of panicking when the task is cancelled. - File
Drag Paths - The files for a native file drag, each paired with whether it is a directory.
- Fill
Options - Parameters for the fill tessellator.
- Filter
Boundary - The start or end marker of a content-filter or opacity isolation group.
- Filter
Target Index - The index of an offscreen target in the renderer’s content-filter target pool.
- Focus
Handle - A handle that makes an element focusable and tracks whether it has focus.
- FocusId
- A key that identifies one focusable element within the focus map of a window.
- Focus
OutEvent - The event passed to listeners registered with
Context::on_focus_out. - Font
- The face to use for text: a font family plus its weight, width, style, features, and fallbacks.
- Font
Fallbacks - Font families to try, in order, when a
Fontlacks a glyph. - Font
Features - OpenType feature settings applied while shaping a
Font. - FontId
- An opaque identifier for a font face that the
TextSystemhas resolved. - Font
Metrics - The measurements of a typeface, in font units.
- Font
Weight - The weight of a font, from
FontWeight::THIN(100) toFontWeight::BLACK(900). - Font
Width - The requested width of a font face, as a percentage of its normal width.
- Foreground
Executor - Runs futures on the main thread, interleaved with event handling and drawing.
- Gesture
Kinds - The gestures a platform recognizes on its own.
- Gesture
Tuning - The timing, distance and feel constants that touch gesture recognition uses.
- Global
Element Id - A globally unique identifier for an element, used to track state across frames.
- Glyph
Atlas Entry - A cached glyph’s GPU tile and the placement metadata for its uploaded pixels.
- GlyphId
- An identifier for a specific glyph, as returned by
WindowTextSystem::layout_line. - GpuSpecs
- Describes the GPU that GPUI renders with.
- Gpui
Borrow - A mutable borrow of an entity’s state, taken out of GPUI while the borrow is alive.
- Graphical
Environment - The graphical session to connect to: the variables that locate its display server, as some process sees them.
- Grid
Location - The rows and columns that a grid item occupies.
- Grid
Template - The portion of a grid template that describes track sizes.
- Grid
Template Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Group
Style - A style that applies to an element while a named group of elements is hovered, pressed or receives a drag.
- Headless
AppContext - A headless app for tests that need real text layout, without a window on screen.
- Headless
Atlas - A sprite atlas for windows without a GPU. It hands out uniquely identified tiles without uploading any pixels, so glyph, SVG, and image painting can run to completion in tests and headless platforms.
- Highlight
Style - A highlight style to apply, similar to a
TextStyleexcept for a single font, uniformly sized and spaced text. - HitTest
- The hitboxes under the mouse, from front to back, as of the last frame.
- HitTest
Entry - An entry in a
HitTestwhich represents aHitbox. Contains some metadata about the hitbox in the frame the HitTest was evaluated on. - Hitbox
- A region that receives mouse input for the frame it was inserted in.
- Hitbox
Id - Identifies a
Hitboxin the frame that inserted it. - Image
- Encoded image data and the format it is encoded in.
- Image
Cache Element - The element that
image_cachereturns. It installs the cache for its children during layout and paint, and lays out like adiv. - Image
Cache Item - Owns an image load and its cached result.
- Image
Format Iter - An iterator over the variants of ImageFormat
- ImageId
- Identifies a
RenderImage.RenderImage::newgives each image a new ID, so two images never share one. The wrappedusizeis the counter value that identifies the image. - Image
Style - The settings that the
StyledImagemethods set on an image element. - Img
- An image element, made by
img. - ImgLayout
State - The per-frame state that an
Imgpasses from layout to paint. - Inline
BoxRequest - An atomic element inserted at a UTF-8 boundary in an inline document.
- Inline
Layout - Text and atomic boxes laid out together, following inline paragraph flow.
- Inline
Layout Request - Complete input for a document containing text and element boxes.
- Inline
Range Geometry - The area that a text range covers on one visual line.
- Inline
Text Metrics - Font metrics that set the vertical extent of an inline line.
- Inline
Text Style - Resolved font size and line height for part of an inline document.
- Inline
Visual Line - One row of an inline layout, positioned relative to the layout’s origin.
- Inspector
- Tracks the element selected or hovered in the inspector, and whether picking is active.
- Inspector
Element Id - Identifies one element so the inspector can select it and describe its state.
- Inspector
Element Path - A
GlobalElementIdplus the source location where the element was built. - Interactive
Element State - The state that an element with an
ElementIdkeeps between frames, such as its focus handle and scroll offset. - Interactive
Text - A
StyledTextthat reports clicks, hovers, and tooltips for character ranges. - Interactivity
- The interactivity state of an element: its listeners, styles, focus and scroll state.
- Interactivity
Prepaint - The bounds and content size of an element, as passed to
Interactivity::on_prepaint. - Invalid
Keystroke Error - Error returned by
Keystroke::parsewhen a string isn’t a valid keystroke. - Item
Size - The sizes of a
UniformList’s viewport and of all its rows, from the last prepaint. - KeyBinding
- A keybinding: a keystroke sequence, the action it runs, and the key context it applies in.
- KeyBinding
Meta Index - An index into your own store of metadata about where a binding came from, such as the keymap file or the built-in defaults. Lower indexes are stronger sources.
- KeyContext
- The names and values that describe one element, for matching key bindings.
- KeyDown
Event - A key press, sent when the platform reports that a key went down.
- KeyUp
Event - A key release, sent when the platform reports that a key went up.
- Keybinding
Keystroke - A keystroke as it appears in a keybinding, ready to display to the user.
- Keyboard
Click Event - A click triggered from the keyboard: Enter or Space on a focused element.
- Keymap
- The set of key bindings for the application, and the rules for choosing among them.
- Keymap
Version - An identifier for one state of a
Keymap. - Keystroke
- A key press, with the modifier keys that were held when it happened.
- Keystroke
Event - A keystroke that reached the app, with the action it resolved to, if any.
- Layout
Id - An id for a node in the layout tree.
- Leak
Detector Snapshot - A snapshot of the entities that had alive handles at one point in time.
- Line
Layout - The shaped and laid-out form of a string of text, ready to measure and paint.
- Linear
Color Stop - A color stop in a linear gradient.
- List
- The element returned by
list. Style it, then return it fromrender. - List
Offset - A position in a list: a row index and a pixel offset into that row.
- List
Prepaint State - The hitbox and laid-out rows that a
Listcarries from prepaint to paint. You don’t construct it. - List
Scroll Event - The state of a
ListStateafter a wheel or trackpad scroll. - List
State - The state of a
list. Store it on your view and pass a clone tolisteach frame. - Long
Press Event - A touch held still long enough to count as a long press.
- Menu
- A menu in the application’s menu bar, or a submenu inside another menu.
- Modifiers
- The modifier keys held at some point in time.
- Modifiers
Changed Event - A change to the modifier keys (Shift, Control, Alt, Platform, Function) or Caps Lock, sent without a key press.
- Monochrome
Sprite - A single-color sprite: an alpha mask from the sprite atlas, tinted with
color. - Motion
- A deterministic, time-sampled motion from a start value to a target.
- Motion
Pass - One directional pass of a
Motion: a duration together with its easing curve. - Motion
Sample - The state of a
Motionat one moment, returned byMotion::sample. - Mouse
Click Event - A completed mouse click: the press and the release of one button on one element.
- Mouse
Down Event - A mouse button press, sent to
InteractiveElement::on_mouse_downlisteners. - Mouse
Exit Event - The pointer left the window.
- Mouse
Move Event - The pointer moved over the window, with or without a button held.
- Mouse
Pressure Event - A pressure update from a force-sensitive trackpad, sent as the user presses harder or eases off. Only macOS trackpads report it today.
- Mouse
UpEvent - A mouse button release, sent to
InteractiveElement::on_mouse_uplisteners. - NoAction
- Disables the lower-precedence bindings for the same keystrokes.
- Null
Platform Gestures - A
PlatformGestureswith the default tuning and no native recognizers. - Ongoing
Scroll - Keeps a scroll gesture on one axis, so a mostly vertical swipe does not drift sideways.
- OsMenu
- A submenu that the operating system fills in, such as the Services menu on macOS.
- Owned
Menu - A
Menuin the form thatApp::get_menusreturns. - Owned
OsMenu - An
OsMenuin the form thatApp::get_menusreturns. - Paint
Fragment - A run of glyphs that share one font and one style, positioned on a visual line.
- Paint
Quad - A rectangle with a background and optional border, ready for
Window::paint_quad. - Paint
Style - The paint properties of one run of text: color, background, underline, and strikethrough.
- Paint
Surface - A surface produced outside GPUI, such as a video frame, drawn as a rectangle.
- Parsed
Svg - A parsed SVG document that can be rasterized at any scale.
- Path
- A filled shape, stored as a triangle mesh.
- Path
Builder - Builds a
Pathfrom lines and curves, and tessellates it into triangles. - PathId
- Identifies a
Pathby the index it had inScene::pathswhen the path was inserted. The scene assigns it at that point, andScene::finishmay sort the paths afterwards. - Path
Prompt Options - Options for
Platform::prompt_for_paths, which shows a file or folder picker. - Path
Vertex - A vertex of a
Pathtriangle. - Pending
Input Status - Pending input for a potential multi-stroke key binding.
- Pending
Input Timeout Status - The timeout state for pending input.
- Percentage
- A fraction of a full turn, from
0.0to1.0. - Pinch
Event - A pinch-to-zoom gesture, typically from a trackpad.
- Pixels
- A length in logical pixels, GPUI’s unit for layout, painting and input.
- Platform
Frame Signal - Preserves the first platform frame request time across coalesced notifications.
- Platform
Input Handler - Connects the platform’s input method (IME) to the focused
InputHandler. - Playback
- The iteration count and configured direction of a run.
- Point
- A position or offset in two-dimensional space.
- Point
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Polychrome
Sprite - A sprite whose colors come from the atlas as they are, such as an image or a color emoji.
- Positioned
Inline Box - An atomic box from an inline layout, with the position the layout gave it.
- Prepared
Raster Style - The cache-relevant raster settings chosen by a platform rasterizer.
- Progress
- A motion’s presentation progress, normally between zero and one.
- Prompt
Handle - A handle that a prompt builder uses to show a prompt and report the user’s answer.
- Prompt
Response - The event a prompt emits when the user chooses one of its buttons.
- Quad
- A filled rectangle with an optional border and rounded corners, in scaled pixels.
- Radians
- An angle in radians.
- Raster
Style Request - A scene request before a platform rasterizer normalizes its cache-relevant settings.
- Rasterized
Glyph - A glyph raster produced by a platform rasterizer.
- Relative
- A length given as a fraction of a reference length.
- Rems
- A length in rems, a unit based on the font size of the window.
- Render
Glyph Params - Parameters for rendering a glyph, used as cache keys for glyph atlas entries.
- Render
Image - A decoded image: one or more frames of BGRA pixels, ready to draw.
- Render
Image Params - Render
SvgParams - Renderable
Prompt Handle - A prompt that a window can render, as returned by a prompt builder.
- Request
Frame Options - Options for a frame the platform asks GPUI to draw. The platform passes them to
the callback registered with
PlatformWindow::on_request_frame. - Reservation
- A slot for an entity that doesn’t exist yet.
- Resize
Region - Resize handles around a rectangle.
- Retain
AllImage Cache - An
ImageCachethat keeps every image it loads until you clear it, remove a source, or drop the cache. - Retain
AllImage Cache Provider - The
ImageCacheProviderthatretain_allreturns. - Ring
Style - A ring around or inside an element.
- Ring
Style Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Runnable
Meta - Metadata attached to runnables for debugging and profiling.
- Scaled
Pixels - A logical length multiplied by the display’s scale factor.
- Scene
- The primitives painted for one frame, ready for a renderer to consume.
- Scene
Hsla - Internal representation of
palette::Hslawith the layout provided to the renderer. - Scene
Plan - A compiled scene command stream, built by
Scene::finishand shared by every renderer. - Scene
Plan Requirements - Allocation and draw totals collected while compiling one
ScenePlan. - Scheduler
Local Executor - An executor for one session, for futures that are not
Send. - Scope
- A set of futures that run together and are awaited together.
- Screen
Capture Frame - One frame of captured video.
- Scroll
Anchor - A reference to an element that a
ScrollHandlecan scroll to, even if it is not a direct child of the scrolling element. - Scroll
Handle - A handle to the scroll state of an element, used to read the scroll position and to scroll it.
- Scroll
Wheel Event - A scroll from a mouse wheel, a trackpad, or a touch pan.
- Shadow
- A blurred shadow of a rounded rectangle. It is drawn outside the element, or inside it when
Shadow::insetis set. - Shaped
Glyph - One glyph in a shaped line, ready to paint.
- Shaped
Line - A shaped line that is ready to measure and paint.
- Shaped
Text - Shaped text that may contain hard breaks and soft-wrapped lines.
- Shaped
Text Layout - Shaped text with its wrap width, which is how a layout is measured and queried.
- Shared
String - A shared string is an immutable string that can be cheaply cloned in GPUI
tasks. Essentially an abstraction over an
Arc<str>and&'static str, currently backed by aSmolStr. - Shared
Uri - A URI held in a
SharedString, so cloning the handle does not copy its text. - Size
- A width and height, such as the size of a window or an element.
- Size
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Source
Metadata - Describes a screen or window that can be captured.
- Spring
Animation - A spring animation for an element: a
SpringConfig, a target and a starting value. - Spring
Animation Element - The element returned by
AnimationExt::with_spring. - Spring
Config - The physical parameters of a damped spring that moves a scalar toward a target.
- Spring
Description - The timing of a spring-driven
Motion: its physical parameters and settling tolerance. - Spring
State - The position and velocity of a spring at one instant.
- Stateful
- An element with an
ElementId, which lets it keep state between frames. - Strikethrough
Style - The properties that can be applied to a strikethrough.
- Strikethrough
Style Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Stroke
Options - Parameters for the tessellator.
- Style
- The resolved styling of an element, which GPUI uses to lay out and paint it.
- Style
Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Style
Transitions - Selects style properties to transition and configures their motion.
- Styled
Text - Text that is laid out and painted with a different style for each run.
- Subpixel
Sprite - A glyph drawn with subpixel anti-aliasing, tinted with
color. - Subscription
- A handle to a callback that GPUI calls until the handle is dropped.
- Surface
- An element that shows a platform video or capture frame, such as a camera feed.
- Svg
- An element that draws an SVG as a single-color mask, filled with the text color.
- SvgRenderer
- Parses and rasterizes SVG documents, resolving their fonts from the app’s
crate::AssetRegistry. - System
Notification - A notification for the operating system’s notification center, rather than in-app UI.
- System
Notification Action - A button on a
SystemNotification. - System
Notification Response - The user’s response to a
SystemNotification. - System
Window TabController - A global that tracks which windows are grouped into native window tabs.
- Task
- A handle to a future that runs in the background, and to its output.
- TestApp
- A headless app for tests.
- Test
AppContext - The test version of
App, passed to#[gpui::test]functions. - Test
AppWindow - A window opened by
TestApp::open_window. - Test
Screen Capture Source - A fake screen capture source for tests. It reports a 1x1 resolution and sends no frames.
- Test
Screen Capture Stream - A fake screen capture stream for tests. It reports the metadata of
TestScreenCaptureSource. - Test
Text System - Text
- An
Elementthat lays out and paints one text string. - Text
Input Configuration - Platform text-assistance preferences for the focused text region.
- Text
Layout - The laid-out state of a text element, for mapping between byte indices and pixels.
- Text
Layout Request - Complete input for one backend-owned text document layout.
- Text
Layout Truncation - How a text element should truncate its text to fit, computed during layout.
- Text
Movement - A caret movement described by a direction and a unit, such as “to the end of the word”.
- TextRun
- A stretch of text that shares one font and style.
- Text
Style - The text properties of an element: font, size, color and spacing.
- Text
Style Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Text
System - The platform-independent font database and metrics cache, shared by all windows.
- Threaded
Dispatcher - A [
PlatformDispatcher] that runs background work on real threads, for tests and benchmarks. - TileId
- Identifies a tile within its atlas texture.
- Tiling
- Which edges of a window are tiled against the screen edge.
- Timeout
- The error returned when a future given to
FutureExt::with_timeoutdoesn’t finish in time. - Titlebar
Options - Options for a window’s titlebar.
- Tooltip
Id - Identifies a tooltip set during prepaint with
Window::set_tooltip. - Touch
Click Event - A tap, or a long press, recognized on a touch screen.
- Touch
Drag Event - A touch drag that a listener can claim before the touch becomes a tap, long press or scroll.
- Touch
Event - A raw touch sample from a touch screen, before gesture recognition.
- TouchId
- Identifies one touch (finger or stylus contact) from its
TouchPhase::Startedevent through itsTouchPhase::EndedorTouchPhase::Cancelledevent. - Transformation
- A rotation, scale and translation applied to an
Svgwhen it is drawn. - Transformation
Matrix - A 2D affine transform in scaled pixels: a 2x2 linear part and a translation.
- Transition
- A value that moves toward a goal over time and changes course when that goal changes.
- UTF16
Selection - A struct representing a selection in a text buffer, in UTF16 characters. This is different from a range because the head may be before the tail.
- Unbind
- Removes a lower-precedence binding for the same keystrokes that runs the named action.
- Underline
- A horizontal line under or through text, which can be wavy.
- Underline
Style - The properties that can be applied to an underline.
- Underline
Style Refinement - A refinable version of [
#ident]. See that type’s documentation for details. - Uniform
List - The element returned by
uniform_list. Configure it with the builder methods, then return it fromrender. To read or set the scroll position, pass aUniformListScrollHandletoUniformList::track_scroll. - Uniform
List Frame State - The rows and decorations that a
UniformListlays out for one frame. You don’t construct it. - Uniform
List Scroll Handle - A handle that reads and sets the scroll position of a
UniformList. - Uniform
List Scroll State - The state that a
UniformListScrollHandleshares with itsUniformList. - Validated
Rasterized Glyph - A glyph raster whose placement and pixel buffer have passed validation.
- Visual
Line - One row of text produced by shaping and line breaking.
- Visual
Test Context - A
TestAppContextbound to one window, the test equivalent of aWindowandApp. - Weak
Entity - A handle to an entity that doesn’t keep it alive.
- Weak
Focus Handle - A focus handle that doesn’t keep its element focusable.
- Window
- The state of one platform window: its focus, input, bounds, frame and drawing.
- Window
Button Layout - Which
WindowButtons appear on each side of the titlebar, in order. - Window
Controls - The window controls a platform supports.
- Window
Handle - A handle to an open window whose root view has type
V. - Window
Id - Identifies an open window. A stale id from a closed window never matches a newer one.
- Window
Insets - Regions of a window that are obscured or reserved by the system.
- Window
Options - Options for creating a window, passed to
App::open_window. - Window
Params - The variables that can be configured when creating a new window
The platform-level options for one window, passed to
Platform::open_window. - Window
Text System - The text layout subsystem for one window, with a cache of shaped lines.
- Windowing
Modes - The windowing modes a platform may start in or switch to.
Enums§
- Absolute
Length - A length that doesn’t depend on the parent: pixels or rems.
- Accessible
Action - An action to be taken on an accessibility node.
- Action
Build Error - Error returned by
App::build_actionwhen an action can’t be built by name. - Activation
Policy - Controls whether the application participates in the system’s foreground UI.
- Align
Content - Distributes free space between flex lines or grid tracks along the cross axis.
- Align
Items - Aligns children along the cross axis in flexbox and the block axis in grid.
- Anchor
- A point on the edge or corner of a box, used to align a position to that box.
- Anchored
FitMode - How an
Anchoredelement keeps its children inside the window. - Anchored
Position Mode - The coordinate space of an
Anchoredelement’s anchor position. - AnyMotion
- A duration or spring
Motionbehind one type, so that an API can accept either. - AppLifecycle
Phase - The application’s lifecycle phase, as owned and reported by a mobile OS.
- ArcCow
- Asset
Entry - One asset in the
AssetRegistry: its bytes, or a loader that produces them on request. - Asset
Logger - Wraps an
Assetwhose output is aResult, and logs each error as it loads. - Atlas
Key - Identifies one entry in a
PlatformAtlas: a glyph, an SVG or a raster image. - Atlas
Texture Kind - The kind of pixels a texture in an atlas stores.
- Autocapitalize
- Automatic capitalization applied by software keyboards.
- Available
Space - How much space an element is given along one axis when it is laid out.
- Axis
- An axis of two-dimensional space.
- Background
Kind - What a
Backgroundpaints, decoded from its packed representation. - Background
Tag - The storage-buffer discriminant for a
Background. - Border
Style - The style of a
Quadborder. - Caret
Affinity - Determines which logical neighbor owns a caret at a shared text boundary.
- Click
Event - A completed click from the mouse, keyboard or touch.
- Clipboard
Entry - One part of a
ClipboardItem: a string, an image or a list of file paths. - Clipboard
Read Error - An error from
Platform::read_from_clipboard_async. Each variant calls for different guidance to the user. - Color
Space - A color space for color interpolation.
- Cursor
Hide Mode - Controls when GPUI hides the mouse cursor in response to keyboard input.
- Cursor
Style - The shape of the mouse cursor. Each variant names the CSS cursor it maps to on the web.
- Decorations
- The decorations a window is currently using.
- Deferred
Priority - How the draw priority of a
Deferredelement is chosen. - Definite
Length - A length with a value: an absolute length, or a fraction of the parent.
- Direction
- The configured direction of a motion’s iterations.
- Dispatch
Phase - The two passes an event makes through the element tree.
- Display
- Selects the layout algorithm used for this element’s children.
- Display
Event - A change to the connected displays, reported through
App::observe_displays. - Element
Id - Identifies an element across frames, so that its element state survives re-renders.
- External
Drag Payload - The content of a drag that leaves the window and becomes a native drag session handed to the operating system.
- File
Drop Event - A stage of a file drag from the operating system into the window.
- Fill
- The kinds of fill that can be applied to a shape.
- Fill
Rule - The fill rule defines how to determine what is inside and what is outside of the shape.
- Filter
- A graphical filter that can be applied either to an element’s own content
(via
Styled::filter, like CSSfilter) or to the content rendered behind it (viaStyled::backdrop_filter, like CSSbackdrop-filter). - Filter
Render Target - Where the contents of a filter group are rendered.
- Flex
Direction - The direction of a flex container’s main axis.
- Flex
Wrap - Controls whether flex items stay on one line or wrap onto multiple lines.
- Follow
Mode - Whether a
ListStatekeeps the end of the list in view as rows are added. - Font
Style - Selects an italic or oblique face when the font family has one.
- Foreground
Dependency - Describes which foreground channels can change rasterized color artwork.
- Frame
Request Source - The source of a platform frame request’s timestamp.
- Glyph
Render Mode - The kind of glyph image requested from a rasterizer.
- Grid
Placement - Where a grid item starts or ends along one axis of a grid.
- Grid
Template MinSize - The minimum size of a grid column or row.
- Haptic
Feedback Style - A kind of haptic feedback to play with
App::play_haptic_feedback. - Hitbox
Behavior - How a hitbox affects the hitboxes behind it.
- Hover
Listener Mode - Controls how
StatefulInteractiveElement::on_hoverresponds to key presses while the mouse is stationary. - Image
Asset Loader - Loads and decodes a
Resourceinto aRenderImage.imguses it, throughImgResourceLoader, for URLs, file paths and registry entries. - Image
Cache Error - Why an image failed to load or decode.
- Image
Format - An image format GPUI recognizes in clipboard data and in
Image. - Image
Source - Where an
imgelement gets its pixels. - Input
Preference - Whether a keystroke should prefer character input or key bindings.
- Iterations
- How many iterations a
Motionplays before it completes. - KeyBinding
Context Predicate - A condition on the key context stack that decides whether a binding applies.
- Keyboard
Button - The key that triggered a keyboard click: Enter or Space.
- Layout
Direction - The inline direction established by an element.
- Length
- A length that can be a definite value or
auto. - Linux
Window Background - The background appearance of a Linux window, set through
WindowOptions::linux_window_background. Whether blurring is honored depends on the compositor; X11 treats it as plain transparency. - List
Alignment - Where a
ListStatestarts: at its first row, or at its last row. - List
Horizontal Sizing Behavior - Whether the rows of a
crate::UniformListcan be wider than the list. - List
Measuring Behavior - Whether a
ListStatemeasures every row or only the rows it renders. - List
Sizing Behavior - How a
listorcrate::UniformListsizes itself during layout. - Menu
Item - An entry in a
Menu: a separator, a submenu, a system menu, or an action. - Motion
Extent - The total length of a motion, including its delay.
- Motion
Phase - Where a sampled motion is in its lifecycle.
- Mouse
Button - A mouse button.
- Navigation
Direction - The direction of a navigation button, the side buttons on some mice.
- Object
Fit - How an image is sized and positioned inside an element’s bounds.
- Orientation
- OsAction
- A standard command that the operating system knows about, such as Copy or Undo.
- Overflow
- How overflow affects layout and the scroll region.
- Owned
Menu Item - A
MenuItemin the form thatApp::get_menusreturns. - Pass
Direction - The direction of the pass that a sample falls in.
- Path
Style - How a
crate::PathBuildertessellates its path: as an outline, or as a filled shape. - Platform
Input - Any input event the platform sends to a window.
- Position
- The positioning strategy for this item.
- Pressure
Stage - How hard a force-sensitive trackpad is pressed.
- Primitive
- Any primitive that
Scene::insert_primitiveaccepts. - Primitive
Batch - A contiguous run of one primitive type that the renderer draws in one call.
- Priority
- Task priority for background tasks.
- Prompt
Button - A button on a prompt shown with
PlatformWindow::prompt. - Prompt
Level - How serious a prompt is. The platform uses it to choose the alert’s icon or style.
- Quit
Mode - Controls whether the app quits on its own when its last window closes.
- Raster
Color Effect - The part of the requested color, if any, which changes rasterized pixels.
- Rasterized
Glyph Format - The byte layout supplied by a glyph rasterizer.
- Render
Command - Backend-neutral rendering work derived from a
Scene. - Resize
Edge - The edge or corner of a window that a user drags to resize it.
- Resource
- Where an image or other asset is loaded from: a URL, a file path, or a name in the registry.
- Ring
Color - A ring’s color or gradient.
- Role
- The type of an accessibility node.
- Scaled
Filter - The scene-space (device-pixel) form of a
Filter, carried on the scene primitives that the renderers consume. Produced byFilter::scale; pixel magnitudes are inScaledPixels. - Scroll
Delta - The amount a scroll event moves the content.
- Scroll
Physics - How a fling slows down after the finger lifts.
- Scroll
Strategy - Where a scroll request places the target row in the viewport.
- Shader
Bool - A
boolstored as a four-byte integer, so its layout matches the GPU’s view of it. - Spring
Playback - How a spring advances, and where it rests, when its animation changes state.
- Surface
Source - The frame that a
Surfaceshows. - SvgSize
- The size at which
SvgRenderer::render_parsedrasterizes an SVG. - System
Menu Type - The kinds of menu that the operating system fills in.
- Text
Align - How text is aligned within the element.
- Text
Boundary - The unit that a semantic text movement stops at.
- Text
Direction - The direction of a semantic text movement, such as an arrow key or a Home key.
- Text
Input Action - The action a software keyboard advertises on its confirm (“enter”) key.
- Text
Input State Change - A change in the state of the focused text input.
- Text
Overflow - How text is truncated when it exceeds the element’s width.
- Text
Rendering Mode - The text rendering mode for glyphs.
- Text
Selection Kind - The unit selected by a double or triple click at a point.
- Text
Transform - Case mapping applied at layout time while keeping UTF-8 byte lengths unchanged.
- Thermal
State - The device’s thermal pressure, from least to most constrained.
- Toggled
- Touch
Phase - The lifecycle stage of a touch, scroll or pinch event.
- Truncate
From - The part of an overflowing line that is removed and replaced by the affix.
- Unicode
Bidi - Controls the Unicode bidirectional scope established by an element.
- Vertical
Align - Controls the vertical position of an element box in an inline formatting context.
- Visibility
- Whether an element is painted while it remains in layout.
- Visual
Direction - A direction in visual order, which is left and right on screen, regardless of text direction.
- White
Space - How text handles whitespace and line wrapping.
- Window
Appearance - The light or dark appearance of a window, as the operating system defines it.
- Window
Background Appearance - How a window’s background is drawn when there is no content or the content is transparent.
- Window
Bounds - The state a window opens in, with the bounds it uses for that state.
- Window
Button - A window control button, used in
WindowButtonLayout. - Window
Control Area - A region of a custom title bar that the operating system treats as a window control.
- Window
Decorations - Whether a window draws its own titlebar and borders, or the window server does.
- Window
Kind - The kind of window to create, set with
WindowOptions::kind. - Window
Visibility - Whether the platform is presenting a window’s frames.
- Windowing
Request - A display mode for
App::request_windowingto switch to.
Constants§
- DEFAULT_
ADDITIONAL_ WINDOW_ SIZE - A 6:5 minimum window size in logical pixels, for secondary windows such as settings or document-library windows.
- DEFAULT_
WINDOW_ SIZE - The size, in logical pixels, of a window whose bounds were not set.
- KEYSTROKE_
PARSE_ EXPECTED_ MESSAGE - The sentence that
InvalidKeystrokeErrorappends to its message. It describes the syntaxKeystroke::parseexpects. - LOADING_
DELAY - How long an image may take to load before the
StyledImage::with_loadingplaceholder appears. - MAX_
BUTTONS_ PER_ SIDE - The largest number of
WindowButtons on one side of the titlebar. - MAX_
FILTER_ GROUP_ DEPTH - Inline capacity of renderer isolation stacks. Deeper groups allocate additional targets.
- SHUTDOWN_
TIMEOUT - The duration for which native applications wait for futures returned from Context::on_app_quit before fully quitting.
- SMOOTH_
SVG_ SCALE_ FACTOR - The multiplier used when
SvgRenderer::render_parsedrasterizes a scale-factor request. - SUBPIXEL_
VARIANTS_ X - The number of horizontal subpixel positions each glyph is rasterized at.
- SUBPIXEL_
VARIANTS_ Y - The number of vertical subpixel positions each glyph is rasterized at.
Traits§
- Action
- An action is a named command that the app can run, such as saving or moving the cursor up.
- Along
- Reads and updates the value along one
Axis. - Animation
Ext - Adds animation methods to every element and component.
- AppContext
- Operations shared by GPUI’s app, entity and async contexts.
- AsKeystroke
- A type that can be viewed as a
Keystroke. - Asset
- A value that GPUI loads in the background and shares between callers, such as an image.
- Asset
Source - A read-only source of files that the app can load by path, such as a directory or a bundle.
- Borrow
AppContext - Helpers for changing globals from any context that can reach the
App. - Color
Ext - Helpers for changing the alpha of a color.
- Duration
With Easing - The former name of
MotionDurationExt. Adds motion constructors toDuration, includingduration.with_easing(...). - Element
- A part of a window’s element tree that lays itself out and paints itself.
- Entity
Input Handler - Text input for a view: the methods the platform calls for typed text, IME composition, paste and selection.
- Event
Emitter - Declares that an entity type emits events of type
E. - Focusable
- A view that owns a
FocusHandleand can be focused as a whole. - Future
Ext - Adds timeout combinators to futures.
- Gesture
Event - A gesture event recognized from touch input, such as
PinchEvent,LongPressEventorTouchDragEvent. - Global
- Marks a type whose value is stored once per app.
- Half
- Returns half of a value, for centering and midpoints.
- Image
Cache - A store of decoded images that
imgelements read from. - Image
Cache Provider - Creates the
AnyImageCachefor animage_cacheelement. - Input
Event - A platform input event that GPUI can dispatch to a window.
- Input
Handler - Receives text from the platform’s input method (IME) on behalf of a focused element.
- Interactive
Element - An element that can respond to the mouse and keyboard, style itself on state, and take focus.
- Interpolate
- A value that
AnimationPhasecan interpolate. - Into
Element - A type that can be converted into an
Element, so it can be a child of another element. - IsEmpty
- IsZero
- Checks whether a length or geometry value is zero.
- KeyEvent
- An input event from the keyboard:
KeyDownEvent,KeyUpEventorModifiersChangedEvent. - Lerp
- A type whose values can be interpolated between two endpoints.
- Managed
View - A view whose lifetime is controlled by a parent view, such as a modal, popover or menu.
- Motion
Duration Ext - The former name of
MotionDurationExt. Adds motion constructors toDuration, includingduration.with_easing(...). - Mouse
Event - An input event from a pointer or touch: mouse buttons, movement, scrolling, pinch, pressure, file drops and the gesture events.
- Parent
Element - An element that can hold any number of children of any type.
- Parent
Element Typed - A parent element whose children all have one concrete type.
- Platform
- The operating system or browser that GPUI runs on, as seen by the
App. - Platform
Atlas - A texture atlas that packs glyphs, SVGs and images into shared GPU textures.
- Platform
Display - A display, such as a monitor or a laptop screen, as the platform reports it.
- Platform
Gestures - Gesture settings that a platform supplies to GPUI.
- Platform
Headless Renderer - Renders scenes offscreen for windows that have no display, such as in tests and benchmarks.
- Platform
Keyboard Layout - The keyboard layout that is currently active on a platform.
- Platform
Keyboard Mapper - Maps keystrokes in keybindings to the keys the platform reports.
- Platform
Text Layout - The text interaction model that a backend provides for one laid-out string.
- Platform
Text System - Loads fonts and lays out text for one platform. Each backend implements this trait.
- Platform
Window - The native window that GPUI draws into, implemented by each backend.
- Prompt
- A view that can be shown as a prompt in a window.
- Raster
Color Ext - Converts a scene color to the bytes used by a raster cache key.
- Read
Global - Reads the global of the implementing type from an
App, as inTheme::global(cx). - Refineable
- A trait for types that can be refined with partial updates.
- Render
- A view: an entity that GPUI draws in a window.
- Render
Once - A component: a value that describes a pattern of elements and renders it once.
- Screen
Capture Source - A screen or window that can be captured.
- Screen
Capture Stream - A running capture of a
ScreenCaptureSource. - Spring
Target - A value that a one-dimensional spring can target.
- Stateful
Interactive Element - An element with an id, which can also be clicked, scrolled, dragged, given a tooltip, and read by accessibility tools.
- Styled
- Sets an element’s layout, paint and text properties.
- Styled
Image - Styling methods for image elements, implemented by
ImgandStateful<Img>. - TaskExt
- Extension methods for tasks that produce a
Result. - Text
Range Ext - UTF-8 text range containment checks.
- Uniform
List Decoration - An element drawn over the rows of a
UniformList, such as indent guides. - Update
Global - Changes or sets the global of the implementing type through a context.
- View
- A value that renders into elements and may carry an entity identity.
- Visual
Context - Operations that need a window.
Functions§
- align_
inline_ boxes - Applies CSS-like vertical alignment to boxes after a text backend assigns them to lines.
- anchored
- Creates an
Anchoredelement that keeps its children inside the window. - auto
- Returns
Length::Auto, which lets layout choose the size from the context. - black
- Opaque black in
Hsla. - block_
on - Block the thread until the future is ready.
- blue
- Opaque blue in
Hsla, at hue 240 degrees. - bounce
- Runs
easingforward over the first half, then backward over the second half. - bounds
- Creates
Boundsfrom an origin and a size. - canvas
- Creates a
Canvasthat draws with the painting methods onWindow. - checkerboard
- Creates a checkerboard of squares in
color, alternating with transparency. - combine_
highlights - Combine and merge the highlights and ranges in the two iterators.
- container_
query - Creates a
ContainerQuerywhose contents depend on the size it is given. - deferred
- Creates a
Deferredelement that drawschildafter the rest of the tree. - div
- Creates an empty
Divelement, which you style and fill with children. - ease_
in_ out - Starts and ends slowly, and moves fastest at the midpoint.
- ease_
out_ quint - Starts quickly and decelerates to a stop.
- fallback_
prompt_ renderer - Shows a prompt drawn inside the window, rather than a platform dialog.
- fill
Deprecated - Returns a filled quad with no border and no corner radius.
- font
- Returns a
Fontforfamily, with normal weight, width, and style. - generate_
list_ of_ all_ registered_ actions - Generate a list of all the registered actions. Useful for transforming the list of available actions into a format suited for static analysis such as in validating keymaps, or generating documentation.
- get_
gamma_ correction_ ratios - Returns the gamma correction ratios for subpixel text at
gamma. - green
- A dark, opaque green in
Hsla, at hue 120 degrees and lightness 0.25. - guess_
compositor - Return which compositor we’re guessing we’ll use. Does not attempt to connect to the given compositor.
- hash
- Hashes
datawith a fast, non-cryptographic hash, for use as a cache key within one process. - hsla
- Creates an
Hslacolor from hue, saturation, lightness and alpha. - hsla_
schemar - Generates the JsonSchema for palette::Hsla
- hsla_
to_ rgba - Converts an
Hslacolor to sRGBRgba, keeping the alpha. - image_
cache - Scopes an image cache to the
imgelements below it. - img
- Creates an image element that draws
source. - is_
no_ action - Returns whether
actionis aNoAction. - is_
paragraph_ separator - Returns whether
characterseparates Unicode text paragraphs. - is_
unbind - Returns whether
actionis anUnbind. - linear
- Returns
deltaunchanged. This is the default easing. - linear_
color_ stop - Creates a color stop of
coloratpercentagealong a gradient line. - linear_
gradient - Creates a linear gradient between two color stops.
- list
- Creates a list element that renders rows of any height, using the state in
state. - millis
- Creates a
Durationfrom whole milliseconds. - oklcha
- Creates an
Oklchacolor from lightness, chroma, hue and alpha. - opaque_
grey - A grey in
Hslawith the given lightness and opacity. - outline
Deprecated - Returns a transparent quad with a 1px border and the given border style.
- pattern_
slash - Creates a background of diagonal stripes in
color, over transparency. - percentage
- Creates a
Percentageof a full turn. - phi
- Returns the golden ratio, about
1.618, as aRelativelength. - point
- Creates a
Pointfrom itsxandycoordinates. - pulsating_
between - Breathes between
minandmax, for idle indicators. - px
- Creates a
Pixelslength, the usual way to write a fixed size in logical pixels. - quad
Deprecated - Returns a quad with bounds, radii, background, border widths, border color and border style.
- quadratic
- Accelerates from rest. Returns
delta * delta. - radians
- Creates a
Radiansangle from a value in radians. - red
- Opaque red in
Hsla, at hue0.0. - refresh_
interval_ from_ hz - Converts a refresh rate in hertz to the time between refreshes, rejecting the zero, negative, and non-finite rates platforms use to mean “unknown”.
- relative
- Creates a
Relativelength, a fraction of the reference length. - rems
- Creates a
Remslength. - retain_
all - Returns a provider for an
image_cacheelement that keeps oneRetainAllImageCachein the element state underid. - rgb
- Creates an opaque
Rgbacolor from a0xRRGGBBhex number. - rgb_
to_ hsla - Converts an sRGB
Rgbacolor toHsla, keeping the alpha. - rgba
- Creates an
Rgbacolor from a0xRRGGBBAAhex number. - rgba_
schemar - Generates the JsonSchema for palette::Rgba
- sampled_
easing - Returns the time a spring takes to settle from rest, and an easing that samples it over that time.
- secs
- Creates a
Durationfrom whole seconds. - size
- Creates a
Sizefrom its width and height. - solid_
background - Creates a solid background of
color. - spring
- Creates a
SpringConfigfrom stiffness, damping and mass. - surface
- Creates a
Surfacethat showssource. - svg
- Creates an
Svgelement with no source yet. - swap_
rgba_ pa_ to_ bgra - Converts one premultiplied RGBA pixel to straight-alpha BGRA, in place.
- transparent_
black - Black with zero alpha in
Hsla. - transparent_
white - White with zero alpha in
Hsla. - uniform_
list - Creates a list of rows that all have the same height, and renders only the rows in view.
- utf8_
to_ utf16_ offset - Converts a UTF-8 byte offset into a UTF-16 code-unit offset.
- utf16_
to_ utf8_ offset - Converts a UTF-16 code-unit offset into a UTF-8 byte offset.
- white
- Opaque white in
Hsla. - yellow
- Opaque yellow in
Hsla, at hue 60 degrees.
Type Aliases§
- Align
Self - Aligns one child along the cross axis in flexbox or the block axis in grid.
- Asset
Data - The bytes of one asset.
Cow::Borrowedfor data compiled into the binary, andCow::Ownedfor data read at runtime. - CanDrop
Listener Fn - Function type for
DropListener::can_drop, which checks if a typed payload can be dropped on an element’s hitbox. - Caret
Selection Movement - The result of moving a selection: the new anchor and caret, and the column to keep.
- Draw
Order - The order in which primitives are drawn. Lower values are drawn first.
- External
Drag Payload Source - A closure that builds the payload for a drag that leaves the window.
- FnAsset
Loader - A callback that produces an asset’s bytes when the asset is requested, or
Noneif it can’t. - Hsla
- Linear HSL with an alpha component. See the
Hslaimplementation inAlpha. - ImgResource
Loader - The asset loader that
imguses forImageSource::Resourcesources: URLs, file paths andcrate::AssetRegistryentries. - Inspector
Renderer - The function that builds the inspector panel. Install it with
App::set_inspector_renderer. - Justify
Content - Distributes free space between flex items or grid tracks along the main or inline axis.
- Justify
Items - Aligns grid children along the inline axis.
- Justify
Self - Aligns one grid child along the inline axis.
- MacActivation
Policy Deprecated - The activation policy for a macOS application.
- Motion
Info Deprecated - The former name of
Motion. - OnDrag
Over Fn - Function type for
DropListener::on_drag_over. - OnDrop
Fn - Function type for
DropListener::on_drop. - Path
Vertex_ Scaled Pixels - A
PathVertexin scaled pixels. - Result
Result<T, Error>- Rgba
- Generic RGB with an alpha component. See the
Rgbaimplementation inAlpha. - Rgba8
- Eight-bit sRGB color stored in a raster cache key when a native raster path needs it.
- Runnable
Variant - Type alias for runnables with metadata. Previously an enum with a single variant, now simplified to a direct type alias.
- Timer
Resolution Guard - Transform
- Alias for
euclid::default::Transform2D<f32> - Transition
State - The state behind a
Transition: anAnimatedthat reads the clock fromInstant.
Attribute Macros§
- bench
- Turns a function into a Criterion benchmark that runs with GPUI support.
- property_
test - A variant of
#[gpui::test]that runs a test with many generated inputs. - test
- Marks a function as a GPUI test. The generated function is a
#[test], so it runs undercargo testorcargo nextest.
Derive Macros§
- Action
- Derives
gpui::Actionfor a type and registers it with the runtime. - AppContext
- Derives
gpui::AppContextfor a struct that holds a&mut gpui::App. - Interactive
Element - Derives
gpui::InteractiveElementfor a struct with an#[interactivity]field. - Into
Element - Derives
gpui::IntoElementfor a type that implementsgpui::RenderOnce. - Parent
Element - Derives
gpui::ParentElementfor a struct with a#[children]field. - Refineable
- Stateful
Interactive Element - Derives
gpui::StatefulInteractiveElement, which adds methods such asrole. - Styled
- Derives
gpui::Styledfor a struct with a#[style]field. - Visual
Context - Derives
gpui::VisualContextfor a struct that holds a&mut gpui::Appand a&mut gpui::Window.