Upgrade egui and eframe to 0.31 and update all other dependencies

This commit is contained in:
2025-05-30 11:25:40 -04:00
parent a8340a3fb9
commit ab8abd635b
10 changed files with 2075 additions and 1069 deletions

View File

@@ -104,7 +104,7 @@ impl eframe::App for TemplateApp {
self.plots.render_menu_buttons(ui);
ui.add_space(16.0);
egui::widgets::global_dark_light_mode_buttons(ui);
egui::widgets::global_theme_preference_buttons(ui);
});
});

View File

@@ -82,9 +82,12 @@ impl DebugPlots {
match plot {
PlotData::U8(v) => {
ui.heading("u8 Plot");
let line = Line::new(PlotPoints::from_iter(
v.iter().enumerate().map(|(i, y)| [i as f64, *y as f64]),
));
let line = Line::new(
"Data",
PlotPoints::from_iter(
v.iter().enumerate().map(|(i, y)| [i as f64, *y as f64]),
),
);
let plot = Plot::new(title);
plot.show(ui, |plot_ui| {
plot_ui.line(line);
@@ -96,7 +99,7 @@ impl DebugPlots {
}
PlotData::F32(v) => {
ui.heading("f32 plot");
let line = Line::new(PlotPoints::from_ys_f32(&v));
let line = Line::new("Data", PlotPoints::from_ys_f32(&v));
let plot = Plot::new(title);
plot.show(ui, |plot_ui| {
plot_ui.line(line);
@@ -108,18 +111,23 @@ impl DebugPlots {
}
PlotData::Bode32(v) => {
ui.heading("Bode Plot");
let mag_line =
Line::new(PlotPoints::from_iter(v.iter().enumerate().map(|(i, c)| {
let mag_line = Line::new(
"Magnitude",
PlotPoints::from_iter(v.iter().enumerate().map(|(i, c)| {
[
i as f64,
((c.re * c.re) + (c.im * c.im)).sqrt() as f64 / v.len() as f64,
]
})));
let phase_line = Line::new(PlotPoints::from_iter(
v.iter()
.enumerate()
.map(|(i, c)| [i as f64, c.arg() as f64 / core::f64::consts::PI]),
));
})),
);
let phase_line = Line::new(
"Phase",
PlotPoints::from_iter(
v.iter()
.enumerate()
.map(|(i, c)| [i as f64, c.arg() as f64 / core::f64::consts::PI]),
),
);
let plot = Plot::new(title);
plot.show(ui, |plot_ui| {
plot_ui.line(mag_line);

View File

@@ -30,7 +30,7 @@ unsafe fn clear_texture(gl: &glow::Context, bytes_per_row: usize, n_rows: usize)
1,
glow::RED,
glow::UNSIGNED_BYTE,
PixelUnpackData::Slice(&blank_line),
PixelUnpackData::Slice(Some(&blank_line)),
);
check_for_gl_errors(&gl, &format!("clear texture with offset {}", offset));
}
@@ -100,7 +100,7 @@ impl Waterfall {
1,
glow::RED,
glow::UNSIGNED_BYTE,
PixelUnpackData::Slice(&fft),
PixelUnpackData::Slice(Some(&fft)),
);
check_for_gl_errors(&gl, &format!("update texture with offset {}", self.offset));
self.offset = (self.offset + 1) % self.height;
@@ -215,7 +215,7 @@ impl Waterfall {
glow::RED,
glow::UNSIGNED_BYTE,
//Some(&buffer), // This segfaults with large buffers
None,
PixelUnpackData::Slice(None),
);
check_for_gl_errors(&gl, "Initializing Texture");
@@ -246,7 +246,7 @@ impl Waterfall {
0,
glow::RGB,
UNSIGNED_BYTE,
Some(&turbo_colormap::TURBO_SRGB_BYTES),
PixelUnpackData::Slice(Some(&turbo_colormap::TURBO_SRGB_BYTES)),
);
check_for_gl_errors(&gl, "Initializing LUT");

View File

@@ -7,7 +7,10 @@ mod backend;
#[no_mangle]
fn android_main(app: winit::platform::android::activity::AndroidApp) {
use winit::platform::android::activity::WindowManagerFlags;
use winit::platform::android::EventLoopBuilderExtAndroid;
android_logger::init_once(
android_logger::Config::default().with_max_level(log::LevelFilter::Debug),
);
// Disable LAYOUT_IN_SCREEN to keep app from drawing under the status bar
// winit does not currently do anything with MainEvent::InsetsChanged events
@@ -18,18 +21,15 @@ fn android_main(app: winit::platform::android::activity::AndroidApp) {
// Alternatively we can hide the system bars by setting the app to fullscreen
//app.set_window_flags(WindowManagerFlags::FULLSCREEN, WindowManagerFlags::empty());
android_logger::init_once(
android_logger::Config::default().with_max_level(log::LevelFilter::Debug),
);
let mut options = eframe::NativeOptions::default();
options.event_loop_builder = Some(Box::new(move |builder| {
builder.with_android_app(app);
}));
let options = eframe::NativeOptions {
android_app: Some(app),
..Default::default()
};
let res = eframe::run_native(
"eframe template",
options,
Box::new(|cc| Box::new(app::TemplateApp::new(cc))),
Box::new(|cc| Ok(Box::new(app::TemplateApp::new(cc)))),
);
if let Err(e) = res {
log::error!("{e:?}");

View File

@@ -23,26 +23,53 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"eframe template",
native_options,
Box::new(|cc| Box::new(TemplateApp::new(cc))),
Box::new(|cc| Ok(Box::new(TemplateApp::new(cc)))),
)
}
// When compiling to web using trunk:
#[cfg(target_arch = "wasm32")]
fn main() {
use eframe::wasm_bindgen::JsCast as _;
// Redirect `log` message to `console.log` and friends:
eframe::WebLogger::init(log::LevelFilter::Debug).ok();
let web_options = eframe::WebOptions::default();
wasm_bindgen_futures::spawn_local(async {
eframe::WebRunner::new()
let document = web_sys::window()
.expect("No window")
.document()
.expect("No document");
let canvas = document
.get_element_by_id("the_canvas_id")
.expect("Failed to find the_canvas_id")
.dyn_into::<web_sys::HtmlCanvasElement>()
.expect("the_canvas_id was not a HtmlCanvasElement");
let start_result = eframe::WebRunner::new()
.start(
"the_canvas_id", // hardcode it
canvas,
web_options,
Box::new(|cc| Box::new(TemplateApp::new(cc))),
Box::new(|cc| Ok(Box::new(TemplateApp::new(cc)))),
)
.await
.expect("failed to start eframe");
.await;
// Remove the loading text and spinner:
if let Some(loading_text) = document.get_element_by_id("loading_text") {
match start_result {
Ok(_) => {
loading_text.remove();
}
Err(e) => {
loading_text.set_inner_html(
"<p> The app has crashed. See the developer console for details. </p>",
);
panic!("Failed to start eframe: {e:?}");
}
}
}
});
}