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

Update egui to 0.29.0 #155

Merged
merged 1 commit into from
Sep 30, 2024
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
849 changes: 443 additions & 406 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ clap = "4.4.12"
convert_case = "0.6.0"
criterion = "0.5.1"
dhat = "0.3.2" # for heap profiling
eframe = { version = "0.28.1", default-features = false, features = [
eframe = { version = "0.29.0", default-features = false, features = [
"accesskit",
"default_fonts",
"persistence",
"wgpu",
"wayland",
"x11",
] }
egui = "0.28.1"
egui = "0.29.0"
env_logger = "0.11.5"
geo = "0.28.0" # for point interop only
geos = "9.0.0"
Expand All @@ -57,13 +57,13 @@ puffin = "0.19.0"
puffin_http = "0.16"
proc-macro2 = "1.0.67"
quote = "1.0.33"
quick-xml = "0.31" # sync with egui
quick-xml = "0.34" # sync with egui
open = "5.0.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_distr = "0.4.3"
rayon = "1.8.0"
raw-window-handle = "0.5" # sync with eframe
raw-window-handle = "0.6.0" # sync with eframe
regex = "1.7.1"
rfd = { version = "0.15.0", default-features = false }
serde = { version = "1", features = ["derive", "rc"] }
Expand All @@ -77,10 +77,10 @@ usvg = "0.43.0"
voronoice = "0.2.0"
wasm-bindgen = "0.2.93" # sync with CI!!
wasm-bindgen-futures = "0.4.42"
web-time = "0.2" # sync with egui-winit
web-sys = "0.3.64"
wgpu = { version = "0.20.1", default-features = false, features = ["webgl"] } # sync with egui-wgpu
winit = "0.29.10" # sync with egui-winit
web-time = "1.1.0" # sync with egui-winit
web-sys = "0.3.70"
wgpu = { version = "22.1.0", default-features = false, features = ["webgl"] } # sync with egui-wgpu
winit = "0.30.5" # sync with egui-winit

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand Down
1 change: 1 addition & 0 deletions crates/vsvg-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ puffin_http = { workspace = true, optional = true }
rayon.workspace = true
serde.workspace = true
vsvg = { workspace = true, features = ["egui"] }
web-sys.workspace = true
wgpu.workspace = true

[dev-dependencies] # mostly for examples
Expand Down
8 changes: 4 additions & 4 deletions crates/vsvg-viewer/src/document_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@ impl egui_wgpu::CallbackTrait for DocumentWidgetCallback {
Vec::new()
}

fn paint<'a>(
&'a self,
fn paint(
&self,
_info: PaintCallbackInfo,
render_pass: &mut RenderPass<'a>,
callback_resources: &'a CallbackResources,
render_pass: &mut RenderPass<'static>,
callback_resources: &CallbackResources,
) {
vsvg::trace_scope!("wgpu paint callback");

Expand Down
12 changes: 6 additions & 6 deletions crates/vsvg-viewer/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ impl LayerPainters {
}
}

fn paint<'rp>(
&'rp self,
layer_data: &'rp LayerRenderData,
fn paint(
&self,
layer_data: &LayerRenderData,
display_options: DisplayOptions,
render_objects: &'rp EngineRenderObjects,
render_pass: &mut wgpu::RenderPass<'rp>,
render_objects: &EngineRenderObjects,
render_pass: &mut wgpu::RenderPass<'static>,
) {
vsvg::trace_function!();

Expand Down Expand Up @@ -365,7 +365,7 @@ impl Engine {
}
}

pub(super) fn paint<'rp>(&'rp self, render_pass: &mut wgpu::RenderPass<'rp>) {
pub(super) fn paint(&self, render_pass: &mut wgpu::RenderPass<'static>) {
vsvg::trace_function!();

if let Some(page_size_painter_data) = &self.page_size_painter_data {
Expand Down
3 changes: 3 additions & 0 deletions crates/vsvg-viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub mod exports {
pub use ::eframe;
pub use ::egui;
pub use ::wgpu;

#[cfg(target_arch = "wasm32")]
pub use ::web_sys;
}

/// Viewer app for [`show()`] and [`show_tolerance()`].
Expand Down
11 changes: 6 additions & 5 deletions crates/vsvg-viewer/src/painters/basic_painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl BasicPainter {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
cache: None,
});

Self { render_pipeline }
Expand All @@ -134,11 +135,11 @@ impl BasicPainter {

impl Painter for BasicPainter {
type Data = BasicPainterData;
fn draw<'a>(
&'a self,
rpass: &mut RenderPass<'a>,
camera_bind_group: &'a wgpu::BindGroup,
data: &'a Self::Data,
fn draw(
&self,
rpass: &mut RenderPass<'static>,
camera_bind_group: &wgpu::BindGroup,
data: &Self::Data,
) {
rpass.set_pipeline(&self.render_pipeline);
rpass.set_bind_group(0, camera_bind_group, &[]);
Expand Down
11 changes: 6 additions & 5 deletions crates/vsvg-viewer/src/painters/line_painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ impl LinePainter {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
cache: None,
});

Self { render_pipeline }
Expand All @@ -246,11 +247,11 @@ impl LinePainter {
impl Painter for LinePainter {
type Data = LinePainterData;

fn draw<'a>(
&'a self,
rpass: &mut RenderPass<'a>,
camera_bind_group: &'a wgpu::BindGroup,
data: &'a LinePainterData,
fn draw(
&self,
rpass: &mut RenderPass<'static>,
camera_bind_group: &wgpu::BindGroup,
data: &LinePainterData,
) {
rpass.set_pipeline(&self.render_pipeline);
rpass.set_bind_group(0, camera_bind_group, &[]);
Expand Down
10 changes: 5 additions & 5 deletions crates/vsvg-viewer/src/painters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub(crate) use point_painter::{PointPainter, PointPainterData};
pub(crate) trait Painter {
type Data;

fn draw<'a>(
&'a self,
rpass: &mut RenderPass<'a>,
camera_bind_group: &'a wgpu::BindGroup,
data: &'a Self::Data,
fn draw(
&self,
rpass: &mut RenderPass<'static>,
camera_bind_group: &wgpu::BindGroup,
data: &Self::Data,
);
}

Expand Down
10 changes: 5 additions & 5 deletions crates/vsvg-viewer/src/painters/page_size_painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ impl PageSizePainter {
impl Painter for PageSizePainter {
type Data = PageSizePainterData;

fn draw<'a>(
&'a self,
rpass: &mut RenderPass<'a>,
camera_bind_group: &'a BindGroup,
data: &'a Self::Data,
fn draw(
&self,
rpass: &mut RenderPass<'static>,
camera_bind_group: &BindGroup,
data: &Self::Data,
) {
self.background_and_shadow_painter
.draw(rpass, camera_bind_group, &data.shadow);
Expand Down
11 changes: 6 additions & 5 deletions crates/vsvg-viewer/src/painters/point_painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl PointPainter {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
cache: None,
});

Self { render_pipeline }
Expand All @@ -136,11 +137,11 @@ impl PointPainter {
impl Painter for PointPainter {
type Data = PointPainterData;

fn draw<'a>(
&'a self,
rpass: &mut RenderPass<'a>,
camera_bind_group: &'a wgpu::BindGroup,
data: &'a Self::Data,
fn draw(
&self,
rpass: &mut RenderPass<'static>,
camera_bind_group: &wgpu::BindGroup,
data: &Self::Data,
) {
rpass.set_pipeline(&self.render_pipeline);
rpass.set_bind_group(0, camera_bind_group, &[]);
Expand Down
2 changes: 1 addition & 1 deletion crates/vsvg-viewer/src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Viewer {
viewer_app: Box<dyn ViewerApp>,

#[cfg(puffin)]
profiler: crate::profiler::Profiler,
profiler: Profiler,
}

impl Viewer {
Expand Down
10 changes: 1 addition & 9 deletions crates/vsvg-viewer/src/web_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct WebHandle {
impl WebHandle {
pub async fn start(
&self,
canvas_id: &str,
canvas_id: web_sys::HtmlCanvasElement,
app: impl crate::ViewerApp + 'static,
) -> Result<(), JsValue> {
self.runner
Expand Down Expand Up @@ -48,14 +48,6 @@ impl WebHandle {
self.runner.destroy();
}

// /// Example on how to call into your app from JavaScript.
// #[wasm_bindgen]
// pub fn example(&self) {
// if let Some(_app) = self.runner.app_mut::<WrapApp>() {
// // _app.example();
// }
// }

/// The JavaScript can check whether your app has crashed:
#[must_use]
#[wasm_bindgen]
Expand Down
15 changes: 10 additions & 5 deletions crates/vsvg/src/svg/inkscape_layer_preprocessor.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use quick_xml::events::attributes::{AttrError, Attribute};
use quick_xml::events::{BytesStart, Event};
use quick_xml::name::QName;
use quick_xml::{Reader, Writer};
use std::io::Cursor;
use std::sync::atomic::{AtomicU64, Ordering};

use quick_xml::{
events::{
attributes::{AttrError, Attribute},
BytesStart, Event,
},
name::QName,
Reader, Writer,
};

static UNIQUE_ID: AtomicU64 = AtomicU64::new(0);

#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -107,7 +112,7 @@ impl GroupInfo {

pub(crate) fn preprocess_inkscape_layer(xml: &str) -> Result<String, InkscapeExtPreprocessorError> {
let mut reader = Reader::from_str(xml);
reader.trim_text(true);
reader.config_mut().trim_text(true);
let mut writer = Writer::new(Cursor::new(Vec::new()));
loop {
match reader.read_event() {
Expand Down
7 changes: 5 additions & 2 deletions crates/vsvg/src/ui/list_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,11 @@ impl<'a> ListItem<'a> {
.hovered()
{
if let Some(buttons) = self.buttons_fn {
let mut ui =
ui.child_ui(rect, egui::Layout::right_to_left(egui::Align::Center), None);
let mut ui = ui.new_child(
egui::UiBuilder::new()
.max_rect(rect)
.layout(egui::Layout::right_to_left(egui::Align::Center)),
);
Some(buttons(&mut ui))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion crates/vsvg/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn unit_combo_box(
unit_choices: &[crate::Unit],
) -> bool {
let mut changed = false;
egui::ComboBox::from_id_source(id_source)
egui::ComboBox::from_id_salt(id_source)
.selected_text(unit.to_str())
.width(50.)
.show_ui(ui, |ui| {
Expand Down
15 changes: 9 additions & 6 deletions crates/whiskers-web-demo/web/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<script defer data-domain="whisk.rs" data-api="https://sta.abeyeler.workers.dev/sta/event" src="https://sta.abeyeler.workers.dev/sta/script.js"></script>
<script defer data-domain="whisk.rs" data-api="https://sta.abeyeler.workers.dev/sta/event"
src="https://sta.abeyeler.workers.dev/sta/script.js"></script>

<!-- Disable zooming: -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
Expand Down Expand Up @@ -45,9 +46,11 @@
margin-left: auto;
display: block;
position: absolute;
top: 0%;
left: 50%;
transform: translate(-50%, 0%);
/* see: https://github.com/emilk/egui/issues/4699 */
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.centered {
Expand Down Expand Up @@ -167,7 +170,7 @@

check_for_panic();

wasm_bindgen.start(handle, "the_canvas_id").then(on_app_started).catch(on_error);
wasm_bindgen.start(handle, document.getElementById("the_canvas_id")).then(on_app_started).catch(on_error);
}

function on_app_started(handle) {
Expand Down
2 changes: 1 addition & 1 deletion crates/whiskers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ macro_rules! wasm_sketch {
#[wasm_bindgen::prelude::wasm_bindgen]
pub async fn start(
handle: &vsvg_viewer::web_handle::WebHandle,
canvas_id: &str,
canvas_id: vsvg_viewer::exports::web_sys::HtmlCanvasElement,
) -> std::result::Result<(), wasm_bindgen::JsValue> {
handle.start(canvas_id, $t).await
}
Expand Down
2 changes: 1 addition & 1 deletion crates/whiskers/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<A: crate::SketchApp> vsvg_viewer::ViewerApp for Runner<'_, A> {
ui.visuals_mut().collapsing_header_frame = true;

egui::ScrollArea::vertical()
.id_source("side_bar_scroll")
.id_salt("side_bar_scroll")
.show(ui, |ui| {
// let the UI breeze a little bit

Expand Down
2 changes: 1 addition & 1 deletion crates/whiskers/src/runner/page_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl PageSizeOptions {
ui.horizontal(|ui| {
ui.label("format:");

egui::ComboBox::from_id_source("sketch_page_size")
egui::ComboBox::from_id_salt("sketch_page_size")
.selected_text(new_page_size.to_format().unwrap_or("Custom"))
.width(120.)
.show_ui(ui, |ui| {
Expand Down
4 changes: 2 additions & 2 deletions crates/whiskers/src/runner/save_ui_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ fn download_file(name: &str, content: &str) -> Option<()> {
a.style().set_property("display", "none").ok()?;
body.append_child(&a).ok()?;

let mut blob_options = BlobPropertyBag::new();
blob_options.type_("image/svg+xml;charset=utf-8");
let blob_options = BlobPropertyBag::new();
blob_options.set_type("image/svg+xml;charset=utf-8");

let blob_sequence = js_sys::Array::new_with_length(1);
blob_sequence.set(0, JsValue::from(content));
Expand Down
Loading