wgui: components base, anyhow event listener callbacks, 📦📎-fixes, typo fixes

This commit is contained in:
Aleksander
2025-08-13 17:10:00 +02:00
parent 93a3fee349
commit a79ed0839b
23 changed files with 104 additions and 72 deletions

View File

@@ -92,7 +92,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
let mut recreate = false;
let mut last_draw = std::time::Instant::now();
let mut scale = window.scale_factor() as f32;
@@ -302,8 +301,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let tgt = images[image_index as usize].clone();
last_draw = std::time::Instant::now();
let mut cmd_buf = gfx
.create_gfx_command_buffer(CommandBufferUsage::OneTimeSubmit)
.unwrap();
@@ -337,9 +334,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
profiler.end();
}
Event::AboutToWait => {
if last_draw.elapsed().as_millis() > 16 {
window.request_redraw();
}
// should be limited to vsync
window.request_redraw();
}
_ => (),
}

View File

@@ -33,12 +33,13 @@ fn button_click_callback(
Translation::from_raw_text(text),
);
// FIXME: remove unwrap
button.try_cast::<ComponentButton>().unwrap().set_text(
button.try_cast::<ComponentButton>()?.set_text(
e.state,
e.alterables,
Translation::from_raw_text("this button has been clicked"),
);
Ok(())
})
}
@@ -70,6 +71,7 @@ impl TestbedGeneric {
e.alterables,
Translation::from_raw_text("congrats!"),
);
Ok(())
}));
let button_red = state.fetch_component_as::<ComponentButton>("button_red")?;