Skip to main content

Module prelude

Module prelude 

Source
Expand description

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.

Structs§

Context
The app context, with specialized behavior for the given entity.
Path
A line made up of a series of vertices and control points.
PathBuilder
A Path builder.

Traits§

BorrowAppContext
A helper trait for auto-implementing certain methods on contexts that can be used interchangeably.
BoundsExt
Extension methods on Bounds that need to resolve the application’s displays.
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.
FluentBuilder
A helper trait for building complex objects with imperative conditionals in a fluent style.
ImageExt
Operations on Image that integrate it with GPUI’s rendering and asset systems.
InteractiveElement
A trait for elements that want to use the standard GPUI event handlers that don’t require any state.
IntoElement
Implemented by any type that can be converted into an element.
LineLayoutExt
Extension methods for painting a bare LineLayout.
ParentElement
This is a helper trait to provide a uniform interface for constructing elements that can accept any number of any kind of child elements
PlatformInputHandlerExt
The PlatformInputHandler operations that need the owning window.
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 which impl Render and drawn to the screen.
RenderOnce
You can derive IntoElement on any type that implements this trait. It is used to construct reusable components out 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.
StatefulInteractiveElement
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.
StyledImage
Style an image element.
VisualContext
This trait is used for the different visual contexts in GPUI that require a window to be present.
WindowBoundsExt
Window-bounds helpers that require access to the application’s display state.
_
The context trait, allows the different contexts in GPUI to be used interchangeably for certain operations.
_
Extension trait for Task<Result<T, E>> that adds detach_and_log_err with an &App context.

Derive Macros§

IntoElement
#[derive(IntoElement)] generates an IntoElement impl for any RenderOnce type, wrapping it in a ViewElement so it can be used as a child.
Refineable
VisualContext
#[derive(VisualContext)] is used to create a visual context out of anything that holds a &mut Window and implements AppContext Note that a #[app] and a #[window] attribute are required to identify the variables holding the &mut App, and &mut Window respectively.
_
#[derive(AppContext)] is used to create a context out of anything that holds a &mut App Note that a #[app] attribute is required to identify the variable holding the &mut App.