### Overview Define the base widget trait that all UI elements implement and establish the rendering model for UI components. ### Current State _No response_ ### Scope **Goals:** - `Widget` trait defining common interface - Widget bounds and layout rect - Basic rendering abstraction - Hit testing for input handling **Non-Goals:** - Specific widget types - Layout system - Styling ### Proposed API ```rust // crates/lambda-rs/src/ui/widget.rs pub struct Rect { pub x: f32, pub y: f32, pub width: f32, pub height: f32, } impl Rect { pub fn contains(&self, x: f32, y: f32) -> bool; } pub trait Widget { fn bounds(&self) -> Rect; fn set_bounds(&mut self, rect: Rect); fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>; fn hit_test(&self, x: f32, y: f32) -> bool; } pub struct UiRenderContext<'a> { render_context: &'a mut RenderContext, // UI-specific state } ``` ### Acceptance Criteria - [ ] Widget trait is object-safe (can use dyn Widget) - [ ] Bounds stored and queryable - [ ] Hit test uses bounds by default - [ ] Render returns commands for drawing - [ ] Trait extensible for specific widgets ### Affected Crates lambda-rs ### Notes - Consider immediate-mode alternative (egui integration)
Activity