Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to egui 0.23. #217

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
5 changes: 4 additions & 1 deletion examples/render_to_image_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions examples/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)));
});
}

Expand All @@ -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],
)));
});
}
8 changes: 4 additions & 4 deletions examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,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),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,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,
},
});

Expand Down