Expand description
Widget trait and related types.
This module defines the core Widget trait and supporting types for building
UI components in Presentar.
§Widget Lifecycle (Brick Architecture - PROBAR-SPEC-009)
Widgets follow a verify-measure-layout-paint cycle:
- Verify: Check all Brick assertions pass (Popperian falsification)
- Measure: Compute intrinsic size given constraints
- Layout: Position self and children within allocated bounds
- Paint: Generate draw commands for rendering (only if verified)
§Brick Integration
When the brick feature is enabled, all Widgets must implement the Brick
trait from jugar_probar. This enforces the “tests define interface” philosophy:
- Assertions are verified before every paint
- Budget violations trigger Jidoka (stop-the-line)
- Rendering is blocked if any assertion fails
§Examples
use presentar_core::{WidgetId, TypeId, Transform2D};
// Create widget identifiers
let id = WidgetId::new(42);
assert_eq!(id.0, 42);
// Get type IDs for widget type comparison
let string_type = TypeId::of::<String>();
let i32_type = TypeId::of::<i32>();
assert_ne!(string_type, i32_type);
// Create transforms for rendering
let translate = Transform2D::translate(10.0, 20.0);
let scale = Transform2D::scale(2.0, 2.0);Structs§
- Brick
Budget - Performance budget for a brick.
- Brick
Verification - Result of verifying brick assertions
- Budget
Violation - Budget violation report
- Layout
Result - Result of laying out a widget.
- Text
Style - Text style for rendering.
- Transform2D
- 2D affine transform.
- TypeId
- Type identifier for widget types (used for diffing).
- Widget
Id - Unique identifier for a widget instance.
Enums§
- Accessible
Role - Accessible role for screen readers.
- Brick
Assertion - Brick assertion that must be verified at runtime.
- Brick
Error - Yuan Gate: Zero-swallow error handling for bricks
- Brick
Phase - Rendering phase for budget tracking
- Font
Style - Font style.
- Font
Weight - Font weight.
Traits§
- Brick
- Core Brick trait - the foundation of the Brick Architecture.
- Canvas
- Canvas trait for paint operations.
- Widget
- Core widget trait that all UI elements implement.
Type Aliases§
- Brick
Result - Result type for brick operations