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: implementsgpui::Actionfor 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 Appor&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-writtenActionimpl.- The
*_style_methods!macros generate the builder methods ofStyled.
Macros§
- border_
style_ methods - Generates the border methods for
Styled, such asborder_1andborder_color. - box_
shadow_ style_ methods - Generates the box-shadow and corner methods for
Styled. - cursor_
style_ methods - Generates the cursor methods for
Styled, such ascursor_pointer. - margin_
style_ methods - Generates the margin methods for
Styled, such asm_4andmx_auto. - overflow_
style_ methods - Generates the overflow methods for
Styled, such asoverflow_hidden. - padding_
style_ methods - Generates the padding methods for
Styled, such asp_4andpx_2. - position_
style_ methods - Generates the position methods for
Styled, such asrelativeandabsolute. - register_
action - Registers a type that implements
gpui::Actionby hand. - visibility_
style_ methods - Generates the
visibleandinvisiblemethods forStyled.
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 shapefn method(self) -> Self. This is used by the inspector so that it can use the builder methods inStyledandStyledExt. - 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 undercargo testorcargo nextest.
Derive Macros§
- Action
- Derives
gpui::Actionfor a type and registers it with the runtime. - AppContext
- Derives
gpui::AppContextfor a struct that holds a&mut gpui::App. - Interactive
Element - Derives
gpui::InteractiveElementfor a struct with an#[interactivity]field. - Into
Element - Derives
gpui::IntoElementfor a type that implementsgpui::RenderOnce. - Parent
Element - Derives
gpui::ParentElementfor a struct with a#[children]field. - Stateful
Interactive Element - Derives
gpui::StatefulInteractiveElement, which adds methods such asrole. - Styled
- Derives
gpui::Styledfor a struct with a#[style]field. - Visual
Context - Derives
gpui::VisualContextfor a struct that holds a&mut gpui::Appand a&mut gpui::Window.