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§
- 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.
- Fluent
Builder - A helper trait for building complex objects with imperative conditionals in a fluent style.
- Interactive
Element - A trait for elements that want to use the standard GPUI event handlers that don’t require any state.
- Into
Element - Implemented by any type that can be converted into an element.
- 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
- 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. - 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.
- Visual
Context - 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 addsdetach_and_log_errwith an&Appcontext.
Derive Macros§
- 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. - _
- #[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.