Expand description
§Welcome to GPUI!
GPUI is a hybrid immediate and retained mode, GPU accelerated, UI framework for Rust, designed to support a wide variety of applications.
§Getting Started
GPUI is still in active development as we work on the Zed code editor, and is still pre-1.0. There will often be breaking changes between versions. You’ll also need to use the latest version of stable Rust. Add gpui, and optionally gpui_platform, to your Cargo.toml:
gpui = { version = "*" }
gpui_platform = { version = "*", features = ["font-kit", "wayland", "x11"] }Everything in a standalone GPUI app starts with an Application. You can create one with gpui_platform::application(), which picks the windowing and text backends for the host OS, and kick off your application by passing a callback to Application::run(). Inside this callback, you can create a new window with App::open_window() and register your first root view.
use gpui::*;
fn main() {
gpui_platform::application().run(|cx: &mut App| {
// ..
});
}§gpui_platform
The features on gpui_platform are platform-specific, so the list above is a safe cross-platform default. If you build for a single platform, you can trim it:
-
macOS — Rendering uses Metal and is always available, but glyph rasterization needs
font-kit. Without it, GPUI falls back to a placeholder text system that lays text out but renders no glyphs.gpui_platform = { version = "*", features = ["font-kit"] } -
Linux / FreeBSD — enable at least one windowing backend for desktop windows:
wayland,x11, or both. These features also compile the renderer and text system, so no separate text feature is needed.gpui_platform = { version = "*", features = ["wayland", "x11"] } -
Windows — no features are required. Windowing uses Win32 and text uses DirectWrite.
font-kithas no effect here.
§Additional Topics
§Dependencies
GPUI has various system dependencies that it needs in order to work.
§macOS
On macOS, GPUI uses Metal for rendering. In order to use Metal, you need to do the following:
- Install Xcode from the macOS App Store, or from the Apple Developer website. Note this requires a developer account.
Ensure you launch Xcode after installing, and install the macOS components, which is the default option.
-
Install Xcode command line tools
xcode-select --install -
Ensure that the Xcode command line tools are using your newly installed copy of Xcode:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
§The Big Picture
GPUI offers three different registers depending on your needs:
-
State management and communication with
Entity’s. Whenever you need to store application state that communicates between different parts of your application, you’ll want to use GPUI’s entities. Entities are owned by GPUI and are only accessible through an owned smart pointer similar to anRc. See theapp::contextmodule for more information. -
High level, declarative UI with views. All UI in GPUI starts with a view. A view is simply an
Entitythat can be rendered, by implementing theRendertrait. At the start of each frame, GPUI will call this render method on the root view of a given window. Views build a tree ofelements, lay them out and style them with a tailwind-style API, and then give them to GPUI to turn into pixels. See thedivelement for an all purpose swiss-army knife of rendering. -
Low level, imperative UI with Elements. Elements are the building blocks of UI in GPUI, and they provide a nice wrapper around an imperative API that provides as much flexibility and control as you need. Elements have total control over how they and their child elements are rendered and can be used for making efficient views into large lists, implement custom layouting for a code editor, and anything else you can think of. See the
elementmodule for more information.
Each of these registers has one or more corresponding contexts that can be accessed from all GPUI services. This context is your main interface to GPUI, and is used extensively throughout the framework.
§Other Resources
In addition to the systems above, GPUI provides a range of smaller services that are useful for building complex applications:
-
Actions are user-defined structs that are used for converting keystrokes into logical operations in your UI. Use this for implementing keyboard shortcuts, such as cmd-q. See the
actionmodule for more information. -
Platform services, such as
quit the apporopen a URLare available as methods on theapp::App. -
An async executor that is integrated with the platform’s event loop. See the
executormodule for more information., -
The
[gpui::test]macro provides a convenient way to write tests for your GPUI applications. Tests also have their own kind of context, aTestAppContextwhich provides ways of simulating common platform input. Seeapp::test_contextandtestmodules for more details.
Currently, the best way to learn about these APIs is to read the Zed source code or drop a question in the Zed Discord. We’re working on improving the documentation, creating more examples, and will be publishing more guides to GPUI on our blog.
Re-exports§
pub extern crate accesskit;pub extern crate http_client;
Re-exports§
pub use profiler::*;
Modules§
- _accessibility
- Accessibility in GPUI
- _ownership_
and_ data_ flow - In GPUI, every model or view in the application is actually owned by a single top-level object called the
App. When a new entity or view is created (referred to collectively as entities), the application is given ownership of their state to enable their participation in a variety of app services and interaction with other entities. - colors
- The default colors used by GPUI.
- effect_
id - The built-in effect a
EffectQuadselects, and the index of its pipeline in the renderer’s effect table. - inspector_
reflection - Provides definitions used by
#[derive_inspector_reflection]. - layer_
shell - native_
profiling - Optional embedder hooks for recording native drawing spans. Optional drawing-thread spans supplied by an embedding application.
- 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.
- present_
feedback - vue-native fork: when each window present reached the screen, for an embedder that times its own frames against the display.
- profiler
- Profiling utilities for task, frame, and thread performance tracking.
- queue
- Provides a thread-safe queue with weighted random selection between priorities.
- styled_
reflection - Implements function reflection
- vn_
layer_ flags - vue-native fork:
VnLayer::flags.
Macros§
- actions
- Defines and registers unit structs that can be used as actions. For more complex data types, derive
Action. - border_
style_ methods - Generates methods for border styles.
- box_
shadow_ style_ methods - Generates methods for box shadow styles.
- cursor_
style_ methods - Generates methods for cursor styles.
- margin_
style_ methods - Generates methods for margin styles.
- overflow_
style_ methods - Generates methods for overflow styles.
- padding_
style_ methods - Generates methods for padding styles.
- position_
style_ methods - Generates methods for position styles.
- register_
action - This can be used to register an action with the GPUI runtime when you want to manually implement
the
Actiontrait. Typically you should use theActionderive macro oractions!macro instead. - text
- Create a new
Textelement. - visibility_
style_ methods - Generates methods for visibility styles.
Structs§
- A11y
Callbacks - Callbacks for the accessibility adapter.
- A11y
Subtree Builder - Builder API for synthetic children. See the docs for
Element::a11y_synthetic_children. - Activity
Guard - Keeps an operating system activity, such as an idle sleep inhibitor, alive until dropped.
- Anchored
- An anchored element that can be used to display UI that will avoid overflowing the window bounds.
- Anchored
State - The state that the anchored element element uses to track its children.
- Animation
- An animation that can be applied to an element.
- Animation
Element - A GPUI element that applies an animation to another element
- Animation
Phase - A potentially overshooting coordinate within an animation.
- AnyDrag
- Contains state associated with an active drag operation, started by dragging an element within the window or by dragging into the app from the underlying platform.
- AnyElement
- A dynamically typed element that can be used to store any element type.
- AnyEntity
- A dynamically typed reference to a entity, which can be downcast into a
Entity<T>. - AnyImage
Cache - A dynamically typed image cache, which can be used to store any image cache
- AnyTooltip
- Contains state associated with a tooltip. You’ll only need this struct if you’re implementing tooltip behavior on a custom element. Otherwise, use Div::tooltip.
- AnyView
- A dynamically-typed view handle that can be downcast to a specific
Entity<V>. - AnyWeak
Entity - A type erased, weak reference to a entity.
- AnyWeak
View - A weak, dynamically-typed view handle.
- AnyWindow
Handle - A handle to a window with any root view type, which can be downcast to a window with a specific root view type.
- App
- Contains the state of the full application, and passed as a reference to a variety of callbacks.
Other Context derefs to this type.
You need a reference to an
Appto access the state of a Entity. - AppEffect
- One app effect as far as a renderer is concerned; parameter names, defaults and ranges belong to the CSS layer.
- AppEffect
Pipelines - A renderer’s pipelines for the app’s effects,
effect_id::COUNT + index.Self::syncrebuilds only the effects that changed since the last call; one whose new shader is unusable keeps its previous pipeline, and only an effect that never built is a hole. - AppEffects
- An app’s effects: its
effects.jsonand the generated shaders it names. - Application
- A reference to a GPUI application, typically constructed in the
mainfunction of your app. You won’t interact with this type much outside of initial configuration and startup. - 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.
- Async
App - An async-friendly version of App with a static lifetime so it can be held across
awaitpoints in async code. You’re provided with an instance when calling App::spawn, and you can also create one with App::to_async. - Async
Window Context - A cloneable, owned handle to the application context, composed with the window associated with the current task.
- Atlas
Kind Stats - vue-native fork: one
AtlasTextureKind’s pages in a sprite atlas. - Atlas
Stats - vue-native fork: a sprite atlas’s footprint, indexed by
AtlasTextureKind as usize(monochrome, polychrome, subpixel). - Atlas
Texture Id - Atlas
Tile - Back
Gesture Event - A back-navigation gesture, such as the iOS swipe from the leading screen edge.
- Backdrop
Blur Effect - Options for
Window::paint_backdrop_blur_rect. - Backdrop
Blur Rect - A rounded rect that replaces the pixels already painted behind it with a
blurred copy of them — the primitive behind CSS
backdrop-filter: blur(). - Background
- A background: a solid colour, one of the two procedural patterns, or a
linear / radial / conic gradient of up to
GRADIENT_STOPSstops, optionally repeating and optionally tiled across the box. - Background
Executor - A pointer to the executor that is currently running, for spawning background tasks.
- Binding
Index - Index of a binding within a keymap.
- Boundary
- A boundary between two lines of text.
- Bounds
- Represents a rectangular area in a 2D space with an origin point and a size.
- Bounds
Refinement - A refinable version of [
#ident], see that documentation for details. - BoxShadow
- The possible values of the box-shadow property
- Canvas
- A canvas element, meant for accessing the low level paint API without defining a whole custom element
- Capslock
- The state of the capslock key at some point in time
- 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 - A clipboard item that should be copied to the clipboard
- Clipboard
String - A clipboard item that should be copied to the clipboard
- Composed
Face - One face of a composed family: the family it is registered under (a family of its own, holding that one font file) and the characters it draws.
- Container
Query - A container query element, created with
container_query. - Content
Mask - Indicates which region of the window is visible. Content falling outside of this mask will not be rendered.
- Context
- The app context, with specialized behavior for the given entity.
- Context
Entry - An entry in a KeyContext
- Corner
Shape - CSS
corner-shape: the superellipse parameterKofsuperellipse(K)(css-borders-4 §3.7). The corner isx^(2^K) + y^(2^K) = 1, mirrored about the corner whenKis negative. - Corner
Shapes - The corner shapes of a primitive as the shaders read them. Each corner’s word holds the
shape’s half corner in its low 12 bits, 0 for
round, then two 10-bit insets in quarter pixels: the corner is the inner edge of a border that wide on the boxboundsis inside. - Corners
- Represents the corners of a box in a 2D space, such as border radius.
- Corners
Refinement - A refinable version of [
#ident], see that documentation for details. - D3D12
Texture Handle - Borrowed D3D12 resource and producer fence. Both pointers remain valid
through the owner passed to
PlatformAtlas::upload_from_d3d12. - Debug
Below - Use this struct for interfacing with the ‘debug_below’ styling from your own elements. If a parent element has this style set on it, then this struct will be set as a global in GPUI.
- Decoration
Run - Set the text decoration for a run of text.
- Dedicated
Executor - A long-lived handle to one dedicated session: every future spawned on it runs on that session’s single thread, never on the background pool.
- Deferred
- An element which delays the painting of its child until after all of its ancestors, while keeping its layout as part of the current element tree.
- Deferred
Scroll ToItem - Device
Pixels - Represents physical pixels on the display.
- Dismiss
Event - Emitted by implementers of
ManagedViewto indicate the view should be dismissed, such as when a view is presented as a modal. - Dispatch
Event Result - Display
Changes - The properties of a display that a
DisplayEvent::Changedreports. - Display
Id - An opaque identifier for a hardware display
- Div
- A
Divelement, the all-in-one element for building complex UIs in GPUI - DivFrame
State - A frame state for a
Divelement, which contains layout IDs for its children. - DivInspector
State - Interactivity state displayed an manipulated in the inspector.
- Drag
Move Event - An event for when a drag is moving over this element, with the given state type.
- Drawable
- A wrapper around an implementer of
Elementthat allows it to be drawn in a window. - Dummy
Keyboard Mapper - A dummy implementation of the platform keyboard mapper
- Edges
- Represents the edges of a box in a 2D space, such as padding or margin.
- Edges
Refinement - A refinable version of [
#ident], see that documentation for details. - Effect
Cross Fade - A
--shadingtransition between two different effects:frompaints at1 - progressbeneath the style’s own effect atprogress. - Effect
Quad - A rounded rect shaded by a custom fragment pipeline — the primitive behind
the
--shadingCSS property. - Effect
Spec - The
--shadingvalue that came out of the cascade, carried oncrate::Styleand painted bycrate::Style::paint. - Effect
Texture - An image an effect quad samples.
- Effect
Texture Cache - A renderer’s uploaded effect textures, keyed by image and colour handling.
- Effect
Texture Param - One
SkTextureparameter of anEffectSpec. - Element
Clicked State - Whether or not the element or a group that contains it is clicked by the mouse.
- Element
Hover State - Whether or not the element or a group that contains it is hovered.
- Element
Input Handler - The canonical implementation of
crate::PlatformInputHandler. CallWindow::handle_inputwith an instance during your element’s paint. - Empty
- The empty element, which renders nothing.
- Empty
View - A view that renders nothing
- Entity
- A strong, well-typed reference to a struct which is managed by GPUI
- Entity
Id - A unique identifier for a entity across the application.
- External
Paths - A collection of paths from the platform, such as from a file drop.
- Fallback
Prompt Renderer - The default GPUI fallback for rendering prompts, when the platform doesn’t support it.
- Fallible
Task - A task that returns
Option<T>instead of panicking when cancelled. - File
Drag Paths - Paths handed to the platform for a native file drag. Directory metadata is provided by the caller to avoid querying it when the platform drag starts.
- Fill
Options - How to fill a path.
- Focus
Handle - A handle which can be used to track and manipulate the focused element in a window.
- FocusId
- A globally unique identifier for a focusable element.
- Focus
OutEvent - This is provided when subscribing for
Context::on_focus_outevents. - Font
- The configuration details for identifying a specific font.
- Font
Fallbacks - The fallback fonts that can be configured for a given font. Fallback fonts family names are stored here.
- Font
Family Id - An opaque identifier for a specific font family.
- Font
Features - The OpenType features that can be configured for a given font.
- FontId
- An opaque identifier for a specific font.
- Font
Metrics - A struct for storing font metrics. It is used to define the measurements of a typeface.
- FontRun
- A run of text with a single font.
- Font
Weight - The degree of blackness or stroke thickness of a font. This value ranges from 100.0 to 900.0, with 400.0 as normal.
- Foreground
Executor - A pointer to the executor that is currently running, for spawning tasks on the main thread.
- Frame
Work - One frame request:
started..endedis the time it took on this thread. - Gesture
Kinds - The set of gesture kinds that participate in recognition.
- Gesture
Tuning - Feel constants consumed by gesture recognizers. Provided on a best-effort basis, depending on each platform’s support, defaulting to GPUI’s own (iOS flavored) values
- Global
Element Id - A globally unique identifier for an element, used to track state across frames.
- GlyphId
- An identifier for a specific glyph, as returned by
WindowTextSystem::layout_line. - Glyph
Raster Data - Pre-computed glyph data for efficient painting without per-glyph cache lookups.
- Glyph
Shadow Params - vue-native fork: identifies a glyph’s
text-shadowcoverage, blurred, in the sprite atlas. - GpuSpecs
- Information about the GPU GPUI is running on.
- GpuTexture
Handle - A borrowed, platform-defined handle to a texture that already lives in the
GPU memory of the renderer’s own device. See
PlatformAtlas::upload_from_gpu. - Gpui
Borrow - A mutable reference to an entity owned by GPUI
- Graphical
Environment - The graphical session to connect to: the variables that locate its display server, as some process sees them.
- Grid
Auto Repeat - vue-native fork: CSS
repeat(auto-fill | auto-fit, <tracks>)inside a track list — as many repetitions as fit the container, which taffy counts at layout time. The repeated tracks are a run of the track list it belongs to (Style::vn_grid_cols/Style::vn_grid_rows); CSS allows one such repetition per list, and every other track in that list must then have a fixed size, which the caller checks. - Grid
Location - A location in a grid layout.
- Grid
Template - A simplified representation of the grid-template-* value
- Grid
Template Refinement - A refinable version of [
#ident], see that documentation for details. - Grid
Track - One track in a
grid-template-columns/grid-template-rowslist. - Group
Style - The styling information for a given group.
- 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. - Hitbox
- A rectangular region that potentially blocks hitboxes inserted prior. See Window::insert_hitbox for more details.
- Hitbox
Id - An identifier for a Hitbox which also includes HitboxBehavior.
- Hsla
- An HSLA color
- Image
- An image, with a format and certain bytes
- Image
Cache Element - An image cache element.
- Image
Cache Item - Owns an image load and its cached result.
- ImageId
- A unique identifier for the image cache
- Image
Style - The style of an image element.
- Img
- An image element.
- ImgLayout
State - The image layout state between frames
- Inspector
- Manages inspector state - which element is currently selected and whether the inspector is in picking mode.
- Inspector
Element Id - A unique identifier for an element that can be inspected.
- Inspector
Element Path GlobalElementIdqualified by source location of element construction.- Interactive
Element State - The per-frame state of an interactive element. Used for tracking stateful interactions like clicks and scroll offsets.
- Interactive
Text - A text element that can be interacted with.
- Interactivity
- The interactivity struct. Powers all of the general-purpose
interactivity in the
Divelement. - Invalid
Keystroke Error - Error type for
Keystroke::parse. This is used instead ofanyhow::Errorso that Zed can use markdown to display it. - Item
Size - The size of the item and its contents.
- KeyBinding
- A keybinding and its associated metadata, from the keymap.
- KeyBinding
Meta Index - A unique identifier for retrieval of metadata associated with a key binding. Intended to be used as an index or key into a user-defined store of metadata associated with the binding, such as the source of the binding.
- KeyContext
- A datastructure for resolving whether an action should be dispatched at this point in the element tree. Contains a set of identifiers and/or key value pairs representing the current context for the keymap.
- KeyDown
Event - The key down event equivalent for the platform.
- KeyUp
Event - The key up event equivalent for the platform.
- Keybinding
Keystroke - Represents a keystroke that can be used in keybindings and displayed to the user.
- Keyboard
Click Event - A click event that was generated by a keyboard button being pressed and released.
- Keymap
- A collection of key bindings for the user’s application.
- Keymap
Version - An opaque identifier of which version of the keymap is currently active. The keymap’s version is changed whenever bindings are added or removed.
- Keystroke
- A keystroke and associated metadata generated by the platform
- Keystroke
Display - A keystroke formatted with an explicit host operating system.
- Keystroke
Event - A keystroke event, and potentially the associated action
- Layout
Id - A unique identifier for a layout node, generated when requesting a layout from Taffy
- Line
Layout - A laid out and styled line of text
- Line
Wrapper - The GPUI line wrapper, used to wrap lines of text to a given width.
- Line
Wrapper Handle - A handle into the text system, which can be used to compute the wrapped layout of text
- Linear
Color Stop - A color stop in a linear gradient.
- List
- A list element
- List
Offset - An offset into the list’s items, in terms of the item index and the number of pixels off the top left of the item.
- List
Prepaint State - Frame state used by the List element after layout.
- List
Scroll Event - A scroll event that has been converted to be in terms of the list’s items.
- List
State - The list state that views must hold on behalf of the list element.
- Long
Press Event - A phased long-press gesture recognized from a touch.
- Menu
- A menu of the application, either a main menu or a submenu
- Metal
Device Lease - vue-native fork: the Metal device and a command queue the renderer draws
with (
id<MTLDevice>,id<MTLCommandQueue>), retained bykeep_alive.generationchanges when a renderer comes up on another device. - Missing
Glyph - A grapheme cluster that could not be represented by any available font.
- Modifiers
- The state of the modifier keys at some point in time
- Modifiers
Changed Event - The modifiers changed event equivalent for the platform.
- Monochrome
Sprite - Mouse
Click Event - A click event, generated when a mouse button is pressed and released.
- Mouse
Down Event - A mouse down event from the platform
- Mouse
Exit Event - A mouse exit event from the platform, generated when the mouse leaves the window.
- Mouse
Move Event - A mouse move event from the platform.
- Mouse
Pressure Event - A mouse pressure event from the platform. Generated when a force-sensitive trackpad is pressed hard. Currently only implemented for macOS trackpads.
- Mouse
UpEvent - A mouse up event from the platform
- NoAction
- Action with special handling which unbinds the keybinding this is associated with, if it is the highest precedence match.
- Noop
Text System - Null
Platform Gestures - A no-op
PlatformGesturesimplementation: no native recognizers and default tuning. Suitable for desktop platforms and tests. - Object
Position - CSS
object-position: per axis, a fraction of the free space (box minus content, which may be negative) plus an offset. The default is centred. - Ongoing
Scroll - Tracks the dominant axis across the events in a scroll gesture.
- OsMenu
- OS menus are menus that are recognized by the operating system This allows the operating system to provide specialized items for these menus
- Outline
- CSS
outline: a ring painted just outside the border box, taking no layout space. SeeStyle::vn_outline. - Owned
Menu - A menu of the application, either a main menu or a submenu
- Owned
OsMenu - OS menus are menus that are recognized by the operating system This allows the operating system to provide specialized items for these menus
- Padded
Bool32 - A boolean stored as a
u32so that GPU-facing structs contain no compiler-inserted padding bytes, which would be undefined behavior to reinterpret as&[u8]when writing instance buffers. Guaranteed to be0or1by construction; shaders read it as au32/uint. - Paint
Quad - A rectangle to be rendered in the window at the given position and size.
Passed as an argument
Window::paint_quad. - Paint
Surface - Painted
Path - Parsed
Svg - A parsed SVG document that can be rasterized at any scale.
- Path
- A filled path, ready to paint. Build one with
PathBuilder. - Path
Builder - A
Pathbuilder. - Path
Curve - Path
Paint - Path
Prompt Options - The options that can be configured for a file dialog prompt
- Path
Tile - Pending
Input Status - Pending input for a potential multi-stroke key binding.
- Pending
Input Timeout Status - The timeout state for pending input.
- Percentage
- A type representing a percentage value.
- Pinch
Event - A pinch gesture event from the platform, generated when the user performs a pinch-to-zoom gesture (typically on a trackpad).
- Pixels
- Represents a length in pixels, the base unit of measurement in the UI framework.
- Platform
Frame Signal - Preserves the first platform frame request time across coalesced notifications.
- Platform
Info - The host operating system and the kind of application delivering the UI.
- Platform
Input Handler - Point
- Describes a location in a 2D cartesian space.
- Point
Refinement - A refinable version of [
#ident], see that documentation for details. - Polychrome
Sprite - Prompt
Handle - A handle to a prompt that can be used to interact with it.
- Prompt
Response - The event emitted when a prompt’s option is selected. The usize is the index of the selected option, from the actions passed to the prompt.
- Quad
- Keep the field order in sync with
struct Quadingpui_windows/src/shaders.hlsl(85 words / 340 bytes) — the DirectX renderer uploads this straight into aStructuredBufferandStructureByteStrideissize_of::<Quad>(), so the Rust layout IS the shader layout. - Radians
- Represents an angle in Radians
- Rems
- Represents a length in rems, a unit based on the font-size of the window, which can be assigned with
Window::set_rem_size. - Render
Glyph Params - Parameters for rendering a glyph, used as cache keys for raster bounds.
- Render
Image - A cached and processed image, in BGRA format
- Render
Image Params - Render
SvgParams - Renderable
Prompt Handle - A prompt handle capable of being rendered in a window.
- Request
Frame Options - Reservation
- Returned by Context::reserve_entity to later be passed to Context::insert_entity. Allows you to obtain the EntityId for a entity before it is created.
- Retain
AllImage Cache - An implementation of ImageCache, that uses an LRU caching strategy to unload images when the cache is full
- Retain
AllImage Cache Provider - A provider struct for creating a retain-all image cache inline
- Rgba
- An RGBA color
- Runnable
Meta - Metadata attached to runnables for debugging and profiling.
- Scaled
Pixels - Represents scaled pixels that take into account the device’s scale factor.
- Scene
- Scheduler
Local Executor - A
!Sendexecutor pinned to a single session. Tasks spawned on it run in order on whichever thread drains the dispatch destination supplied at construction time — typically the main thread for the default session, or a dedicated OS thread for sessions created byspawn_dedicated_thread. - Scope
- Scope manages a set of tasks that are enqueued and waited on together. See
BackgroundExecutor::scoped. - Screen
Capture Frame - A frame of video captured from a screen.
- Scroll
Anchor - Represents an element that can be scrolled to in its parent element. Contrary to ScrollHandle::scroll_to_active_item, an anchored element does not have to be an immediate child of the parent.
- Scroll
Event - One step of scrolling from a mouse wheel, trackpad, or touch pan.
- Scroll
Handle - A handle to the scrollable aspects of an element. Used for accessing scroll state, like the current scroll offset, and for mutating the scroll state, like scrolling to a specific child.
- Send
Foreground Executor - A thread-safe handle for spawning
Sendfutures on the main thread. - Shadow
- Shaped
Glyph - A single glyph, ready to paint.
- Shaped
Line - A line of text that has been shaped and decorated.
- Shaped
Line Cursor - Incrementally splits a
ShapedLineat increasing UTF-8 byte boundaries. - Shaped
Run - A run of text that has been shaped .
- 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
SharedStringcontaining a URI. - Size
- A structure representing a two-dimensional size with width and height in a given unit.
- Size
Refinement - A refinable version of [
#ident], see that documentation for details. - Source
Metadata - Metadata for a given ScreenCaptureSource
- Spring
Animation - A stateful spring animation targeting a value or projected path.
- Spring
Animation Element - A GPUI element driven by a stateful spring.
- Spring
Config - The physical parameters of a damped harmonic oscillator.
- Spring
State - The instantaneous position and velocity of a spring.
- Sprite
Animation Id - Refers to an animation of the scene a sprite is inserted into.
- Stateful
- A wrapper around an element that can store state, produced after assigning an ElementId.
- Strikethrough
Style - The properties that can be applied to a strikethrough.
- Strikethrough
Style Refinement - A refinable version of [
#ident], see that documentation for details. - Stroke
Options - How to stroke a path.
- Style
- The CSS styling that can be applied to an element via the
Styledtrait - Style
Refinement - A refinable version of [
#ident], see that documentation for details. - Styled
Text - Renders text with runs of different styles.
- Subpixel
Sprite - Subscription
- A handle to a subscription created by GPUI. When dropped, the subscription is cancelled and the callback will no longer be invoked.
- Surface
- A surface element.
- Svg
- An SVG element.
- SvgRenderer
- A struct holding everything necessary to render SVGs.
- SvgText
Font - The font of an SVG
<text>element, as the values of its presentation attributes. - System
Notification - A notification posted to the operating system’s notification center, rather than rendered as in-app UI.
- System
Notification Action - A button offered on a
SystemNotification. - System
Notification Response - The user’s activation of a
SystemNotification. - System
Window TabController - A controller for managing window tabs.
- Task
- Task is a primitive that allows work to happen in the background.
- Text
- An
Elementthat renders text. - Text
Input Configuration - Platform text-assistance preferences for the focused text region.
- Text
Layout - The Layout for TextElement. This can be used to map indices to pixels and vice versa.
- TextRun
- A styled run of text, for use in
crate::TextLayout. - Text
Shadow - One CSS
text-shadow, painted beneath the glyphs it is attached to. - Text
Style - The properties that can be used to style text in GPUI
- Text
Style Refinement - A refinable version of [
#ident], see that documentation for details. - Text
System - The GPUI text rendering sub system.
- Text
Wrap - vue-native fork: the rules a text breaks its lines under, from its style
(
TextStyle::wrap). Part of the line layout cache’s key. - TileId
- Tiling
- A type to describe which sides of the window are currently tiled in some way
- Timed
Transformation - A
Transformationthat repeatedly moves from one pose to another over a period, forSvg::with_timed_transformation. - Timeout
- Error returned by with_timeout when the timeout duration elapsed before the future resolved
- Titlebar
Options - The options that can be configured for a window’s titlebar
- Tooltip
Id - An identifier for a tooltip.
- Touch
Click Event - A click event that was generated by a recognized tap gesture on a touch screen.
- Touch
Drag Event - A direct touch drag claimed by an element before touch input becomes a tap, long press, or scrolling gesture.
- Touch
Event - A raw touch event from the platform.
- TouchId
- Identifies one touch (finger or stylus contact) for its lifetime, from
TouchPhase::StartedthroughTouchPhase::EndedorTouchPhase::Cancelled. - Transform
Spec - CSS
transform, as the cascade computed it, carried oncrate::Styleand turned into aTransformationMatrixat paint time bycrate::Style::paint. - Transformation
- A transformation to apply to an SVG element.
- Transformation
Matrix - A data type representing a 2 dimensional transformation that can be applied to an element.
- 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
- Action with special handling which unbinds later bindings for the same keystrokes when they dispatch the named action, regardless of that action’s context.
- Underline
- Underline
Style - The properties that can be applied to an underline.
- Underline
Style Refinement - A refinable version of [
#ident], see that documentation for details. - Uniform
List - A list element for efficiently laying out and displaying a list of uniform-height elements.
- Uniform
List Frame State - Frame state used by the UniformList.
- Uniform
List Scroll Handle - A handle for controlling the scroll position of a uniform list. This should be stored in your view and passed to the uniform_list on each frame.
- Uniform
List Scroll State - VnCalc
Size - vue-native fork:
calc-size(<basis>, size * scale + offset). The basis is laid out first andsizeis the length it took; only a linear function ofsizeis representable. - VnCapture
- vue-native fork: one capture of a finished scene. The renderer draws
groupinto a cleared target and keeps theinkrectangle of it as the snapshotinfo.id. - VnCapture
Info - vue-native fork: what a captured group knows of the element it holds.
- VnClip
Geometry - vue-native fork: a clip shape flattened into line segments, in window device pixels. What the renderer evaluates per pixel and the hit test asks.
- VnClip
Mask - vue-native fork: a
crate::VnMaskwith the border box and transform it paints at, so a deferred descendant can paint it again around its own layer. - VnClip
Node - vue-native fork: a clip shape in force, and the ones around it — what a hitbox, a deferred draw and the window’s clip stack carry, so a press outside any of them misses (CSS Masking 1 §5).
- VnClip
Outline - vue-native fork: a
polygon()orpath()laid out against its reference box, in the element’s own frame and logical pixels (crate::Style::vn_clip_outline). - VnColor
Matrix - An SVG feColorMatrix over unpremultiplied RGBA components.
- VnCorner
Radius - vue-native fork: one CSS
border-*-radiuscorner, as its two radii. Each is a length, a percentage of the box (Fraction), or a linearcalc()with one. SeeStyle::vn_corner_radii. - VnEffect
Draw - vue-native fork: one
--shadingquad of aVnEffectLayer, with the key of its history (0 for none). - VnEffect
Histories - One renderer’s histories;
Tis its texture handle. - VnEffect
Layer - vue-native fork: a
VnLayercomposited by itsScene::vn_effect_drawsin order, each reading the layer’s group (none when it is 0) as content. - VnEffect
Paint - vue-native fork: what
Scene::vn_push_effectopens: the quads that composite what is painted until the matchingScene::vn_pop_isolation. - VnGroup
Ranges - vue-native fork: one group’s primitives in each of the scene’s vectors.
- VnHistory
- One history in this frame.
- VnIsolation
- vue-native fork: an isolated layer as it is opened: the clip it composites through, in window device pixels, and the content mask around it.
- VnLayer
- vue-native fork: the composite of one isolated layer. The renderer draws
group
groupinto an offscreen target the size of the window, then composites it over its parent’s, multiplied by the coverage of the segmentssegment_start..segment_start + segment_countofScene::vn_clip_segmentsunderfill_rule(bit 0: 0 nonzero, 1 evenodd), and by the content mask. Bits 1–2 offill_rulename a mask (Scene::vn_begin_mask): 1 multiplies by the alpha, 2 by the luminance of groupgroup + 1, which the renderer draws into a target of its own. - VnMask
- CSS
mask: the element’s painting, subtree included, is multiplied by the alpha (or luminance) of whatpaintdraws over its border box. - VnRetained
Layout Stats - Work retained layout performed during an opt-in profiling capture.
- VnSnapshot
Paint - vue-native fork: a snapshot drawn into a box (
Scene::vn_insert_snapshot). - VnText
Background - One text background and its positioning space. GPU layout matches HLSL.
- VnText
Fill - A CSS background stack clipped to the element’s descendant text.
- VnText
Paint - A text background resolved against its element, in logical CSS pixels. Carried in TextStyle so deferred drawing and paint-cache keys retain it.
- Weak
Entity - A weak reference to a entity of the given type.
- Weak
Focus Handle - A weak reference to a focus handle.
- Window
- Holds the state for a specific window.
- Window
Button Layout - Describes which
WindowButtons appear on each side of the titlebar. - Window
Controls - What window controls this platform supports
- Window
Handle - A handle to a window with a specific root view type. Note that this does not keep the window alive on its own.
- Window
Id - A unique identifier for a window.
- Window
Insets - Regions of a window that are obscured or reserved by the system.
- Window
Options - The variables that can be configured when creating a new window
- Window
Params - The variables that can be configured when creating a new window
- Window
Text System - The GPUI text layout subsystem.
- Windowing
Modes - The windowing modes a platform may start in or switch to.
- Wrap
Boundary - A boundary at which a line was wrapped
- Wrapped
Line - A line of text that has been shaped, decorated, and wrapped by the text layout system.
- Wrapped
Line Layout - A line of text that has been wrapped to fit a given width
Enums§
- Absolute
Length - Represents an absolute length in pixels or rems.
- Accessible
Action - An action to be taken on an accessibility node.
- Action
Build Error - Error type for
Keystroke::parse. This is used instead ofanyhow::Errorso that Zed can use markdown to display it. - Activation
Policy - Controls whether the application participates in the system’s foreground UI.
- Align
Content - Sets the distribution of space between and around content items For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis
- Align
Items - Used to control how child nodes are aligned. For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis
- Anchor
- Identifies a reference point on a 2D box, used to anchor positioned elements.
- Anchored
FitMode - Which algorithm to use when fitting the anchored element to be inside the window.
- Anchored
Position Mode - Which algorithm to use when positioning the anchored element.
- AppEffect
Source - One generated shader of an
AppEffect. - AppLifecycle
Phase - The application’s lifecycle phase, as owned and reported by a mobile OS.
- ArcCow
- Asset
Logger - An asset Loader which logs the
Errvariant of aResultduring loading - Atlas
Key - Atlas
Texture Kind - Autocapitalize
- Automatic capitalization applied by software keyboards.
- Available
Space - The space available for an element to be laid out in
- Axis
- Axis in a 2D cartesian space.
- Back
Gesture Phase - The phase of a
BackGestureEvent. - Border
Style - The style of a border.
- Click
Event - A click event, generated when a mouse button or keyboard button is pressed and released, or when a tap gesture is recognized on a touch screen.
- Clipboard
Entry - Either a ClipboardString or a ClipboardImage
- Clipboard
Read Error - An error produced by
Platform::read_from_clipboard_async. - 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 style of the cursor (pointer)
- Decorations
- A type to describe how this window is currently configured
- Definite
Length - A non-auto length that can be defined in pixels, rems, or percent of parent.
- Dispatch
Phase - Represents the two different phases when dispatching events.
- Display
- Sets the layout used for the children of this node
- Display
Event - A change to the connected displays, reported through
App::observe_displays. - Easing
- How a value’s rate of change varies over one pass of a
TimedTransformation. - Element
Id - An identifier for an
Element. - External
Drag Payload - Data offered to the platform when an internal drag leaves the window and is promoted to a native drag session.
- Fallback
Font Class - The spacing behavior required of a fallback font.
- File
Drop Event - A file drop event from the platform, generated when files are dragged and dropped onto 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.
- Flex
Direction - The direction of the flexbox layout main axis.
- Flex
Wrap - Controls whether flex items are forced onto one line or can wrap onto multiple lines.
- Follow
Mode - Controls whether the list automatically follows new content at the end.
- Font
Style - Allows italic or oblique faces to be selected.
- Frame
Outcome - vue-native fork: how a window’s frame request went, for an embedder’s frame meter.
- Frame
Request Source - The source of a platform frame request’s timestamp.
- Grid
Auto Flow - CSS
grid-auto-flow: which axis the auto-placement algorithm fills, and whether it backfills holes. - Grid
Placement - The placement of an item within a grid layout’s column or row.
- Grid
Template MinSize - The minimum size of a column or row in a grid layout
- Grid
Track Size - One end of a CSS grid track’s sizing function — the
aor thebinminmax(a, b). - Hitbox
Behavior - How the hitbox affects mouse behavior.
- Hover
Listener Mode - Controls how
StatefulInteractiveElement::on_hoverresponds to key presses while the mouse is stationary. - Hyphens
- vue-native fork: CSS
hyphens(CSS Text 3 §6.1). There is no hyphenation dictionary, soautois the caller’s to map toManual. - Image
Asset Loader - An image loader for the GPUI asset system
- Image
Cache Error - An error that can occur when interacting with the image cache.
- Image
Format - One of the editor’s supported image formats (e.g. PNG, JPEG) - used when dealing with images in the clipboard
- Image
Source - A source of image content.
- Indent
Adjustment - Controls how soft-wrapped continuation lines are indented.
- Input
Preference - Whether a keystroke should prefer character input or key bindings.
- KeyBinding
Context Predicate - A datastructure for resolving whether an action should be dispatched Representing a small language for describing which contexts correspond to which actions.
- Keyboard
Button - An enum representing the keyboard button that was pressed for a click event.
- Length
- A length that can be defined in pixels, rems, percent of parent, or auto.
- LineCap
- Line cap as defined by the SVG specification.
- Line
Fragment - A fragment of a line that can be wrapped.
- Line
Join - Line join as defined by the SVG specification.
- List
Alignment - Whether the list is scrolling from top to bottom or bottom to top.
- List
Horizontal Sizing Behavior - The horizontal sizing behavior to apply during layout.
- List
Measuring Behavior - The measuring behavior to apply during layout.
- List
Sizing Behavior - The sizing behavior to apply during layout.
- Menu
Item - The different kinds of items that can be in a menu
- Mouse
Button - An enum representing the mouse button that was pressed.
- Navigation
Direction - A navigation direction, such as back or forward.
- Object
Fit - How to fit the image into the bounds of the element.
- Operating
System - The host operating system, including when the application runs in a browser.
- Orientation
- OsAction
- OS actions are actions that are recognized by the operating system This allows the operating system to provide specialized behavior for these actions
- Overflow
- How children overflowing their container should affect layout
- Overflow
Wrap - vue-native fork: CSS
overflow-wrap(CSS Text 3 §5.5). May a line break inside a word that does not fit on a line of its own? - Owned
Menu Item - The different kinds of items that can be in a menu
- Path
Style - Style of the PathBuilder
- Platform
Input - An enum corresponding to all kinds of platform input events.
- Platform
Target - The kind of application delivering the UI, independently of its host OS.
- Pointer
Lock Error - vue-native fork: why
PlatformWindow::lock_pointerdid not lock. - Position
- The positioning strategy for this item.
- Power
Mode - The operating system’s preference for energy use versus performance.
- Pressure
Stage - The stage of a pressure click event.
- Primitive
- Primitive
Batch - Priority
- Task priority for background tasks.
- Prompt
Button - Prompt Button
- Prompt
Level - What kind of prompt styling to show
- Quit
Mode - Defines when the application should automatically quit.
- Resize
Edge - Which part of the window to resize
- Resource
- An enum representing
- Role
- The type of an accessibility node.
- Scroll
Delta - The scroll delta for a
ScrollEvent. - Scroll
Physics - How free scrolling decelerates after a fling.
- Scroll
Source - The kind of input that produced a
ScrollEvent. - Scroll
Strategy - Where to place the element scrolled to.
- Spring
Playback - Controls how a spring advances and resolves its presentation value.
- Surface
Source - A source of a surface’s content.
- SvgSize
- The size in which to rasterize the SVG.
- System
Menu Type - The type of system menu
- Text
Align - How to align text within the element
- 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 to truncate text that overflows the width of the element
- Text
Rendering Mode - The text rendering mode to use for drawing glyphs.
- Thermal
State - Thermal state of the system
- Tile
Source - vue-native fork: where
crate::Window::write_image_tiletakes a frame’s pixels from. - Tile
Write - vue-native fork: what
crate::Window::write_image_tiledid with a frame. - Toggled
- Touch
Phase - The phase of a touch motion event. Based on the winit enum of the same name.
- Transform
Length - One axis of a
TransformSpec’stranslate(). - Truncate
From - Determines whether to truncate text from the start or end.
- Visibility
- The value of the visibility property, similar to the CSS property
visibility - VnBatch
- vue-native fork: what the renderer iterates for one group: runs of
primitives as before, and runs of
VnLayercomposites. - VnClip
Box - vue-native fork: the box a
clip-pathis laid against (CSS Masking 1 §5.1,<geometry-box>).fill-boxis the content box andstroke-boxandview-boxthe border box, as for any element with a CSS box. - VnClip
Path - vue-native fork: CSS
clip-path(CSS Masking 1 §5). The shapes a rounded content mask can carry are one (Style::vn_clip_mask);polygon(),path()and an ellipse that is no circle are an isolated layer composited through the shape (Style::vn_clip_outline,crate::VnClipGeometry). - VnFill
Rule - vue-native fork: the
<fill-rule>of apolygon()orpath(). - VnHit
Kind - vue-native fork: which mouse event a
VnHitRefineris refining. - VnPath
Verb - vue-native fork: one verb of a
path(), in absolute pixels from the reference box’s top left corner. A parser resolves the relative commands, theH/Vlines, theS/Treflections and the arcs (VnPathVerb::push_arc) into these five. - VnPointer
Lock - vue-native fork: how
Window::vn_lock_pointerholds the pointer. - VnShape
Radius - vue-native fork: a
<shape-radius>ofcircle()orellipse(). - VnSize
Basis - vue-native fork: the intrinsic sizing keyword a
VnCalcSizeis measured from. - White
Space - How to handle whitespace in text
- Window
Appearance - The appearance of the window, as defined by the operating system.
- Window
Background Appearance - The appearance of the background of the window itself, when there is no content or the content is transparent.
- Window
Bounds - Represents the status of how a window should be opened.
- Window
Button - A window control button type used in
WindowButtonLayout. - Window
Control Area - A type of window control area that corresponds to the platform window.
- Window
Decorations - A type to describe the appearance of a window
- Window
Kind - The kind of window to create
- Window
Visibility - Whether the platform is presenting a window’s frames.
- Windowing
Request - A display mode for
App::request_windowingto switch to. - Word
Break - vue-native fork: CSS
word-break(CSS Text 3 §5.2).
Constants§
- APP_
EFFECTS_ DIR_ ENV - Names a directory of compiled app effects (
effects.jsonand the shaders beside it). A developer override: it wins over what the host installs withset_app_effects. - APP_
EFFECTS_ SCHEMA - The
effects.jsonlayout this build understands. - DEFAULT_
ADDITIONAL_ WINDOW_ SIZE - A 6:5 aspect ratio minimum window size to be used for functional, additional-to-main-Zed windows, like the settings and rules library windows.
- DEFAULT_
WINDOW_ SIZE - Default window size used when no explicit size is provided.
- EFFECT_
FLAG_ HISTORY - Bit 2 of
EffectQuad::flags: the effect keeps its own state from frame to frame ([SkHistory]), at t8. A renderer clears it on a quad it has no history for, which then reads zeros. - EFFECT_
FLAG_ HISTORY_ PASS - Bit 3 of
EffectQuad::flags, set by the renderer only: this draw writes the next history state instead of the element’s pixels. - EFFECT_
FLAG_ NEEDS_ BACKDROP - Bit 0 of
EffectQuad::flags: this effect samples the backdrop, so the renderer must snapshot the render target, run the blur pyramid, bind t0/t2 and draw with blending disabled. - EFFECT_
FLAG_ NEEDS_ CONTENT - Bit 1 of
EffectQuad::flags: the effect reads its element’s painted subtree ([SkContent]), so the element paints into an isolated group the effect samples at t7 and composites in its place. - EFFECT_
FLAG_ TEXTURE_ SET_ SHIFT - Bits of
EffectQuad::flagsabove this hold the quad’s texture set, plus one; zero samples no image. - EFFECT_
PARAM_ SLOTS - How many floats an effect’s parameter block holds (
EffectSpec::params,EffectQuad::params). - EFFECT_
TEXTURE_ SLOTS SkTextureparameters an effect may declare. They bind at HLSL t3..t6, WGSL@group(2) @binding(3..6)and Metaltexture(3..6), with the repeating sampler at s2,@binding(9)andsampler(2).- GRADIENT_
STOPS - How many colour stops a gradient
Backgroundcarries inline. - KEYSTROKE_
PARSE_ EXPECTED_ MESSAGE - Sentence explaining what keystroke parser expects, starting with “Expected …”
- LOADING_
DELAY - The delay before showing the loading state.
- MAX_
BACKDROP_ BLUR_ KERNEL_ LEVELS - Maximum number of GPU blur downsample/upsample levels a backdrop blur rect may request.
- MAX_
BUTTONS_ PER_ SIDE - Maximum number of
WindowButtons per side in the titlebar. - MAX_
GLYPH_ SHADOW_ SIGMA - The largest shadow blur, as a standard deviation in device pixels; a larger one is drawn at it.
- SHUTDOWN_
TIMEOUT - The duration for which native applications wait for futures returned from Context::on_app_quit before fully quitting.
- SMOOTH_
SVG_ SCALE_ FACTOR - When rendering SVGs, we render them at twice the size to get a higher-quality result.
- SUBPIXEL_
VARIANTS_ X - Number of subpixel glyph variants along the X axis.
- SUBPIXEL_
VARIANTS_ Y - Number of subpixel glyph variants along the Y axis.
- VN_
CLIP_ TOLERANCE - The largest distance, in device pixels, between a curve and the line segments that stand for it. A quarter pixel is below what the shader’s one-pixel antialiased edge shows.
- VN_
HISTORY_ BUDGET_ BYTES - What the histories of one window may hold together, both textures counted.
- VN_
HISTORY_ MAX_ SIDE - A quad longer than this on a side, in device pixels, gets no history.
- VN_
HISTORY_ MIN_ STEP_ SECONDS - The shortest time between two steps of one history, so a simulation runs at about the same speed on a 60 Hz and a 144 Hz display.
- VN_
HISTORY_ TEXEL_ BYTES - Bytes per history texel: RGBA, each a 16-bit float.
- VN_
TAG_ PASSIVE - vue-native fork: the bit an embedder ORs into a hitbox tag
(
Window::set_hitbox_tag) for a box that belongs to the node but is not where the node is — a scroll container’s wheel viewport, inserted after the content it covers.Window::vn_tags_atleaves such boxes out;Window::vn_restrict_mouse_hitjudges them by the node.
Traits§
- Action
- Actions are used to implement keyboard-driven UI. When you declare an action, you can bind keys to the action in the keymap and listeners for that action in the element tree.
- Along
- A trait for accessing the given unit along a certain axis.
- Animation
Ext - An extension trait for adding the animation wrapper to both Elements and Components
- AppContext
- The context trait, allows the different contexts in GPUI to be used interchangeably for certain operations.
- AsKeystroke
- This is a helper trait so that we can simplify the implementation of some functions
- Asset
- A trait for asynchronous asset loading.
- Asset
Source - A source of assets for this app to use.
- Borrow
AppContext - A helper trait for auto-implementing certain methods on contexts that can be used interchangeably.
- Element
- Implemented by types that participate in laying out and painting the contents of a window. Elements form a tree and are laid out according to web-based layout rules, as implemented by Taffy. You can create custom elements by implementing this trait, see the module-level documentation for more details.
- Entity
Input Handler - Implement this trait to allow views to handle textual input when implementing an editor, field, etc.
- Event
Emitter - A trait for tying together the types of a GPUI entity and the events it can emit.
- Focusable
- Focusable allows users of your view to easily focus it (using window.focus_view(cx, view))
- Future
Ext - Extensions for Future types that provide additional combinators and utilities.
- Gesture
Event - A gesture event from the platform.
- Global
- A marker trait for types that can be stored in GPUI’s global state.
- Half
- Provides a trait for types that can calculate half of their value.
- Image
Cache - An object that can handle the caching and unloading of images. Implementations of this trait should ensure that images are removed from all windows when they are no longer needed.
- Image
Cache Provider - An object that can create an ImageCache during the render phase. See the ImageCache trait for more information.
- Input
Event - An event from a platform input source.
- Input
Handler - GPUI’s interface for native text input, IME composition, and selection. Platform backends translate their native text protocols into these operations.
- Interactive
Element - A trait for elements that want to use the standard GPUI event handlers that don’t require any state.
- Interpolate
- A value that supports linear interpolation and extrapolation.
- Into
Element - Implemented by any type that can be converted into an element.
- IsEmpty
- IsZero
- A trait for checking if a value is zero.
- KeyEvent
- A key event from the platform.
- Managed
View - ManagedView is a view (like a Modal, Popover, Menu, etc.) where the lifecycle of the view is handled by another view.
- Missing
Glyph Sink - Accepts missing glyphs detected by a platform text system.
- Mouse
Event - A mouse event from the platform.
- Parent
Element - This is a helper trait to provide a uniform interface for constructing elements that can accept any number of any kind of child elements
- Platform
- Platform
Atlas - Platform
Display - A handle to a platform’s display, e.g. a monitor or laptop screen.
- Platform
Gestures - Platform gesture recognition services.
- Platform
Keyboard Layout - A trait for platform-specific keyboard layouts
- Platform
Keyboard Mapper - A trait for platform-specific keyboard mappings
- Platform
Text System - Platform
Window - Prompt
- A prompt that can be rendered in the window.
- Read
Global - A trait for reading a global value from the context.
- Refineable
- A trait for types that can be refined with partial updates.
- Render
- An object that can be drawn to the screen. This is the trait that distinguishes “views” from
other entities. Views are
Entity’s whichimpl Renderand drawn to the screen. - Render
Once - You can derive
IntoElementon any type that implements this trait. It is used to construct reusablecomponentsout of plain data. Think of components as a recipe for a certain pattern of elements. RenderOnce allows you to invoke this pattern, without breaking the fluent builder pattern of the element APIs. - Screen
Capture Source - A source of on-screen video content that can be captured.
- Screen
Capture Stream - A video stream captured from a screen.
- Spring
Target - A value that can be targeted by a one-dimensional spring.
- Stateful
Interactive Element - A trait for elements that want to use the standard GPUI interactivity features that require state.
- Styled
- A trait for elements that can be styled. Use this to opt-in to a utility CSS-like styling API.
- Styled
Image - Style an image element.
- TaskExt
- Extension trait for
Task<Result<T, E>>that addsdetach_and_log_errwith an&Appcontext. - Uniform
List Decoration - A decoration for a
UniformList. This can be used for various things, such as rendering indent guides, or other visual effects. - Update
Global - A trait for updating a global value in the context.
- View
- A renderable that participates in GPUI’s reactive graph — the unifying model
behind
RenderandRenderOnce. - Visual
Context - This trait is used for the different visual contexts in GPUI that require a window to be present.
Functions§
- anchored
- anchored gives you an element that will avoid overflowing the window bounds. Its children should have no margin to avoid measurement issues.
- app_
effects - The app’s effects: the last reload, else
$SK_EFFECTS_DIRwhen set, else what the host installed, else none. - app_
effects_ generation - Moves on every
reload_app_effects; a renderer compares it once per frame. - auto
- Returns a
Lengthrepresenting an automatic length. - black
- Pure black in
Hsla - block_
on - Block the thread until the future is ready.
- blue
- The color blue in
Hsla - blur_
glyph_ coverage - vue-native fork: blurs single-channel coverage (or the alpha of 4-channel color glyphs) with a
Gaussian of standard deviation
sigmadevice pixels, grown by its reach on every side. - bounce
- Apply the given easing function, first in the forward direction and then in the reverse direction
- bounds
- Create a bounds with the given origin and size
- canvas
- Construct a canvas element with the given paint callback. Useful for adding short term custom drawing to a view.
- checkerboard
- Creates a checkerboard pattern background
- combine_
highlights - Combine and merge the highlights and ranges in the two iterators.
- conic_
gradient - A conic gradient.
from_angleis in degrees clockwise from twelve o’clock; the centre defaults to the middle of the box. - container_
query - Construct a container query element with the given render callback. The callback receives the size the element was assigned during layout and returns the contents to display within it.
- continues_
cluster - Is
ca character that belongs to the cluster before it, so that it is drawn with the same face as that character rather than chosen on its own? Combining marks, joiners and variation selectors: a browser keeps a grapheme in one font when it can. - deferred
- Builds a
Deferredelement, which delays the layout and paint of its child. - div
- Construct a new
Divelement - ease_
in_ out - The quadratic ease-in-out function, which starts and ends slowly but speeds up in the middle
- ease_
out_ quint - The Quint ease-out function, which starts quickly and decelerates to a stop
- effect_
clock_ seconds - Seconds since the effect clock’s origin — the clock
EffectQuad::timecarries. The origin isset_effect_clock_origin’s, or the first read. - fallback_
prompt_ renderer - Use this function in conjunction with App::set_prompt_builder to force GPUI to always use the fallback prompt renderer.
- fill
- Creates a filled quad with the given bounds and background color.
- font
- Get a
Fontfor a given name. - font_
name_ with_ fallbacks - Maps well-known virtual font names to their concrete equivalents.
- font_
name_ with_ fallbacks_ shared - Like
font_name_with_fallbacksbut accepts and returnsSharedStringreferences. - 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 - Compute gamma correction ratios for subpixel text rendering.
- green
- The color green in
Hsla - guess_
compositor - Return which compositor we’re guessing we’ll use. Does not attempt to connect to the given compositor.
- hash
- Use a quick, non-cryptographically secure hash function to get an identifier from data
- heartbeat
- A heartbeat: a strong beat, a weaker one, then a rest. Starts and ends at 0 and peaks at 1.
- hsla
- Construct an
Hslaobject from plain values - image_
cache - An image cache element, all its child img elements will use the cache specified by this element.
Note that this could as simple as passing an
Entity<T: ImageCache> - img
- Create a new image element.
- is_
no_ action - Returns whether or not this action represents a removed key binding.
- is_
unbind - Returns whether or not this action represents an unbind marker.
- line_
layout_ counters - vue-native fork:
(lookups, shapes, nanoseconds spent shaping)since the process started, over every window’s line layout cache. A lookup that is not a shape was answered from this frame’s or the previous frame’s cache. - linear
- The linear easing function, or delta itself
- linear_
color_ stop - Creates a new linear color stop.
- linear_
gradient - Creates a LinearGradient background color.
- linear_
gradient_ stops - A linear gradient with up to
GRADIENT_STOPSstops. Extra stops are dropped from the middle rather than the ends, so the ramp always starts and finishes on the colours the caller asked for. - list
- Construct a new list element
- observe_
frames - vue-native fork:
observerhears about every frame request that did work or was throttled. The first call wins. - opaque_
grey - Opaque grey in
Hsla, values will be clamped to the range [0, 1] - outline
- Creates a rectangle outline with the given bounds, border color, and a 1px border width
- pattern_
slash - Creates a hash pattern background
- percentage
- Generate a
Radianfrom a percentage of a full circle. - phi
- Returns the Golden Ratio, i.e.
~(1.0 + sqrt(5.0)) / 2.0. - point
- Constructs a new
Point<T>with the given x and y coordinates. - pulsating_
between - A custom easing function for pulsating alpha that slows down as it approaches 0.1
- px
- Constructs a
Pixelsvalue representing a length in pixels. - quad
- Creates a quad with the given parameters.
- quad_
depth - Maps a quad’s index in
Scene::quadsto depth, with greater values closer. - quad_
depth_ scale - The depth step between consecutive quads in a frame with
quad_countquads. - quadratic
- The quadratic easing function, delta * delta
- radial_
gradient - A radial gradient, centred on the box and reaching its farthest corner —
CSS’s defaults.
Background::at,Background::with_radiiandBackground::with_extentchange each of those. - radians
- Create a
Radianfrom a raw value - red
- The color red in
Hsla - 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
- Constructs a
DefiniteLengthrepresenting a relative fraction of a parent size. - reload_
app_ effects - Replaces the app’s effects in a running app (a dev rebuild). Every renderer rebuilds the app’s pipelines on its next frame, and the CSS registry renumbers on its next read.
- rems
- Constructs a
Remsvalue representing a length in rems. - renderer_
metal_ device - vue-native fork: the Metal device the newest renderer draws with, once a
window has made one;
Noneon other backends. - retain_
all - Constructs a retain-all image cache that uses the element state associated with the given ID.
- rgb
- Convert an RGB hex color code number to a color type
- rgba
- Convert an RGBA hex color code number to
Rgba - sampled_
easing - Adapts a spring starting at zero with no velocity to GPUI’s duration-based easing API.
- set_
app_ effects - Hands the renderers and the CSS registry the app’s effects (from its payload). Call it before
the first window; false when
APP_EFFECTS_DIR_ENVis set, which wins, or when the effects were already read. - set_
effect_ clock_ origin - Anchors the effect clock, so an embedder can make it share a zero with its
own (a JS
performance.now()). Returnsfalseonce the clock has been read. - set_
effect_ texture_ resolver - Installs the embedder’s resolver; without one every texture is missing.
- set_
image_ resampler - vue-native: installs the process’s
ImageResampler. The first one installed stays. - size
- Constructs a new
Size<T>with the provided width and height. - solid_
background - Creates a solid background color.
- split_
by_ face - Splits
textinto the pieces each face offacesdraws:(byte length, index into faces),Nonefor a piece no face covers. Adjacent characters with the same answer are one piece; acontinues_clustercharacter stays with the piece before it. - svg
- Create a new SVG element.
- swap_
rgba_ pa_ to_ bgra - Swap from RGBA with premultiplied alpha to BGRA
- transparent_
black - Transparent black in
Hsla - transparent_
white - Transparent white in
Hsla - underline_
y_ offset - Returns the vertical offset used to paint an underline within a line.
- uniform_
list - uniform_list provides lazy rendering for a set of items that are of uniform height. When rendered into a container with overflow-y: hidden and a fixed (or max) height, uniform_list will only render the visible subset of items.
- vn_
resolve_ corner_ radii - vue-native fork: a box’s painted corner radii, as CSS resolves them.
- vn_
take_ ellipse_ drawn_ as_ circle - vue-native fork: whether a corner was painted with a circle in place of the ellipse CSS asks for, since the last call. vn-tree reads it to advise once.
- white
- Pure white in
Hsla - yellow
- The color yellow in
Hsla
Type Aliases§
- Align
Self - Used to control how the specified nodes is aligned.
Overrides the parent Node’s
AlignItemsproperty. For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis - Draw
Order - Effect
Texture Resolver - Resolves
EffectTextureParam::source:Nonewhile the image loads or when it cannot, and the effect then reads its fallback. - Effect
Texture Set - One quad’s images, by binding.
- External
Drag Payload Source - Lazily resolves the payload handed to the platform when an internal drag is promoted to a native drag session.
- Family
Composer - The faces a composed family draws text of a weight and style with, in the order they are tried for a character: the first that covers it draws it. Empty when the family has no face for that text (yet).
- Image
Resampler - vue-native: a host’s smaller copy of an image that is about to be drawn well below its own size.
- ImgResource
Loader - A type alias to the resource loader that the
img()element uses. - Inspector
Renderer - Function set on
Appto render the inspector UI. - Justify
Content - Sets the distribution of space between and around content items For Flexbox it controls alignment in the main axis For Grid it controls alignment in the inline axis
- Justify
Items - Used to control how child nodes are aligned. Does not apply to Flexbox, and will be ignored if specified on a flex container For Grid it controls alignment in the inline axis
- Justify
Self - Used to control how the specified nodes is aligned.
Overrides the parent Node’s
JustifyItemsproperty. Does not apply to Flexbox, and will be ignored if specified on a flex child For Grid it controls alignment in the inline axis - Result
Result<T, Error>- Runnable
Variant - Type alias for runnables with metadata. Previously an enum with a single variant, now simplified to a direct type alias.
- Scroll
Wheel Event Deprecated - The former name of
ScrollEvent. - Timer
Resolution Guard - Transform
- Alias for
euclid::default::Transform2D<f32> - VnHit
Refiner - vue-native fork: the embedder’s say over which hitboxes a mouse event is
for, run once per press, release and wheel before any listener sees it.
See
Window::set_vn_hit_refiner. - VnMask
Painter - Paints a mask’s layers into the border box it is given. With a tint (always
opaque), the layers paint in that colour as the element’s whole picture
(
VnMask::tint_leaf).
Attribute Macros§
- bench
#[gpui::bench]annotates a Criterion benchmark that runs with GPUI support.- property_
test - A variant of
#[gpui::test]that supports property-based testing. - test
#[gpui::test]can be used to annotate test functions that run with GPUI support.
Derive Macros§
- Action
Actionderive macro - see the trait documentation for details.- AppContext
- #[derive(AppContext)] is used to create a context out of anything that holds a
&mut AppNote that a#[app]attribute is required to identify the variable holding the &mut App. - Into
Element - #[derive(IntoElement)] generates an
IntoElementimpl for anyRenderOncetype, wrapping it in aViewElementso it can be used as a child. - Refineable
- Visual
Context - #[derive(VisualContext)] is used to create a visual context out of anything that holds a
&mut Windowand implementsAppContextNote that a#[app]and a#[window]attribute are required to identify the variables holding the &mut App, and &mut Window respectively.