ui_macros.rs

 1mod derive_register_component;
 2mod dynamic_spacing;
 3
 4use proc_macro::TokenStream;
 5
 6/// Generates the DynamicSpacing enum used for density-aware spacing in the UI.
 7#[proc_macro]
 8pub fn derive_dynamic_spacing(input: TokenStream) -> TokenStream {
 9    dynamic_spacing::derive_spacing(input)
10}
11
12/// Registers components that implement the `Component` trait.
13///
14/// This proc macro is used to automatically register structs that implement
15/// the `Component` trait with the [`component::ComponentRegistry`].
16///
17/// If the component trait is not implemented, it will generate a compile-time error.
18///
19/// # Example
20///
21/// ```
22/// use ui::Component;
23/// use ui_macros::RegisterComponent;
24///
25/// #[derive(RegisterComponent)]
26/// struct MyComponent;
27///
28/// impl Component for MyComponent {
29///     // Component implementation
30/// }
31/// ```
32///
33/// This example will add MyComponent to the ComponentRegistry.
34#[proc_macro_derive(RegisterComponent)]
35pub fn derive_register_component(input: TokenStream) -> TokenStream {
36    derive_register_component::derive_register_component(input)
37}