Expand description
§Tessera UI Framework
Tessera is a declarative, immediate-mode UI framework for Rust that emphasizes performance, flexibility, and extensibility through a functional approach and pluggable shader system.
§Architecture Overview
Tessera’s architecture is built around several core concepts:
- Declarative Components: UI components are defined as functions with the
#[tessera]macro - Immediate Mode: The UI is rebuilt every frame, ensuring consistency and simplicity
- Pluggable Shaders: Custom WGPU shaders are first-class citizens for advanced visual effects
- Parallel Processing: Core operations like measurement utilize parallel computation
- Explicit State Management: Components are stateless with explicit state passing
§Getting Started by Developer Level
§🟢 Beginner Users - Building Basic Applications
If you’re new to Tessera and want to build applications using existing components:
Start with these modules:
renderer- Core renderer and application lifecycle managementDp,Px- Basic measurement units for layoutsColor- Color system for styling components
Key concepts to understand:
- How to set up a
Rendererand run your application - Using
tessera_basic_componentsfor common UI elements - Basic layout with
row,column, andsurfacecomponents
§🟡 Intermediate Users - Custom Layout and Interaction
For developers who want to create custom components and handle complex layouts:
Essential functions and types:
measure_node- Measure child component sizes with constraintsplace_node- Position child components in the layoutInputHandlerFn- Handle user interactions and state changesConstraint,DimensionValue- Layout constraint systemComputedData- Return computed size and layout information
Key concepts:
- Understanding the measurement and placement phase
- Creating custom layout algorithms
- Managing component state through explicit input handlers
- Working with the constraint-based layout system
use tessera_ui::{measure_node, place_node, ComputedData, Constraint, PxPosition, tessera};
#[tessera]
fn custom_layout(child: impl FnOnce()) {
child();
measure(Box::new(|input| {
// Custom measurement logic here
}));
input_handler(Box::new(|input| {
// Handle user interactions here
}));
}§🔴 Advanced Users - Custom Rendering Pipelines
For developers building custom visual effects and rendering pipelines:
Advanced rendering modules:
renderer::drawer- Custom drawable pipelines and draw commandsrenderer::compute- GPU compute pipelines for advanced effectsDrawCommand,ComputeCommand- Low-level rendering commandsDrawablePipeline,ComputablePipeline- Pipeline trait implementationsPipelineRegistry,ComputePipelineRegistry- Pipeline management
Key concepts:
- Creating custom WGPU shaders and pipelines
- Managing GPU resources and compute operations
- Understanding the rendering command system
- Implementing advanced visual effects like lighting, shadows, and particles
§Core Modules
§Essential Types and Functions
Renderer- Main application renderer and lifecycle managermeasure_node,place_node- Core layout functionsConstraint,DimensionValue- Layout constraint systemDp,Px- Measurement units (device-independent and pixel units)Color- Color representation and utilities
§Component System
ComponentTree- Component tree managementComponentNode- Individual component node representationComputedData- Layout computation resultsInputHandlerFn- State management and event handling
§Event Handling
CursorEvent- Mouse and touch input eventsFocus- Focus management systemPressKeyEventType- Keyboard input handling
§Rendering System
renderer::drawer- Drawing pipeline systemrenderer::compute- Compute pipeline systemDrawCommand,ComputeCommand- Rendering commands
§Examples
Check out the example crate in the workspace for comprehensive examples demonstrating:
- Basic component usage
- Custom layouts and interactions
- Advanced shader effects
- Cross-platform deployment (Windows, Linux, macOS, Android)
§Performance Considerations
Tessera is designed for high performance through:
- Parallel measurement computation using Rayon
- Efficient GPU utilization through custom shaders
- Minimal allocations in hot paths
- Optimized component tree traversal
Re-exports§
pub use crate::clipboard::Clipboard;pub use crate::color::Color;pub use crate::dp::Dp;pub use crate::focus_state::Focus;pub use crate::px::Px;pub use crate::px::PxPosition;pub use crate::px::PxRect;pub use crate::px::PxSize;pub use crate::renderer::BarrierRequirement;pub use crate::renderer::Command;pub use crate::renderer::Renderer;pub use crate::renderer::compute;pub use crate::renderer::compute::ComputablePipeline;pub use crate::renderer::compute::ComputeCommand;pub use crate::renderer::compute::ComputePipelineRegistry;pub use crate::renderer::compute::ComputeResource;pub use crate::renderer::compute::ComputeResourceManager;pub use crate::renderer::compute::ComputeResourceRef;pub use crate::renderer::drawer;pub use crate::renderer::drawer::DrawCommand;pub use crate::renderer::drawer::DrawablePipeline;pub use crate::renderer::drawer::PipelineRegistry;pub use crate::renderer::drawer::command;pub use crate::runtime::TesseraRuntime;pub use wgpu;pub use winit;pub use tessera_ui_shard;
Modules§
- clipboard
- Provides a cross-platform clipboard manager for text manipulation.
- color
- Color utilities for the Tessera UI framework.
- dp
- Density-Independent Pixels (Dp)
- dyn_eq
- dyn_
eq_ compute - focus_
state - Focus State Management
- px
- Physical pixel coordinate system for Tessera UI framework.
- renderer
- Tessera Renderer
- router
- Root routing entry utilities.
- runtime
- Tessera Runtime System
Structs§
- Arena
- An
Arenastructure containing certainNodes. - Component
Node - A ComponentNode is a node in the component tree. It represents all information about a component.
- Component
Node Meta Data - Contains metadata of the component node.
- Component
Tree - Respents a component tree
- Computed
Data - Layout information computed at the measure stage, representing the size of a node.
- Constraint
- Represents layout constraints for a component node.
- Cursor
Event - Represents a single cursor or touch event with timing information.
- ImeRequest
- A request to the windowing system to open an Input Method Editor (IME). This is typically used for text input components.
- Input
Handler Input - Input for the input handler function (
InputHandlerFn). - Measure
Input - Input for the measure function (
MeasureFn). - NodeId
- A node identifier within a particular
Arena. - Scroll
Event Conent - Contains scroll movement data for scroll events.
Enums§
- Cursor
Event Content - Enumeration of all possible cursor event types.
- Dimension
Value - Defines how a dimension (width or height) should be calculated.
- Gesture
State - Describes the high-level gesture classification of a cursor event.
- Measurement
Error - Represents errors that can occur during node measurement.
- Press
KeyEvent Type - Represents the different types of cursor buttons or touch interactions.
Functions§
- measure_
node - Measures a single node recursively, returning its size or an error.
- measure_
nodes - Concurrently measures multiple nodes using Rayon for parallelism.
- place_
node - Places a node at the specified relative position within its parent.
Type Aliases§
- Component
Node Meta Datas - Contains all component nodes’ metadatas, using a thread-safe
DashMap. - Component
Node Tree - A tree of component nodes, using
indextree::Arenafor storage. - Input
Handler Fn - A
InputHandlerFnis a function that handles state changes for a component. - Measure
Fn - A
MeasureFnis a function that takes an inputConstraintand its children nodes, finishes placementing inside, and returns its size (ComputedData) or an error.