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
verify: Check Brick assertions (mandatory)measure: Compute intrinsic size given constraintslayout: Position self and children within allocated boundspaint: Generate draw commands (only ifcan_render()returns true)
Required Methods§
Sourcefn measure(&self, constraints: Constraints) -> Size
fn measure(&self, constraints: Constraints) -> Size
Compute intrinsic size constraints.
Sourcefn layout(&mut self, bounds: Rect) -> LayoutResult
fn layout(&mut self, bounds: Rect) -> LayoutResult
Position children within allocated bounds.
Sourcefn paint(&self, canvas: &mut dyn Canvas)
fn paint(&self, canvas: &mut dyn Canvas)
Generate draw commands for rendering.
§Panics
Panics if called when can_render() returns false (Brick verification failed).
Sourcefn children_mut(&mut self) -> &mut [Box<dyn Widget>]
fn children_mut(&mut self) -> &mut [Box<dyn Widget>]
Get mutable child widgets.
Provided Methods§
Sourcefn is_interactive(&self) -> bool
fn is_interactive(&self) -> bool
Check if this widget is interactive (can receive focus/events).
Sourcefn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Check if this widget can receive keyboard focus.
Sourcefn accessible_name(&self) -> Option<&str>
fn accessible_name(&self) -> Option<&str>
Get the accessible name for screen readers.
Sourcefn accessible_role(&self) -> AccessibleRole
fn accessible_role(&self) -> AccessibleRole
Get the accessible role.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Widget for Button
impl Widget for Button
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>]
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>
Source§impl Widget for Chart
impl Widget for Chart
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>]
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>
Source§impl Widget for Checkbox
impl Widget for Checkbox
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>]
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>
Source§impl Widget for Column
impl Widget for Column
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>]
fn test_id(&self) -> Option<&str>
Source§impl Widget for Container
impl Widget for Container
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>]
fn test_id(&self) -> Option<&str>
Source§impl Widget for DataCard
impl Widget for DataCard
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>]
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>
Source§impl Widget for DataTable
impl Widget for DataTable
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>]
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>
Source§impl Widget for Grid
impl Widget for Grid
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>]
fn bounds(&self) -> Rect
fn test_id(&self) -> Option<&str>
Source§impl Widget for Image
impl Widget for Image
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>]
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>
Source§impl Widget for List
impl Widget for List
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>]
fn is_focusable(&self) -> bool
fn test_id(&self) -> Option<&str>
fn bounds(&self) -> Rect
Source§impl Widget for Menu
impl Widget for Menu
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>]
fn is_focusable(&self) -> bool
fn test_id(&self) -> Option<&str>
fn bounds(&self) -> Rect
Source§impl Widget for Modal
impl Widget for Modal
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>]
fn is_focusable(&self) -> bool
fn test_id(&self) -> Option<&str>
fn bounds(&self) -> Rect
Source§impl Widget for ModelCard
impl Widget for ModelCard
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>]
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>
Source§impl Widget for ProgressBar
impl Widget for ProgressBar
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>]
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>
Source§impl Widget for RadioGroup
impl Widget for RadioGroup
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>]
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>
Source§impl Widget for Row
impl Widget for Row
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>]
fn test_id(&self) -> Option<&str>
Source§impl Widget for Select
impl Widget for Select
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>]
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>
Source§impl Widget for Slider
impl Widget for Slider
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>]
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>
Source§impl Widget for Stack
impl Widget for Stack
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>]
fn test_id(&self) -> Option<&str>
Source§impl Widget for Tabs
impl Widget for Tabs
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>]
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>
Source§impl Widget for Text
impl Widget for Text
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>]
fn test_id(&self) -> Option<&str>
Source§impl Widget for TextInput
impl Widget for TextInput
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>]
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>
Source§impl Widget for Toggle
impl Widget for Toggle
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>]
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>
Source§impl Widget for Tooltip
impl Widget for Tooltip
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>]
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>
Source§impl Widget for Video
impl Widget for Video
Source§fn layout(&mut self, bounds: Rect) -> LayoutResult
fn layout(&mut self, bounds: Rect) -> LayoutResult
Lay the video out in bounds.
The bounds are stored as given, so verify can judge them (like Grid
and Waveform). They are sanitised where they are used (NaN and
infinities become 0, components are clamped to +-1e15, a negative size
becomes 0), so every rect and glyph vertex paint emits is finite and
the returned size is finite and not negative.