From 7cc61b82d1d50df5e97c180bed4c7796e06eec15 Mon Sep 17 00:00:00 2001 From: apekros Date: Thu, 5 Oct 2023 15:41:57 +1100 Subject: [PATCH 1/4] chore: update egui to 0.23.0 --- Cargo.lock | 49 +++++++++++++++++++++++++++++---- crates/notan_egui/Cargo.toml | 2 +- crates/notan_egui/src/plugin.rs | 8 +++--- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fc2d760..0e1ba234 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,6 +608,12 @@ name = "ecolor" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63" + +[[package]] +name = "ecolor" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfdf4e52dbbb615cfd30cf5a5265335c217b5fd8d669593cea74a517d9c605af" dependencies = [ "bytemuck", ] @@ -619,7 +625,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" dependencies = [ "ahash", - "epaint", + "epaint 0.22.0", + "nohash-hasher", +] + +[[package]] +name = "egui" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7" +dependencies = [ + "ahash", + "epaint 0.23.0", "nohash-hasher", ] @@ -629,7 +646,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "807f2eaee012c4f10d541db010845340fcdebf0b97b82b88a13e5ca1d6c84385" dependencies = [ - "egui", + "egui 0.22.0", "egui_extras", "enum-map", "log", @@ -642,7 +659,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9278f4337b526f0d57e5375e5a7340a311fa6ee8f9fcc75721ac50af13face02" dependencies = [ - "egui", + "egui 0.22.0", "serde", ] @@ -657,6 +674,12 @@ name = "emath" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b" + +[[package]] +name = "emath" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ef2b29de53074e575c18b694167ccbe6e5191f7b25fe65175a0d905a32eeec0" dependencies = [ "bytemuck", ] @@ -700,9 +723,23 @@ dependencies = [ "ab_glyph", "ahash", "atomic_refcell", + "ecolor 0.22.0", + "emath 0.22.0", + "nohash-hasher", + "parking_lot", +] + +[[package]] +name = "epaint" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58067b840d009143934d91d8dcb8ded054d8301d7c11a517ace0a99bb1e1595e" +dependencies = [ + "ab_glyph", + "ahash", "bytemuck", - "ecolor", - "emath", + "ecolor 0.23.0", + "emath 0.23.0", "nohash-hasher", "parking_lot", ] @@ -1676,7 +1713,7 @@ name = "notan_egui" version = "0.10.0" dependencies = [ "bytemuck", - "egui", + "egui 0.23.0", "log", "notan_app", "notan_core", diff --git a/crates/notan_egui/Cargo.toml b/crates/notan_egui/Cargo.toml index 75a775bb..8980445e 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.22.0", features = ["bytemuck"] } +egui = { version = "0.23.0", features = ["bytemuck"] } [features] links = [] diff --git a/crates/notan_egui/src/plugin.rs b/crates/notan_egui/src/plugin.rs index 777552ff..ba9a5255 100644 --- a/crates/notan_egui/src/plugin.rs +++ b/crates/notan_egui/src/plugin.rs @@ -255,14 +255,14 @@ impl Plugin for EguiPlugin { id: egui::TouchId(*id), phase: egui::TouchPhase::Start, pos: (*x, *y).into(), - force: 0.0, + force: Some(0.0), }), Event::TouchMove { id, x, y } => self.add_event(egui::Event::Touch { device_id: egui::TouchDeviceId(0), id: egui::TouchId(*id), phase: egui::TouchPhase::Move, pos: (*x, *y).into(), - force: 0.0, + force: Some(0.0), }), Event::TouchEnd { id, x, y } => { self.add_event(egui::Event::Touch { @@ -270,7 +270,7 @@ impl Plugin for EguiPlugin { id: egui::TouchId(*id), phase: egui::TouchPhase::End, pos: (*x, *y).into(), - force: 0.0, + force: Some(0.0), }); is_touch_end = true; @@ -281,7 +281,7 @@ impl Plugin for EguiPlugin { id: egui::TouchId(*id), phase: egui::TouchPhase::Cancel, pos: (*x, *y).into(), - force: 0.0, + force: Some(0.0), }); is_touch_end = true; } From 68d90d394e1a7686f51332ea40da16da1a79fb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nazari=CC=81=20Gonza=CC=81lez?= Date: Thu, 12 Oct 2023 20:07:15 +0100 Subject: [PATCH 2/4] clippy fixes --- Cargo.lock | 95 ++++++++++++++---------------- Cargo.toml | 2 +- crates/notan_macro/src/handlers.rs | 7 +-- 3 files changed, 49 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e1ba234..e39ff4c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,16 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +[[package]] +name = "accesskit" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" +dependencies = [ + "enumn", + "serde", +] + [[package]] name = "adler" version = "1.0.2" @@ -32,6 +42,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "once_cell", + "serde", "version_check", ] @@ -134,12 +145,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "atomic_refcell" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112ef6b3f6cb3cb6fc5b6b494ef7a848492cff1ab0ef4de10b0f7d572861c905" - [[package]] name = "autocfg" version = "1.1.0" @@ -603,12 +608,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" -[[package]] -name = "ecolor" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63" - [[package]] name = "ecolor" version = "0.23.0" @@ -616,17 +615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf4e52dbbb615cfd30cf5a5265335c217b5fd8d669593cea74a517d9c605af" dependencies = [ "bytemuck", -] - -[[package]] -name = "egui" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" -dependencies = [ - "ahash", - "epaint 0.22.0", - "nohash-hasher", + "serde", ] [[package]] @@ -635,45 +624,53 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7" dependencies = [ + "accesskit", "ahash", - "epaint 0.23.0", + "epaint", "nohash-hasher", + "serde", ] [[package]] name = "egui_demo_lib" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807f2eaee012c4f10d541db010845340fcdebf0b97b82b88a13e5ca1d6c84385" +checksum = "157bdb4408d324d9035c1b5cc517c6c4f0b8067195a931402a282c464f366cd7" dependencies = [ - "egui 0.22.0", + "egui", "egui_extras", - "enum-map", + "egui_plot", "log", "unicode_names2", ] [[package]] name = "egui_extras" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9278f4337b526f0d57e5375e5a7340a311fa6ee8f9fcc75721ac50af13face02" +checksum = "68ffe3fe5c00295f91c2a61a74ee271c32f74049c94ba0b1cea8f26eb478bc07" dependencies = [ - "egui 0.22.0", + "egui", + "enum-map", + "log", + "mime_guess", "serde", ] [[package]] -name = "either" -version = "1.9.0" +name = "egui_plot" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "c7f33a00fe8eb1ba56535b3dbacdecc7a1365a328908a97c5f3c81bb466be72b" +dependencies = [ + "egui", +] [[package]] -name = "emath" -version = "0.22.0" +name = "either" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "emath" @@ -682,6 +679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ef2b29de53074e575c18b694167ccbe6e5191f7b25fe65175a0d905a32eeec0" dependencies = [ "bytemuck", + "serde", ] [[package]] @@ -715,18 +713,14 @@ dependencies = [ ] [[package]] -name = "epaint" -version = "0.22.0" +name = "enumn" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b" +checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ - "ab_glyph", - "ahash", - "atomic_refcell", - "ecolor 0.22.0", - "emath 0.22.0", - "nohash-hasher", - "parking_lot", + "proc-macro2", + "quote", + "syn 2.0.31", ] [[package]] @@ -738,10 +732,11 @@ dependencies = [ "ab_glyph", "ahash", "bytemuck", - "ecolor 0.23.0", - "emath 0.23.0", + "ecolor", + "emath", "nohash-hasher", "parking_lot", + "serde", ] [[package]] @@ -1713,7 +1708,7 @@ name = "notan_egui" version = "0.10.0" dependencies = [ "bytemuck", - "egui 0.23.0", + "egui", "log", "notan_app", "notan_core", diff --git a/Cargo.toml b/Cargo.toml index d2b6b320..237a09e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ shaderc = ["notan_macro/shaderc", "notan_glyph?/shaderc", "notan_draw?/shaderc", serde = ["notan_app/serde", "notan_math/serde", "notan_core/serde", "notan_input/serde", "notan_graphics/serde"] [dev-dependencies] -egui_demo_lib = "0.22.0" +egui_demo_lib = "0.23.0" bytemuck = "1.14.0" [[example]] diff --git a/crates/notan_macro/src/handlers.rs b/crates/notan_macro/src/handlers.rs index ed55051e..7f6cca43 100644 --- a/crates/notan_macro/src/handlers.rs +++ b/crates/notan_macro/src/handlers.rs @@ -124,7 +124,7 @@ fn enum_impl_generator(tokens: &Tokens, once: bool) -> String { .ret .as_ref() .map(|v| format!(" -> {v}")) - .unwrap_or_else(|| "".to_string()); + .unwrap_or_default(); let callback = enum_callback_generics(&combo(&tokens.params), &tokens.params); let reference = if once { "" } else { "&" }; @@ -171,7 +171,7 @@ fn trait_impl_generator(tokens: &Tokens, gen_type: GenericType, fn_literal: &str .ret .as_ref() .map(|v| format!(" -> {v}")) - .unwrap_or_else(|| "".to_string()); + .unwrap_or_default(); let s_type = match gen_type { GenericType::Plugin => "Plugin + 'static", @@ -252,8 +252,7 @@ fn enum_generics(g: &[Vec], r: Option<&String>, fn_literal: &str) -> Str "_{}(Box)", i, gen, - r.map(|v| format!(" -> {v}")) - .unwrap_or_else(|| "".to_string()) + r.map(|v| format!(" -> {v}")).unwrap_or_default() ) }) .collect::>() From 3acc6cefecd83f903c47542d6cebb5805378311e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nazari=CC=81=20Gonza=CC=81lez?= Date: Thu, 12 Oct 2023 20:07:42 +0100 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4201e46..8ecab08a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## UNRELEASED - Added traits `Serialize` and `Deserialize` to `Color` with the feature `serde` enabled. +- Updated EGUI to `0.23`. ## v0.10.0 - 11/09/2023 From 8bdf4ae58b493f3478d305d240946f97788607bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nazari=CC=81=20Gonza=CC=81lez?= Date: Sun, 15 Oct 2023 19:58:17 +0100 Subject: [PATCH 4/4] fixed egui image api --- crates/notan_egui/src/extension.rs | 18 ++++++++++-------- crates/notan_egui/src/lib.rs | 1 + examples/egui_render_texture.rs | 11 ++++------- examples/egui_texture.rs | 10 ++++------ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/notan_egui/src/extension.rs b/crates/notan_egui/src/extension.rs index 54af681f..8c1125e8 100644 --- a/crates/notan_egui/src/extension.rs +++ b/crates/notan_egui/src/extension.rs @@ -3,6 +3,7 @@ use crate::epaint::Primitive; use crate::plugin::Output; use crate::TextureId; +use egui::load::SizedTexture; use egui::{PaintCallbackInfo, Rect}; use notan_app::{ BlendFactor, BlendMode, Buffer, CullMode, Device, Graphics, Pipeline, RenderTexture, @@ -149,14 +150,15 @@ impl EguiExtension { }) } - pub fn add_texture(&mut self, texture: &Texture) -> egui::TextureId { + pub fn add_texture(&mut self, texture: &Texture) -> SizedTexture { let id = egui::TextureId::User(texture.id()); + let size: egui::Vec2 = texture.size().into(); self.textures.insert(id, texture.clone()); - id + SizedTexture { id, size } } - pub fn remove_texture(&mut self, id: egui::TextureId) { - self.free_texture(id); + pub fn remove_texture(&mut self, id: impl Into) { + self.free_texture(id.into()); } fn set_texture( @@ -388,18 +390,18 @@ impl EguiExtension { } pub trait EguiRegisterTexture { - fn egui_register_texture(&mut self, texture: &Texture) -> egui::TextureId; - fn egui_remove_texture(&mut self, id: egui::TextureId); + fn egui_register_texture(&mut self, texture: &Texture) -> egui::load::SizedTexture; + fn egui_remove_texture(&mut self, id: impl Into); } impl EguiRegisterTexture for Graphics { - fn egui_register_texture(&mut self, texture: &Texture) -> TextureId { + fn egui_register_texture(&mut self, texture: &Texture) -> SizedTexture { self.extension_mut::() .unwrap() .add_texture(texture) } - fn egui_remove_texture(&mut self, id: TextureId) { + fn egui_remove_texture(&mut self, id: impl Into) { self.extension_mut::() .unwrap() .remove_texture(id); diff --git a/crates/notan_egui/src/lib.rs b/crates/notan_egui/src/lib.rs index 92ad0c1c..cba26831 100644 --- a/crates/notan_egui/src/lib.rs +++ b/crates/notan_egui/src/lib.rs @@ -7,4 +7,5 @@ pub use config::EguiConfig; pub use extension::{EguiCallbackFn, EguiExtension, EguiRegisterTexture}; pub use plugin::{EguiPlugin, EguiPluginSugar}; +pub use egui::load::SizedTexture; pub use egui::*; diff --git a/examples/egui_render_texture.rs b/examples/egui_render_texture.rs index 30f89885..913ebd6c 100644 --- a/examples/egui_render_texture.rs +++ b/examples/egui_render_texture.rs @@ -6,8 +6,7 @@ use notan::prelude::*; struct State { cube: Cube, render_texture: RenderTexture, - tex_id: egui::TextureId, - img_size: egui::Vec2, + sized_texture: SizedTexture, } impl State { @@ -20,14 +19,12 @@ impl State { .build() .unwrap(); - let img_size = render_texture.size().into(); - let tex_id = gfx.egui_register_texture(&render_texture); + let sized_texture = gfx.egui_register_texture(&render_texture); Self { - img_size, - tex_id, cube, render_texture, + sized_texture, } } } @@ -47,7 +44,7 @@ fn draw(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut St let mut output = plugins.egui(|ctx| { egui::Window::new("Notan Render Texture").show(ctx, |ui| { - ui.image(state.tex_id, state.img_size); + ui.image(state.sized_texture); }); }); output.clear_color(Color::BLACK); diff --git a/examples/egui_texture.rs b/examples/egui_texture.rs index 94e2fb55..b75b360d 100644 --- a/examples/egui_texture.rs +++ b/examples/egui_texture.rs @@ -3,8 +3,7 @@ use notan::prelude::*; #[derive(AppState)] struct State { - tex_id: egui::TextureId, - img_size: egui::Vec2, + sized_texture: egui::SizedTexture, } impl State { @@ -16,10 +15,9 @@ impl State { .build() .unwrap(); - let img_size: egui::Vec2 = texture.size().into(); - let tex_id = gfx.egui_register_texture(&texture); + let sized_texture = gfx.egui_register_texture(&texture); - Self { img_size, tex_id } + Self { sized_texture } } } @@ -34,7 +32,7 @@ fn main() -> Result<(), String> { fn draw(gfx: &mut Graphics, plugins: &mut Plugins, state: &mut State) { let mut output = plugins.egui(|ctx| { egui::Window::new("Notan Texture").show(ctx, |ui| { - ui.image(state.tex_id, state.img_size); + ui.image(state.sized_texture); }); });