use taffy::{AvailableSpace, Size}; use crate::{Node, View}; pub trait Widget { #[allow(unused_variables)] fn size( &mut self, ctx: &mut C, known: Size>, available: Size, ) -> Size { Size::ZERO } fn draw_below(&mut self, ctx: &mut C, view: &mut View<'_>) -> anyhow::Result<()>; fn draw_above(&mut self, ctx: &mut C, view: &mut View<'_>) -> anyhow::Result<()>; } pub type BoxedWidget = Box>; pub trait WidgetExt { fn node(self) -> Node; } impl + 'static> WidgetExt for W { fn node(self) -> Node { Node::empty().widget(self) } }