Skip to main content

Widget

Trait Widget 

Source
pub trait Widget:
    Brick
    + Send
    + Sync {
Show 13 methods // Required methods fn type_id(&self) -> TypeId; fn measure(&self, constraints: Constraints) -> Size; fn layout(&mut self, bounds: Rect) -> LayoutResult; fn paint(&self, canvas: &mut dyn Canvas); fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>; fn children(&self) -> &[Box<dyn Widget>]; fn children_mut(&mut self) -> &mut [Box<dyn Widget>]; // Provided methods fn is_interactive(&self) -> bool { ... } fn is_focusable(&self) -> bool { ... } fn accessible_name(&self) -> Option<&str> { ... } fn accessible_role(&self) -> AccessibleRole { ... } fn test_id(&self) -> Option<&str> { ... } fn bounds(&self) -> Rect { ... }
}
Expand description

Core widget trait that all UI elements implement.

§Brick Architecture (PROBAR-SPEC-009)

Widget REQUIRES the Brick trait, enforcing the “tests define interface” philosophy:

  • Every Widget has assertions that define its contract
  • Every Widget has a performance budget
  • Rendering is blocked if assertions fail (Popperian falsification)

§Lifecycle

  1. verify: Check Brick assertions (mandatory)
  2. measure: Compute intrinsic size given constraints
  3. layout: Position self and children within allocated bounds
  4. paint: Generate draw commands (only if can_render() returns true)

Required Methods§

Source

fn type_id(&self) -> TypeId

Get the type identifier for this widget type.

Source

fn measure(&self, constraints: Constraints) -> Size

Compute intrinsic size constraints.

Source

fn layout(&mut self, bounds: Rect) -> LayoutResult

Position children within allocated bounds.

Source

fn paint(&self, canvas: &mut dyn Canvas)

Generate draw commands for rendering.

§Panics

Panics if called when can_render() returns false (Brick verification failed).

Source

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Handle input events.

Source

fn children(&self) -> &[Box<dyn Widget>]

Get child widgets for tree traversal.

Source

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Get mutable child widgets.

Provided Methods§

Source

fn is_interactive(&self) -> bool

Check if this widget is interactive (can receive focus/events).

Source

fn is_focusable(&self) -> bool

Check if this widget can receive keyboard focus.

Source

fn accessible_name(&self) -> Option<&str>

Get the accessible name for screen readers.

Source

fn accessible_role(&self) -> AccessibleRole

Get the accessible role.

Source

fn test_id(&self) -> Option<&str>

Get the test ID for this widget (if any).

Source

fn bounds(&self) -> Rect

Get the current bounds of this widget.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Widget for Border

Source§

impl Widget for BoxPlot

Source§

impl Widget for BrailleGraph

Source§

impl Widget for ClusterPlot

Source§

impl Widget for CollapsiblePanel

Source§

impl Widget for ConfusionMatrix

Source§

impl Widget for ConnectionsPanel

Source§

impl Widget for ContainersPanel

Source§

impl Widget for CoreStatsDataFrame

Source§

impl Widget for CoreUtilizationHistogram

Source§

impl Widget for CpuGrid

Source§

impl Widget for CpuStateBreakdown

Source§

impl Widget for DataFrame

Source§

impl Widget for FeatureImportance

Source§

impl Widget for FilesPanel

Source§

impl Widget for FlexCell

Source§

impl Widget for ForceGraph

Source§

impl Widget for FreqTempHeatmap

Source§

impl Widget for Gauge

Source§

impl Widget for GpuPanel

Source§

impl Widget for GutterCursor

Source§

impl Widget for Heatmap

Source§

impl Widget for Histogram

Source§

impl Widget for HorizonGraph

Source§

impl Widget for LabeledBar

Source§

impl Widget for Layout

Source§

impl Widget for LineChart

Source§

impl Widget for LoadAverageTimeline

Source§

impl Widget for LossCurve

Source§

impl Widget for MemoryBar

Source§

impl Widget for Meter

Source§

impl Widget for MultiBarGraph

Source§

impl Widget for NetworkPanel

Source§

impl Widget for PCAPlot

Source§

impl Widget for ParallelCoordinates

Source§

impl Widget for PerCoreSparklineGrid

Source§

impl Widget for ProcessDataFrame

Source§

impl Widget for ProcessTable

Source§

impl Widget for ProportionalBar

Source§

impl Widget for RadarPlot

Source§

impl Widget for RocPrCurve

Source§

impl Widget for ScatterPlot

Source§

impl Widget for Scrollbar

Source§

impl Widget for SegmentedMeter

Source§

impl Widget for SemanticLabel

Source§

impl Widget for SensorsPanel

Source§

impl Widget for Sparkline

Source§

impl Widget for SystemStatus

Source§

impl Widget for Table

Source§

impl Widget for Text

Source§

impl Widget for TextInput

Source§

impl Widget for TitleBar

Source§

impl Widget for TopProcessesMini

Source§

impl Widget for TopProcessesTable

Source§

impl Widget for Tree

Source§

impl Widget for Treemap

Source§

impl Widget for TrendSparkline

Source§

impl Widget for ViolinPlot