This commit is contained in:
Ashley Wulber 2025-04-24 18:24:10 -04:00
parent 6fb4a4a43e
commit 4fcd09d690
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
10 changed files with 999 additions and 763 deletions

View file

@ -1,4 +1,5 @@
use std::{
borrow::Borrow,
cell::RefCell,
rc::Rc,
thread::{self, ThreadId},
@ -14,6 +15,12 @@ pub struct RcWrapper<T> {
pub(crate) thread_id: ThreadId,
}
impl<T: Default> Default for RcWrapper<T> {
fn default() -> Self {
Self::new(T::default())
}
}
impl<T> Clone for RcWrapper<T> {
fn clone(&self) -> Self {
Self {
@ -75,6 +82,12 @@ impl<M> RcElementWrapper<M> {
}
}
impl<M: 'static> Borrow<dyn Widget<M, crate::Theme, crate::Renderer>> for RcElementWrapper<M> {
fn borrow(&self) -> &(dyn Widget<M, crate::Theme, crate::Renderer> + 'static) {
self
}
}
impl<M> Widget<M, crate::Theme, crate::Renderer> for RcElementWrapper<M> {
fn size(&self) -> Size<Length> {
self.element.with_data(|e| e.as_widget().size())