strong & weak widgets

This commit is contained in:
2025-12-11 07:16:06 -05:00
parent a85e129026
commit 36668c82f4
19 changed files with 293 additions and 294 deletions

View File

@@ -158,7 +158,7 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> FnOnce<(&mut Ui,)>
extern "rust-call" fn call_once(self, args: (&mut Ui,)) -> Self::Output {
Span {
children: self.children.ui(args.0).arr.to_vec(),
children: self.children.ui(args.0).arr.into_iter().collect(),
dir: self.dir,
gap: self.gap,
}

View File

@@ -55,7 +55,7 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> FnOnce<(&mut Ui,)>
extern "rust-call" fn call_once(self, args: (&mut Ui,)) -> Self::Output {
Stack {
children: self.children.ui(args.0).arr.to_vec(),
children: self.children.ui(args.0).arr.into_iter().collect(),
size: self.size,
}
}

View File

@@ -1,4 +1,5 @@
use crate::prelude::*;
use std::marker::{Sized, Unsize};
#[derive(Default)]
pub struct WidgetPtr {
@@ -28,3 +29,19 @@ impl Widget for WidgetPtr {
}
}
}
impl WidgetPtr {
pub fn new() -> Self {
Self::default()
}
pub fn set<W: ?Sized + Unsize<dyn Widget>>(&mut self, to: WidgetHandle<W>) {
self.inner = Some(to)
}
pub fn replace<W: ?Sized + Unsize<dyn Widget>>(
&mut self,
to: WidgetHandle<W>,
) -> Option<WidgetHandle> {
self.inner.replace(to)
}
}

View File

@@ -123,7 +123,7 @@ widget_trait! {
}
}
fn to_any(self) -> impl WidgetRet {
fn to_any(self) -> impl WidgetIdFn {
|ui| self.add(ui).any()
}
}