texture freeing + render updates done a bit nicer

This commit is contained in:
2025-08-23 13:02:00 -04:00
parent 5fe63e311c
commit 6fbdf9fbc8
10 changed files with 176 additions and 108 deletions

View File

@@ -76,8 +76,6 @@ impl Client {
let span_add_test = ui.add(Span::empty(Dir::RIGHT).id(&span_add));
let main: WidgetId<Regioned> = ui.id();
let image_test = ui.add(image(include_bytes!("assets/sungals.png")));
fn switch_button<To>(
color: UiColor,
main: &WidgetId<Regioned>,
@@ -106,9 +104,8 @@ impl Client {
switch_button(UiColor::RED, &main, &pad_test),
switch_button(UiColor::GREEN, &main, &span_test),
switch_button(UiColor::BLUE, &main, &span_add_test),
switch_button(UiColor::MAGENTA, &main, &image_test),
)
.span(Dir::RIGHT, [1, 1, 1, 1]),
.span(Dir::RIGHT, [1, 1, 1]),
);
let test_button = Rect::new(Color::PURPLE)
.radius(30)
@@ -159,15 +156,17 @@ impl Client {
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::RedrawRequested => {
let updates = ui.update(self);
self.renderer.update(updates);
ui.update(self);
self.renderer.update(ui);
self.renderer.draw()
}
WindowEvent::Resized(size) => self.renderer.resize(&size),
WindowEvent::KeyboardInput { event, .. } => {
if event.state.is_pressed() {
let child = ui.add(Rect::new(Color::YELLOW)).erase_type();
ui[&self.ui.span_add].children.push((child, fixed(20.0)));
let child = ui
.add(image(include_bytes!("assets/sungals.png")))
.erase_type();
ui[&self.ui.span_add].children.push((child, ratio(1)));
self.renderer.window().request_redraw();
}
}