move everything out of layout

This commit is contained in:
2025-12-11 05:48:29 -05:00
parent 174c447706
commit a85e129026
48 changed files with 142 additions and 160 deletions

20
core/src/attr.rs Normal file
View File

@@ -0,0 +1,20 @@
use crate::{Ui, WidgetHandle, WidgetIdFn, WidgetLike};
pub trait WidgetAttr<W> {
type Input;
fn run(ui: &mut Ui, id: &WidgetHandle<W>, input: Self::Input);
}
pub trait Attrable<W, Tag> {
fn attr<A: WidgetAttr<W>>(self, input: A::Input) -> impl WidgetIdFn<W>;
}
impl<WL: WidgetLike<Tag>, Tag> Attrable<WL::Widget, Tag> for WL {
fn attr<A: WidgetAttr<WL::Widget>>(self, input: A::Input) -> impl WidgetIdFn<WL::Widget> {
|ui| {
let id = self.add(ui);
A::run(ui, &id, input);
id
}
}
}