fix view leak and add view count

This commit is contained in:
2025-08-24 22:13:02 -04:00
parent 74d01d14d4
commit 44a8b1cbeb
7 changed files with 41 additions and 18 deletions

View File

@@ -13,6 +13,7 @@ struct State {
region: UiRegion,
children: Vec<Id>,
parent: Option<Id>,
textures: Vec<TextureHandle>,
// TODO: there's probably a better way but idc at this point
id: Option<Id>,
}
@@ -59,6 +60,7 @@ impl<'a, Ctx> Painter<'a, Ctx> {
children: Vec::new(),
parent: None,
id: None,
textures: Vec::new(),
},
}
}
@@ -109,6 +111,7 @@ impl<'a, Ctx> Painter<'a, Ctx> {
children: Vec::new(),
id: Some(id.duplicate()),
parent: self.state.id.as_ref().map(|i| i.duplicate()),
textures: Vec::new(),
};
// save state
let self_state = std::mem::replace(&mut self.state, child_state);
@@ -129,13 +132,14 @@ impl<'a, Ctx> Painter<'a, Ctx> {
span: start_i..end_i,
children: child_state.children,
parent: child_state.parent,
textures: child_state.textures,
},
self.sensors_map,
);
}
pub fn draw_texture(&mut self, handle: &TextureHandle) {
self.primitives.drawn_textures.push(handle.clone());
self.state.textures.push(handle.clone());
self.write(handle.inner);
}