From f697e175985ec02fd6faf85d7a1f84be3c56f0c4 Mon Sep 17 00:00:00 2001 From: Jacob Millward Date: Mon, 1 Jan 2024 13:24:03 +0000 Subject: [PATCH] Update minimal-egui to egui 0.24 --- examples/minimal-egui/Cargo.toml | 6 +++--- examples/minimal-egui/src/gui.rs | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/minimal-egui/Cargo.toml b/examples/minimal-egui/Cargo.toml index b91a8b8c..489cdce5 100644 --- a/examples/minimal-egui/Cargo.toml +++ b/examples/minimal-egui/Cargo.toml @@ -10,9 +10,9 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -egui = "0.23" -egui-wgpu = "0.23" -egui-winit = { version = "0.23", default-features = false, features = ["links"] } +egui = "0.24" +egui-wgpu = "0.24" +egui-winit = { version = "0.24", default-features = false, features = ["links"] } env_logger = "0.10" error-iter = "0.4" log = "0.4" diff --git a/examples/minimal-egui/src/gui.rs b/examples/minimal-egui/src/gui.rs index e821c4fa..9ca98881 100644 --- a/examples/minimal-egui/src/gui.rs +++ b/examples/minimal-egui/src/gui.rs @@ -1,4 +1,4 @@ -use egui::{ClippedPrimitive, Context, TexturesDelta}; +use egui::{ClippedPrimitive, Context, TexturesDelta, ViewportId}; use egui_wgpu::renderer::{Renderer, ScreenDescriptor}; use pixels::{wgpu, PixelsContext}; use winit::event_loop::EventLoopWindowTarget; @@ -36,9 +36,13 @@ impl Framework { let max_texture_size = pixels.device().limits().max_texture_dimension_2d as usize; let egui_ctx = Context::default(); - let mut egui_state = egui_winit::State::new(event_loop); - egui_state.set_max_texture_side(max_texture_size); - egui_state.set_pixels_per_point(scale_factor); + let egui_state = egui_winit::State::new( + ViewportId::ROOT, + event_loop, + Some(scale_factor), + Some(max_texture_size), + ); + let screen_descriptor = ScreenDescriptor { size_in_pixels: [width, height], pixels_per_point: scale_factor, @@ -60,7 +64,7 @@ impl Framework { /// Handle input events from the window manager. pub(crate) fn handle_event(&mut self, event: &winit::event::WindowEvent) { - let _ = self.egui_state.on_event(&self.egui_ctx, event); + let _ = self.egui_state.on_window_event(&self.egui_ctx, event); } /// Resize egui. @@ -87,7 +91,9 @@ impl Framework { self.textures.append(output.textures_delta); self.egui_state .handle_platform_output(window, &self.egui_ctx, output.platform_output); - self.paint_jobs = self.egui_ctx.tessellate(output.shapes); + self.paint_jobs = self + .egui_ctx + .tessellate(output.shapes, self.screen_descriptor.pixels_per_point); } /// Render egui.