mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 15:20:05 -04:00
egui_kittest: Allow passing state to the app closure (#5313)
The allows us to pass any state to the ui closure. While it is possible to just store state in the closure itself, accessing that state after the harness was created to e.g. read or modify it would require interior mutability. With this change there are new `Harness::new_state`, `Harness::run_state`, ... methods that allow passing state on each run. This builds on top of #5301, which should be merged first --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -60,7 +60,7 @@ impl TestRenderer {
|
||||
}
|
||||
|
||||
/// Render the [`Harness`] and return the resulting image.
|
||||
pub fn render(&mut self, harness: &Harness<'_>) -> RgbaImage {
|
||||
pub fn render<State>(&mut self, harness: &Harness<'_, State>) -> RgbaImage {
|
||||
// We need to create a new renderer each time we render, since the renderer stores
|
||||
// textures related to the Harnesses' egui Context.
|
||||
// Calling the renderer from different Harnesses would cause problems if we store the renderer.
|
||||
|
||||
Reference in New Issue
Block a user