From ccd890c258f513aa295bc1269b15047a34321881 Mon Sep 17 00:00:00 2001 From: Alexander 'z33ky' Hirsch <1zeeky@gmail.com> Date: Mon, 25 Dec 2023 15:26:53 +0100 Subject: [PATCH] update egui to 0.24 --- CHANGELOG.md | 4 ++ Cargo.lock | 69 ++++++++++++++++++++++++--------- Cargo.toml | 2 +- crates/notan_egui/Cargo.toml | 2 +- crates/notan_egui/src/plugin.rs | 14 +++---- 5 files changed, 63 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 961767e0..6014a8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## UNRELEASED + +- Updated EGUI to `0.24`. + ## v0.11.0 - 18/10/2023 - Added traits `Serialize` and `Deserialize` to `Color` with the feature `serde` enabled. diff --git a/Cargo.lock b/Cargo.lock index 9d7cbb5c..55e5aceb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" +checksum = "ca8410747ed85a17c4a1e9ed3f5a74d3e7bdcc876cf9a18ff40ae21d645997b2" dependencies = [ "enumn", "serde", @@ -36,14 +36,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "serde", "version_check", + "zerocopy", ] [[package]] @@ -613,9 +614,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "ecolor" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdf4e52dbbb615cfd30cf5a5265335c217b5fd8d669593cea74a517d9c605af" +checksum = "4b7637fc2e74d17e52931bac90ff4fc061ac776ada9c7fa272f24cdca5991972" dependencies = [ "bytemuck", "serde", @@ -623,9 +624,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7" +checksum = "c55bcb864b764eb889515a38b8924757657a250738ad15126637ee2df291ee6b" dependencies = [ "accesskit", "ahash", @@ -636,9 +637,9 @@ dependencies = [ [[package]] name = "egui_demo_lib" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157bdb4408d324d9035c1b5cc517c6c4f0b8067195a931402a282c464f366cd7" +checksum = "4e23ae321f1d2dae48fca3a3d74775d9996647dbc968af153116a48ac3475daf" dependencies = [ "egui", "egui_extras", @@ -649,22 +650,22 @@ dependencies = [ [[package]] name = "egui_extras" -version = "0.23.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ffe3fe5c00295f91c2a61a74ee271c32f74049c94ba0b1cea8f26eb478bc07" +checksum = "97624eaf17a16058265d3a3e712e167798655baf7c8f693de25be75cdd6c57b5" dependencies = [ "egui", "enum-map", "log", - "mime_guess", + "mime_guess2", "serde", ] [[package]] name = "egui_plot" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f33a00fe8eb1ba56535b3dbacdecc7a1365a328908a97c5f3c81bb466be72b" +checksum = "b37b2edcdd197db41825266ae7979bd7591fa2eb6b40152375ac05eb323eb9d2" dependencies = [ "egui", ] @@ -677,9 +678,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "emath" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef2b29de53074e575c18b694167ccbe6e5191f7b25fe65175a0d905a32eeec0" +checksum = "a045c6c0b44b35e98513fc1e9d183ab42881ac27caccb9fa345465601f56cce4" dependencies = [ "bytemuck", "serde", @@ -728,9 +729,9 @@ dependencies = [ [[package]] name = "epaint" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58067b840d009143934d91d8dcb8ded054d8301d7c11a517ace0a99bb1e1595e" +checksum = "7d1b9e000d21bab9b535ce78f9f7745be28b3f777f6c7223936561c5c7fefab8" dependencies = [ "ab_glyph", "ahash", @@ -1497,6 +1498,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "mime_guess2" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a3333bb1609500601edc766a39b4c1772874a4ce26022f4d866854dc020c41" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3453,3 +3464,23 @@ name = "xmlparser" version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/Cargo.toml b/Cargo.toml index 780c82f5..87627828 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,7 +104,7 @@ features = ["default", "glyph", "egui", "text", "extra", "audio", "links", "drop lto = true [dev-dependencies] -egui_demo_lib = "0.23.0" +egui_demo_lib = "0.24.0" bytemuck = "1.14.0" [[example]] diff --git a/crates/notan_egui/Cargo.toml b/crates/notan_egui/Cargo.toml index 62cb2872..e1c75cc5 100644 --- a/crates/notan_egui/Cargo.toml +++ b/crates/notan_egui/Cargo.toml @@ -19,7 +19,7 @@ notan_macro.workspace = true log.workspace = true bytemuck.workspace = true -egui = { version = "0.23.0", features = ["bytemuck"] } +egui = { version = "0.24.0", features = ["bytemuck"] } [features] links = [] diff --git a/crates/notan_egui/src/plugin.rs b/crates/notan_egui/src/plugin.rs index ba9a5255..94f22d26 100644 --- a/crates/notan_egui/src/plugin.rs +++ b/crates/notan_egui/src/plugin.rs @@ -44,13 +44,14 @@ impl EguiPlugin { let egui::FullOutput { platform_output, - repaint_after, textures_delta, shapes, + pixels_per_point, + viewport_output, } = self.ctx.run(new_input, run_ui); let needs_update_textures = !textures_delta.is_empty(); - let needs_repaint = repaint_after.is_zero() || needs_update_textures; + let needs_repaint = viewport_output.values().any(|output| output.repaint_delay.is_zero()) || needs_update_textures; // On post frame needs repaint is set to false // set it again if true after a egui output. @@ -62,7 +63,7 @@ impl EguiPlugin { Output { ctx: self.ctx.clone(), - shapes: RefCell::new(Some(shapes)), + shapes: RefCell::new(Some((shapes, pixels_per_point))), textures_delta, clear_color: None, needs_repaint, @@ -72,7 +73,7 @@ impl EguiPlugin { pub struct Output { ctx: egui::Context, - shapes: RefCell>>, + shapes: RefCell, f32)>>, textures_delta: egui::TexturesDelta, clear_color: Option, needs_repaint: bool, @@ -101,7 +102,7 @@ impl GfxRenderer for Output { "Missing EguiExtension. You may need to add 'EguiConfig' to notan.".to_string() })?; - if let Some(shapes) = self.shapes.borrow_mut().take() { + if let Some((shapes, pixels_per_point)) = self.shapes.borrow_mut().take() { if self.clear_color.is_some() { let mut clear_renderer = device.create_renderer(); clear_renderer.begin(Some(ClearOptions { @@ -116,7 +117,7 @@ impl GfxRenderer for Output { } } - let meshes = self.ctx.tessellate(shapes); + let meshes = self.ctx.tessellate(shapes, pixels_per_point); ext.paint_and_update_textures(device, meshes, &self.textures_delta, target)?; } @@ -294,7 +295,6 @@ impl Plugin for EguiPlugin { } fn update(&mut self, app: &mut App, _assets: &mut Assets) -> Result { - self.raw_input.pixels_per_point = Some(app.window().dpi() as _); self.raw_input.time = Some(app.timer.elapsed_f32() as _); self.raw_input.predicted_dt = app.timer.delta_f32();