Skip to content

Commit

Permalink
update egui to 0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
z33ky authored and Nazariglez committed Feb 17, 2024
1 parent cec247e commit ccd890c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## UNRELEASED

- Updated EGUI to `0.24`.

## v0.11.0 - 18/10/2023

- Added traits `Serialize` and `Deserialize` to `Color` with the feature `serde` enabled.
Expand Down
69 changes: 50 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ features = ["default", "glyph", "egui", "text", "extra", "audio", "links", "drop
lto = true

[dev-dependencies]
egui_demo_lib = "0.23.0"
egui_demo_lib = "0.24.0"
bytemuck = "1.14.0"

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion crates/notan_egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ notan_macro.workspace = true
log.workspace = true
bytemuck.workspace = true

egui = { version = "0.23.0", features = ["bytemuck"] }
egui = { version = "0.24.0", features = ["bytemuck"] }

[features]
links = []
Expand Down
14 changes: 7 additions & 7 deletions crates/notan_egui/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ impl EguiPlugin {

let egui::FullOutput {
platform_output,
repaint_after,
textures_delta,
shapes,
pixels_per_point,
viewport_output,
} = self.ctx.run(new_input, run_ui);

let needs_update_textures = !textures_delta.is_empty();
let needs_repaint = repaint_after.is_zero() || needs_update_textures;
let needs_repaint = viewport_output.values().any(|output| output.repaint_delay.is_zero()) || needs_update_textures;

// On post frame needs repaint is set to false
// set it again if true after a egui output.
Expand All @@ -62,7 +63,7 @@ impl EguiPlugin {

Output {
ctx: self.ctx.clone(),
shapes: RefCell::new(Some(shapes)),
shapes: RefCell::new(Some((shapes, pixels_per_point))),
textures_delta,
clear_color: None,
needs_repaint,
Expand All @@ -72,7 +73,7 @@ impl EguiPlugin {

pub struct Output {
ctx: egui::Context,
shapes: RefCell<Option<Vec<egui::epaint::ClippedShape>>>,
shapes: RefCell<Option<(Vec<egui::epaint::ClippedShape>, f32)>>,
textures_delta: egui::TexturesDelta,
clear_color: Option<Color>,
needs_repaint: bool,
Expand Down Expand Up @@ -101,7 +102,7 @@ impl GfxRenderer for Output {
"Missing EguiExtension. You may need to add 'EguiConfig' to notan.".to_string()
})?;

if let Some(shapes) = self.shapes.borrow_mut().take() {
if let Some((shapes, pixels_per_point)) = self.shapes.borrow_mut().take() {
if self.clear_color.is_some() {
let mut clear_renderer = device.create_renderer();
clear_renderer.begin(Some(ClearOptions {
Expand All @@ -116,7 +117,7 @@ impl GfxRenderer for Output {
}
}

let meshes = self.ctx.tessellate(shapes);
let meshes = self.ctx.tessellate(shapes, pixels_per_point);
ext.paint_and_update_textures(device, meshes, &self.textures_delta, target)?;
}

Expand Down Expand Up @@ -294,7 +295,6 @@ impl Plugin for EguiPlugin {
}

fn update(&mut self, app: &mut App, _assets: &mut Assets) -> Result<AppFlow, String> {
self.raw_input.pixels_per_point = Some(app.window().dpi() as _);
self.raw_input.time = Some(app.timer.elapsed_f32() as _);
self.raw_input.predicted_dt = app.timer.delta_f32();

Expand Down

0 comments on commit ccd890c

Please sign in to comment.