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.

Traits§

BorrowAppContext
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.
FluentBuilder
A helper trait for building complex objects with imperative conditionals in a fluent style.
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.
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
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.
_
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.