texture freeing + render updates done a bit nicer

This commit is contained in:
iris committed 2025-08-23 13:02:00 -04:00
1 parent 5fe63e311c
commit 6fbdf9fbc8
10 files changed
+176 -108

No files matched your search

+7 -8
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();
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
use pollster::FutureExt;
use std::sync::Arc;
use ui::{
UiRenderUpdates,
Ui,
render::{UiLimits, UiRenderer},
};
use wgpu::{util::StagingBelt, *};
@@ -21,7 +21,7 @@ pub struct Renderer {
}
impl Renderer {
pub fn update(&mut self, updates: UiRenderUpdates) {
pub fn update<Ctx>(&mut self, updates: &mut Ui<Ctx>) {
self.ui.update(&self.device, &self.queue, updates);
}