strong & weak widgets
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ widget_trait! {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_any(self) -> impl WidgetRet {
|
||||
fn to_any(self) -> impl WidgetIdFn {
|
||||
|ui| self.add(ui).any()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user