Module widget

Module widget 

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

  1. Verify: Check all Brick assertions pass (Popperian falsification)
  2. Measure: Compute intrinsic size given constraints
  3. Layout: Position self and children within allocated bounds
  4. 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§

BrickBudget
Performance budget for a brick.
BrickVerification
Result of verifying brick assertions
BudgetViolation
Budget violation report
LayoutResult
Result of laying out a widget.
TextStyle
Text style for rendering.
Transform2D
2D affine transform.
TypeId
Type identifier for widget types (used for diffing).
WidgetId
Unique identifier for a widget instance.

Enums§

AccessibleRole
Accessible role for screen readers.
BrickAssertion
Brick assertion that must be verified at runtime.
BrickError
Yuan Gate: Zero-swallow error handling for bricks
BrickPhase
Rendering phase for budget tracking
FontStyle
Font style.
FontWeight
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§

BrickResult
Result type for brick operations