Skip to content

Commit

Permalink
feat: upgrade to egui 0.23. (vladbat00#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag authored and Schmarni-Dev committed Dec 23, 2023
1 parent 9a9a667 commit b9645d8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
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 @@ -416,7 +416,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

0 comments on commit b9645d8

Please sign in to comment.