diff --git a/CHANGELOG.md b/CHANGELOG.md index 39597572..e9192f97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ 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. -- Fixed an error acquiring the GL Context due required samples configuration. +- Updated EGUI to `0.23`. +- Fixed an error acquiring the GL Context due required samples configuration. ## v0.10.0 - 11/09/2023 diff --git a/Cargo.lock b/Cargo.lock index 1fc2d760..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" @@ -605,47 +610,62 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "ecolor" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63" +checksum = "cfdf4e52dbbb615cfd30cf5a5265335c217b5fd8d669593cea74a517d9c605af" dependencies = [ "bytemuck", + "serde", ] [[package]] name = "egui" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" +checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7" dependencies = [ + "accesskit", "ahash", "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", "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", + "enum-map", + "log", + "mime_guess", "serde", ] +[[package]] +name = "egui_plot" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f33a00fe8eb1ba56535b3dbacdecc7a1365a328908a97c5f3c81bb466be72b" +dependencies = [ + "egui", +] + [[package]] name = "either" version = "1.9.0" @@ -654,11 +674,12 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "emath" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b" +checksum = "1ef2b29de53074e575c18b694167ccbe6e5191f7b25fe65175a0d905a32eeec0" dependencies = [ "bytemuck", + "serde", ] [[package]] @@ -691,20 +712,31 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "enumn" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + [[package]] name = "epaint" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b" +checksum = "58067b840d009143934d91d8dcb8ded054d8301d7c11a517ace0a99bb1e1595e" dependencies = [ "ab_glyph", "ahash", - "atomic_refcell", "bytemuck", "ecolor", "emath", "nohash-hasher", "parking_lot", + "serde", ] [[package]] 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_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/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/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; } 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); }); });