Expand description
Blinc procedural macros
Provides derive macros for the Blinc UI framework.
§Platform-Agnostic Design
The generated code uses traits from blinc_core and blinc_animation
rather than concrete types, enabling components to work across different
platforms without depending on blinc_app.
§Scope and Instance Awareness
The BlincComponent macro generates unique component keys that include
both scope information (module path + struct name) and support for
instance differentiation through key suffixes.
§Component Key Composition
Keys are composed of three parts:
- Scope key:
module_path!()::StructName- identifies the component type - Field key: Field name for struct fields - identifies the field
- Instance key: User-provided or auto-generated suffix - differentiates instances
§Usage Patterns
For single-instance components, use the field methods directly:
ⓘ
let scale = MyComponent::use_scale(ctx, 1.0, SpringConfig::snappy());For multiple instances (e.g., in loops), use the _for variants with an instance key:
ⓘ
for i in 0..10 {
let scale = MyComponent::use_scale_for(ctx, i, 1.0, SpringConfig::snappy());
}For automatic instance keys based on call site (via #[track_caller]):
ⓘ
// Each call site gets a unique key automatically
let scale1 = MyComponent::use_scale_auto(ctx, 1.0, SpringConfig::snappy());
let scale2 = MyComponent::use_scale_auto(ctx, 1.0, SpringConfig::snappy()); // Different key!Derive Macros§
- Blinc
Component - Derive macro that generates a unique compile-time key for a component and generates field accessors based on field attributes.