Astrelis UI - Taffy-based UI system with WGPU rendering
This crate provides a flexible UI system built on Taffy layout engine:
- Declarative widget API
- Flexbox and Grid layouts via Taffy
- GPU-accelerated rendering
- Event handling system
- Composable widget tree
Quick Start
# use UiSystem;
# use ;
# let graphics_context = new_owned_sync.expect;
let mut ui = new;
ui.build;
// In render loop:
// ui.update(delta_time);
// ui.handle_events(&mut event_batch);
// ui.render(&mut render_pass, viewport_size);
API Conventions
This crate follows consistent method naming conventions:
Mutation Methods
set_*()- Full replacement that may trigger complete rebuild/re-layout- Example:
set_text()replaces text and triggers text shaping
- Example:
update_*()- Incremental update optimized with dirty flags- Example:
update_text()only marks TEXT_SHAPING dirty, skipping layout
- Example:
add_*()- Append to a collection- Example:
add_widget()appends to widget tree
- Example:
Accessor Methods
get_*()- ReturnsOption<&T>for possibly-missing values- Example:
get_widget(id)returnsOption<&Widget>
- Example:
*()(no prefix) - Returns&T, panics if unavailable (use when required)- Example:
widget(id)returns&Widgetor panics
- Example:
try_*()- Fallible operation returningResult- Example:
try_layout()returnsResult<(), LayoutError>
- Example:
has_*()- Boolean check for existence- Example:
has_widget(id)returnsbool
- Example:
Computation Methods
compute_*()- Expensive computation (results often cached)- Example:
compute_layout()runs Taffy layout solver
- Example:
calculate_*()- Mathematical calculation- Example:
calculate_bounds()computes widget bounds
- Example:
Builder Methods
with_*(value)- Builder method returningSelffor chaining- Example:
with_padding(20.0)sets padding and returns builder
- Example:
build()- Finalizes builder and consumes it- Example:
widget.build()adds widget to tree
- Example: