Crate tessera_ui

Crate tessera_ui 

Source
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 management
  • Dp, Px - Basic measurement units for layouts
  • Color - Color system for styling components

Key concepts to understand:

§🟡 Intermediate Users - Custom Layout and Interaction

For developers who want to create custom components and handle complex layouts:

Essential functions and types:

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::{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:

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 manager
  • MeasureInput - Context for layout measurement and placement
  • Constraint, DimensionValue - Layout constraint system
  • Dp, Px - Measurement units (device-independent and pixel units)
  • Color - Color representation and utilities

§Component System

§Event Handling

§Rendering System

§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::accessibility::AccessibilityActionHandler;
pub use crate::accessibility::AccessibilityId;
pub use crate::accessibility::AccessibilityNode;
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 accesskit;
pub use wgpu;
pub use winit;
pub use tessera_ui_shard;

Modules§

accessibility
Accessibility Support
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
This module provides a workaround for dynamic equality testing of trait objects of the DrawCommand trait.
dyn_eq_compute
This module provides a workaround for dynamic equality testing of trait objects of the ComputeCommand trait.
focus_state
Focus State Management
px
Physical pixel coordinate system for Tessera UI framework.
renderer
The core rendering system for the Tessera UI framework. This module provides the main Renderer struct that manages the application lifecycle, event handling, and rendering pipeline for cross-platform UI applications.
router
Root routing entry utilities.
runtime
Tessera Runtime System

Structs§

Arena
An Arena structure containing certain Nodes.
ComponentNode
A ComponentNode is a node in the component tree. It represents all information about a component.
ComponentNodeMetaData
Contains metadata of the component node.
ComponentTree
Respents a component tree
ComputedData
Layout information computed at the measure stage, representing the size of a node.
Constraint
Represents layout constraints for a component node.
CursorEvent
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.
InputHandlerInput
Input for the input handler function (InputHandlerFn).
MeasureInput
Input for the measure function (MeasureFn).
NodeId
A node identifier within a particular Arena.
ScrollEventConent
Contains scroll movement data for scroll events.

Enums§

CursorEventContent
Enumeration of all possible cursor event types.
DimensionValue
Defines how a dimension (width or height) should be calculated.
GestureState
Describes the high-level gesture classification of a cursor event.
MeasurementError
Represents errors that can occur during node measurement.
PressKeyEventType
Represents the different types of cursor buttons or touch interactions.

Type Aliases§

ComponentNodeMetaDatas
Contains all component nodes’ metadatas, using a thread-safe DashMap.
ComponentNodeTree
A tree of component nodes, using indextree::Arena for storage.
InputHandlerFn
A InputHandlerFn is a function that handles state changes for a component.
MeasureFn
A MeasureFn is a function that takes an input Constraint and its children nodes, finishes placementing inside, and returns its size (ComputedData) or an error.

Attribute Macros§

shard
Transforms a function into a shard component that can be navigated to via the routing system and (optionally) provided with a lazily‑initialized per‑shard state.
tessera
Transforms a regular Rust function into a Tessera UI component.