gpui: Make style macros more composable (#14007)
This PR begins the process of breaking up the `style_helpers!` macro into smaller macros that can be used to generate methods for a related subset of styles. The style method macros also now accept an optional `visibility` parameter to control the visibility of the generated methods. This allows for adding these methods to a struct instead of a just a trait. For example, to expose just the padding styles on a `Facepile` we can do this: ```rs impl Facepile { fn style(&mut self) -> &mut StyleRefinement { self.base.style() } gpui::padding_style_methods!({ visibility: pub }); } ``` Release Notes: - N/A
This commit is contained in:
parent
8203b6875b
commit
3cdd465226
4 changed files with 335 additions and 203 deletions
|
@ -27,13 +27,34 @@ pub fn derive_render(input: TokenStream) -> TokenStream {
|
|||
derive_render::derive_render(input)
|
||||
}
|
||||
|
||||
/// Used by gpui to generate the style helpers.
|
||||
/// Used by GPUI to generate the style helpers.
|
||||
#[proc_macro]
|
||||
#[doc(hidden)]
|
||||
pub fn style_helpers(input: TokenStream) -> TokenStream {
|
||||
style_helpers::style_helpers(input)
|
||||
}
|
||||
|
||||
/// Generates methods for margin styles.
|
||||
#[proc_macro]
|
||||
#[doc(hidden)]
|
||||
pub fn margin_style_methods(input: TokenStream) -> TokenStream {
|
||||
style_helpers::margin_style_methods(input)
|
||||
}
|
||||
|
||||
/// Generates methods for padding styles.
|
||||
#[proc_macro]
|
||||
#[doc(hidden)]
|
||||
pub fn padding_style_methods(input: TokenStream) -> TokenStream {
|
||||
style_helpers::padding_style_methods(input)
|
||||
}
|
||||
|
||||
/// Generates methods for position styles.
|
||||
#[proc_macro]
|
||||
#[doc(hidden)]
|
||||
pub fn position_style_methods(input: TokenStream) -> TokenStream {
|
||||
style_helpers::position_style_methods(input)
|
||||
}
|
||||
|
||||
/// #[gpui::test] can be used to annotate test functions that run with GPUI support.
|
||||
/// it supports both synchronous and asynchronous tests, and can provide you with
|
||||
/// as many `TestAppContext` instances as you need.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue