Skip to main content

Crate gpui_macros

Crate gpui_macros 

Source
Expand description

Procedural macros for GPUI.

gpui re-exports these macros, so use them as gpui::test, #[derive(gpui::Action)], and so on. Application crates do not need a direct dependency on this crate.

Derives:

  • Action: implements gpui::Action for a type that you can bind to keys.
  • IntoElement, Render: implement the traits that let a type enter the element tree.
  • Styled, ParentElement, InteractiveElement, StatefulInteractiveElement: implement the builder traits for a type that holds a field for them.
  • AppContext, VisualContext: forward context methods from a wrapper around &mut App or &mut Window.

Attributes and function-like macros:

  • #[gpui::test], #[gpui::property_test] and #[gpui::bench] define tests and benchmarks that run with GPUI support.
  • register_action! registers a hand-written Action impl.
  • The *_style_methods! macros generate the builder methods of Styled.

Macros§

border_style_methods
Generates the border methods for Styled, such as border_1 and border_color.
box_shadow_style_methods
Generates the box-shadow and corner methods for Styled.
cursor_style_methods
Generates the cursor methods for Styled, such as cursor_pointer.
margin_style_methods
Generates the margin methods for Styled, such as m_4 and mx_auto.
overflow_style_methods
Generates the overflow methods for Styled, such as overflow_hidden.
padding_style_methods
Generates the padding methods for Styled, such as p_4 and px_2.
position_style_methods
Generates the position methods for Styled, such as relative and absolute.
register_action
Registers a type that implements gpui::Action by hand.
visibility_style_methods
Generates the visible and invisible methods for Styled.

Attribute Macros§

bench
Turns a function into a Criterion benchmark that runs with GPUI support.
derive_inspector_reflection
When added to a trait, #[derive_inspector_reflection] generates a module which provides enumeration and lookup by name of all methods that have the shape fn method(self) -> Self. This is used by the inspector so that it can use the builder methods in Styled and StyledExt.
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 under cargo test or cargo nextest.

Derive Macros§

Action
Derives gpui::Action for a type and registers it with the runtime.
AppContext
Derives gpui::AppContext for a struct that holds a &mut gpui::App.
InteractiveElement
Derives gpui::InteractiveElement for a struct with an #[interactivity] field.
IntoElement
Derives gpui::IntoElement for a type that implements gpui::RenderOnce.
ParentElement
Derives gpui::ParentElement for a struct with a #[children] field.
StatefulInteractiveElement
Derives gpui::StatefulInteractiveElement, which adds methods such as role.
Styled
Derives gpui::Styled for a struct with a #[style] field.
VisualContext
Derives gpui::VisualContext for a struct that holds a &mut gpui::App and a &mut gpui::Window.