From 4bdf854b15d03ff430d9a22d0b7ca499cbadf353 Mon Sep 17 00:00:00 2001 From: Zicklag Date: Sat, 7 Oct 2023 15:13:25 +0000 Subject: [PATCH] feat: upgrade to egui 0.23. (#217) --- Cargo.toml | 2 +- examples/render_to_image_widget.rs | 5 ++++- examples/two_windows.rs | 10 ++++++++-- examples/ui.rs | 8 ++++---- src/egui_node.rs | 2 +- src/systems.rs | 6 +++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e19907684..14b25c54a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ bevy = { version = "0.11", default-features = false, features = [ "bevy_render", "bevy_asset", ] } -egui = { version = "0.22.0", default-features = false, features = ["bytemuck"] } +egui = { version = "0.23.0", default-features = false, features = ["bytemuck"] } webbrowser = { version = "0.8.2", optional = true } wgpu-types = "0.16" diff --git a/examples/render_to_image_widget.rs b/examples/render_to_image_widget.rs index 289a877eb..3ec89372b 100644 --- a/examples/render_to_image_widget.rs +++ b/examples/render_to_image_widget.rs @@ -159,7 +159,10 @@ fn render_to_image_example_system( let ctx = contexts.ctx_mut(); let mut apply = false; egui::Window::new("Cube material preview").show(ctx, |ui| { - ui.image(cube_preview_texture_id, [300.0, 300.0]); + ui.image(egui::load::SizedTexture::new( + cube_preview_texture_id, + egui::vec2(300., 300.), + )); egui::Grid::new("preview").show(ui, |ui| { ui.label("Base color:"); color_picker_widget(ui, &mut preview_material.base_color); diff --git a/examples/two_windows.rs b/examples/two_windows.rs index e5e4c9314..b072950f5 100644 --- a/examples/two_windows.rs +++ b/examples/two_windows.rs @@ -84,7 +84,10 @@ fn ui_first_window_system( ui.text_edit_singleline(&mut shared_ui_state.shared_input); }); - ui.add(egui::widgets::Image::new(bevy_texture_id, [256.0, 256.0])); + ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new( + bevy_texture_id, + [256.0, 256.0], + ))); }); } @@ -111,6 +114,9 @@ fn ui_second_window_system( ui.text_edit_singleline(&mut shared_ui_state.shared_input); }); - ui.add(egui::widgets::Image::new(bevy_texture_id, [256.0, 256.0])); + ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new( + bevy_texture_id, + [256.0, 256.0], + ))); }); } diff --git a/examples/ui.rs b/examples/ui.rs index 62da28fd2..74e3a9e7b 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -118,10 +118,10 @@ fn ui_example_system( ui.text_edit_singleline(&mut ui_state.label); }); - ui.add(egui::widgets::Image::new( + ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new( egui_texture_handle.id(), egui_texture_handle.size_vec2(), - )); + ))); ui.add(egui::Slider::new(&mut ui_state.value, 0.0..=10.0).text("value")); if ui.button("Increment").clicked() { @@ -135,10 +135,10 @@ fn ui_example_system( remove = ui.button("Remove").clicked(); }); - ui.add(egui::widgets::Image::new( + ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new( *rendered_texture_id, [256.0, 256.0], - )); + ))); ui.allocate_space(egui::Vec2::new(1.0, 10.0)); ui.checkbox(&mut ui_state.is_window_open, "Window Is Open"); diff --git a/src/egui_node.rs b/src/egui_node.rs index 78e8911b7..4b0700528 100644 --- a/src/egui_node.rs +++ b/src/egui_node.rs @@ -431,7 +431,7 @@ impl Node for EguiNode { pub(crate) fn as_color_image(image: egui::ImageData) -> egui::ColorImage { match image { - egui::ImageData::Color(image) => image, + egui::ImageData::Color(image) => (*image).clone(), egui::ImageData::Font(image) => alpha_image_as_color_image(&image), } } diff --git a/src/systems.rs b/src/systems.rs index 5e817b861..fc70f6812 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -295,13 +295,13 @@ pub fn process_input_system( }, pos: egui::pos2(touch_position.0, touch_position.1), force: match touch.force { - Some(bevy::input::touch::ForceTouch::Normalized(force)) => force as f32, + Some(bevy::input::touch::ForceTouch::Normalized(force)) => Some(force as f32), Some(bevy::input::touch::ForceTouch::Calibrated { force, max_possible_force, .. - }) => (force / max_possible_force) as f32, - None => 0_f32, + }) => Some((force / max_possible_force) as f32), + None => None, }, });