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);Re-exports§
pub use crate::brick_types::Brick;pub use crate::brick_types::BrickAssertion;pub use crate::brick_types::BrickBudget;pub use crate::brick_types::BrickError;pub use crate::brick_types::BrickPhase;pub use crate::brick_types::BrickResult;pub use crate::brick_types::BrickVerification;pub use crate::brick_types::BudgetViolation;
Structs§
- 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.
- Font
Style - Font style.
- Font
Weight - Font weight.