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

+34 -7
View File
@@ -1,8 +1,8 @@
use crate::{WeakWidget, Widget, Widgets};
use crate::{Mask, TextData, Textures, WeakWidget, WidgetId, Widgets, util::TrackedArena};
mod active;
mod cache;
mod draw_state;
// mod draw_state;
mod painter;
mod render_state;
mod size;
@@ -13,10 +13,37 @@ pub use painter::Painter;
pub use render_state::*;
pub use size::*;
pub struct Ui {}
#[derive(Default)]
pub struct UiData {
pub widgets: Widgets,
pub textures: Textures,
pub text: TextData,
pub masks: TrackedArena<Mask, u32>,
}
pub trait UiRsc: Sized {
fn add_widget<W: Widget>(&mut self, widget: W) -> WeakWidget<W>;
fn widgets(&self) -> &Widgets;
fn widgets_mut(&mut self) -> &mut Widgets;
pub trait UiRsc {
fn ui(&self) -> &UiData;
fn ui_mut(&mut self) -> &mut UiData;
#[allow(unused_variables)]
fn on_add(&mut self, id: WeakWidget) {}
#[allow(unused_variables)]
fn on_remove(&mut self, id: WidgetId) {}
#[allow(unused_variables)]
fn on_draw(&mut self, active: &ActiveData) {}
#[allow(unused_variables)]
fn on_undraw(&mut self, active: &ActiveData) {}
fn widgets(&self) -> &Widgets {
&self.ui().widgets
}
fn widgets_mut(&mut self) -> &mut Widgets {
&mut self.ui_mut().widgets
}
fn free(&mut self) {
while let Some(id) = self.widgets_mut().free_next() {
self.on_remove(id);
}
self.ui_mut().textures.free();
}
}