widget fn ret macro

This commit is contained in:
iris committed 2025-08-13 02:07:35 -04:00
1 parent c7e3225c5f
commit f4975df57b
2 files changed
+11 -11

No files matched your search

+8
View File
@@ -59,9 +59,17 @@ pub trait WidgetLike {
/// A function that returns a widget given a UI.
/// Useful for defining trait functions on widgets that create a parent widget so that the children
/// don't need to be IDs yet
pub trait WFn<W> = FnOnce(&mut Ui) -> W;
pub struct WidgetFn<F: FnOnce(&mut Ui) -> W, W>(pub F);
pub struct WidgetIdFn<F: FnOnce(&mut Ui) -> WidgetId<W>, W>(pub F);
macro_rules! WidgetFnRet {
($W:ident) => {
WidgetFn<impl FnOnce(&mut Ui) -> $W, $W>
};
}
pub(crate) use WidgetFnRet;
pub trait _WidgetFn<W: Widget> {
fn call(ui: &mut Ui) -> W;
}