Expand description
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
let mut ui = UiSystem::new(graphics_context);
ui.build(|root| {
root.container()
.width(800.0)
.height(600.0)
.padding(20.0)
.child(|container| {
container.text("Hello, World!")
.size(24.0)
.color(Color::WHITE)
.build();
container.button("Click Me").build();
container.container().build()
})
.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:
Re-exports§
pub use style::Overflow;pub use style::PointerEvents;pub use animation::AnimatableProperty;pub use animation::Animation;pub use animation::AnimationState;pub use animation::AnimationSystem;pub use animation::EasingFunction;pub use animation::WidgetAnimations;pub use animation::bounce;pub use animation::fade_in;pub use animation::fade_out;pub use animation::scale;pub use animation::slide_in_left;pub use animation::slide_in_top;pub use animation::translate_x;pub use animation::translate_y;pub use clip::ClipRect;pub use clip::PhysicalClipRect;pub use debug::DebugOverlay;pub use dirty::DirtyFlags;pub use dirty::DirtyRanges;pub use dirty::Versioned;pub use draw_list::DrawCommand;pub use draw_list::DrawList;pub use draw_list::ImageCommand;pub use draw_list::QuadCommand;pub use draw_list::RenderLayer;pub use draw_list::TextCommand;pub use glyph_atlas::GlyphBatch;pub use glyph_atlas::atlas_entry_uv_coords;pub use glyph_atlas::create_glyph_batches;pub use glyph_atlas::glyph_to_instance;pub use glyph_atlas::glyphs_to_instances;pub use gpu_types::ImageInstance;pub use gpu_types::QuadInstance;pub use gpu_types::QuadVertex;pub use gpu_types::TextInstance;pub use instance_buffer::InstanceBuffer;pub use length::Length;pub use length::LengthAuto;pub use length::LengthPercentage;pub use length::auto;pub use length::length;pub use length::percent;pub use length::vh;pub use length::vmax;pub use length::vmin;pub use length::vw;pub use constraint::CalcExpr;pub use constraint::Constraint;pub use constraint_builder::calc;pub use constraint_builder::clamp;pub use constraint_builder::max_of;pub use constraint_builder::max2;pub use constraint_builder::min_of;pub use constraint_builder::min2;pub use constraint_builder::px;pub use constraint_resolver::ConstraintResolver;pub use constraint_resolver::ResolveContext;pub use metrics::UiMetrics;pub use viewport_context::ViewportContext;pub use widget_id::WidgetId;pub use widget_id::WidgetIdRegistry;pub use widgets::HScrollbar;pub use widgets::ScrollbarOrientation;pub use widgets::ScrollbarTheme;pub use widgets::VScrollbar;pub use widgets::Image;pub use widgets::ImageFit;pub use widgets::ImageTexture;pub use widgets::ImageUV;pub use widgets::ScrollAxis;pub use widgets::ScrollContainer;pub use widgets::ScrollbarVisibility;pub use builder::ContainerNodeBuilder;pub use builder::ImageBuilder;pub use builder::IntoNodeBuilder;pub use builder::LeafNodeBuilder;pub use builder::UiBuilder;pub use builder::WidgetBuilder;pub use builder::DockSplitterNodeBuilder;pub use builder::DockTabsNodeBuilder;pub use event::UiEvent;pub use event::UiEventSystem;pub use focus::FocusDirection;pub use focus::FocusEvent;pub use focus::FocusManager;pub use focus::FocusPolicy;pub use focus::FocusScopeId;pub use layout::LayoutCache;pub use renderer::UiRenderer;pub use style::Style;pub use theme::ColorPalette;pub use theme::ColorRole;pub use theme::Shapes;pub use theme::Spacing;pub use theme::Theme;pub use theme::ThemeBuilder;pub use theme::Typography;pub use tree::NodeId;pub use tree::UiTree;pub use widgets::Widget;pub use culling::AABB;pub use culling::CullingStats;pub use culling::CullingTree;pub use inspector::EditableProperty;pub use inspector::InspectorConfig;pub use inspector::InspectorGraphs;pub use inspector::PropertyEditor;pub use inspector::SearchState;pub use inspector::TreeViewState;pub use inspector::UiInspector;pub use inspector::WidgetIdRegistryExt;pub use inspector::WidgetKind;pub use layout_engine::LayoutEngine;pub use layout_engine::LayoutMode;pub use layout_engine::LayoutRequest;pub use menu::ContextMenu;pub use menu::MenuBar;pub use menu::MenuItem;pub use menu::MenuStyle;pub use metrics_collector::FrameTimingMetrics;pub use metrics_collector::MemoryMetrics;pub use metrics_collector::MetricsCollector;pub use metrics_collector::MetricsConfig;pub use metrics_collector::PerformanceWarning;pub use metrics_collector::WidgetMetrics;pub use middleware::InspectorMiddleware;pub use middleware::Keybind;pub use middleware::KeybindRegistry;pub use middleware::MiddlewareContext;pub use middleware::MiddlewareManager;pub use middleware::Modifiers;pub use middleware::OverlayContext;pub use middleware::OverlayDrawList;pub use middleware::OverlayRenderer;pub use middleware::UiMiddleware;pub use overlay::AnchorAlignment;pub use overlay::Overlay;pub use overlay::OverlayConfig;pub use overlay::OverlayId;pub use overlay::OverlayManager;pub use overlay::OverlayPosition;pub use overlay::ZLayer;pub use tooltip::TooltipConfig;pub use tooltip::TooltipContent;pub use tooltip::TooltipManager;pub use tooltip::TooltipPosition;pub use virtual_scroll::ItemHeight;pub use virtual_scroll::MountedItem;pub use virtual_scroll::VirtualScrollConfig;pub use virtual_scroll::VirtualScrollState;pub use virtual_scroll::VirtualScrollStats;pub use virtual_scroll::VirtualScrollUpdate;pub use virtual_scroll::VirtualScrollView;pub use widgets::docking::DRAG_THRESHOLD;pub use widgets::docking::DockSplitter;pub use widgets::docking::DockTabs;pub use widgets::docking::DockZone;pub use widgets::docking::DockingStyle;pub use widgets::docking::DragManager;pub use widgets::docking::DragState;pub use widgets::docking::DragType;pub use widgets::docking::PanelConstraints;pub use widgets::docking::SplitDirection;pub use widgets::docking::TabScrollIndicator;pub use widgets::docking::TabScrollbarPosition;pub use plugin::CorePlugin;pub use plugin::PluginHandle;pub use plugin::PluginManager;pub use plugin::TraversalBehavior;pub use plugin::UiPlugin;pub use plugin::WidgetOverflow;pub use plugin::WidgetRenderContext;pub use plugin::WidgetTypeDescriptor;pub use plugin::WidgetTypeRegistry;pub use renderer::UiRendererBuilder;pub use renderer::UiRendererDescriptor;
Modules§
- animation
- Animation system for UI widgets.
- builder
- Declarative builder API for constructing UI trees.
- clip
- Clip rectangle system for overflow clipping.
- constraint
- Advanced constraint expressions for responsive UI layouts.
- constraint_
builder - Builder helpers for constraint expressions.
- constraint_
resolver - Constraint resolution logic for computing final pixel values.
- culling
- Hierarchical AABB culling for efficient rendering.
- debug
- Visual debug overlay for UI system.
- dirty
- Dirty tracking system for efficient incremental UI updates.
- draw_
list - High-level retained draw list for UI rendering.
- event
- Event handling system for UI interactions.
- focus
- Focus management and keyboard navigation for UI widgets.
- glyph_
atlas - Glyph atlas integration for converting shaped glyphs to GPU instances.
- gpu_
types - GPU data types for instance-based rendering.
- inspector
- Enhanced UI Inspector with property editing, graphs, and metrics integration.
- instance_
buffer - GPU instance buffer management for retained rendering.
- layout
- Layout cache for storing computed layout information.
- layout_
engine - Configurable layout engine supporting synchronous and asynchronous computation.
- length
- Type-safe length and dimension types for UI styling.
- menu
- Context menu system with nested submenu support.
- metrics
- Performance metrics and instrumentation for UI system.
- metrics_
collector - Comprehensive metrics collection system for UI performance monitoring.
- middleware
- Middleware system for UI pipeline extensibility.
- overlay
- Overlay management system for menus, tooltips, modals, and popovers.
- plugin
- Plugin system for modular UI widget registration and event handling.
- renderer
- UI renderer for drawing widgets with WGPU.
- scroll_
plugin - Scroll plugin providing ScrollContainer widget type and scroll state management.
- style
- Style system for UI widgets.
- theme
- Theme system for consistent UI styling.
- tooltip
- Tooltip management system for hover-based information display.
- tree
- UI tree structure with Taffy layout integration.
- viewport_
context - Viewport context for resolving viewport-relative units.
- virtual_
scroll - Virtual scrolling for efficient rendering of large lists.
- widget_
id - Widget ID system for tracking UI nodes across frames.
- widgets
- Widget system for UI components.
Structs§
- Color
- An RGBA color with
f32components in the0.0..=1.0range. - Sync
Text Shaper - Synchronous text shaper using a callback for measurement.
- Text
Pipeline - Text shaping pipeline managing requests and results.
- Text
Shape Request - Request for text shaping with all necessary parameters.
- UiCore
- Render-agnostic UI core managing tree, layout, and logic.
- UiSystem
- Main UI system managing tree, layout, rendering, and events.
- Vec2
- A 2-dimensional vector.
- Vec4
- A 4-dimensional vector.
Enums§
- Align
Content - Sets the distribution of space between and around content items For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis
- Align
Items - Used to control how child nodes are aligned. For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis
- Display
- Sets the layout used for the children of this node
- Flex
Direction - The direction of the flexbox layout main axis.
- Flex
Wrap - Controls whether flex items are forced onto one line or can wrap onto multiple lines.
- Image
Sampling - Sampling mode for image textures.
- Position
- The positioning strategy for this item.
Traits§
- Text
Shaper - Trait for text shaping implementations.
Type Aliases§
- Justify
Content - Sets the distribution of space between and around content items For Flexbox it controls alignment in the main axis For Grid it controls alignment in the inline axis