finished moving out render_state

This commit is contained in:
iris committed 2026-01-19 18:00:24 -05:00
1 parent 79813db3ba
commit 06dd015092
26 files changed
+496 -220

No files matched your search

+7 -6
View File
@@ -1,4 +1,4 @@
use crate::{HasRoot, UiRsc};
use crate::UiRsc;
use super::*;
use std::marker::Unsize;
@@ -22,15 +22,16 @@ pub trait WidgetLike<Rsc: UiRsc, Tag>: Sized {
}
}
fn set_root(self, rsc: &mut Rsc)
where
Rsc: HasRoot,
{
fn set_root(self, rsc: &mut Rsc, root: &mut impl HasRoot) {
let id = self.add_strong(rsc);
rsc.set_root(id);
root.set_root(id);
}
}
pub trait HasRoot {
fn set_root(&mut self, root: StrongWidget);
}
pub trait WidgetArrLike<Rsc, const LEN: usize, Tag> {
#[track_caller]
fn add(self, state: &mut Rsc) -> WidgetArr<LEN>;
+3 -1
View File
@@ -6,7 +6,9 @@ pub struct WidgetTag;
impl<Rsc: UiRsc, W: Widget> WidgetLike<Rsc, WidgetTag> for W {
type Widget = W;
fn add(self, rsc: &mut Rsc) -> WeakWidget<W> {
rsc.add_widget(self)
let w = rsc.ui_mut().widgets.add_weak(self);
rsc.on_add(w);
w
}
}
+4 -4
View File
@@ -104,10 +104,10 @@ impl Widgets {
self.vec.get_mut(id.id())
}
pub fn free(&mut self) {
for id in self.recv.try_iter() {
self.vec.free(id.id());
}
pub fn free_next(&mut self) -> Option<WidgetId> {
let next = self.recv.try_recv().ok()?;
self.vec.free(next);
Some(next)
}
#[allow(clippy::len_without_is_empty)]