strong & weak widgets
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user