From 3f7959b536aacd20a36280aa47a80f56e5adbc52 Mon Sep 17 00:00:00 2001 From: Nathan Charles Date: Tue, 20 Oct 2026 12:34:23 +0000 Subject: [PATCH] Canvas and Decal: the file picker opens on PNG and JPEG images (#3266) * Canvas and Decal: the file picker opens on PNG and JPEG images canvas.insert and canvas.decal opened the general Open dialog with no file type, so it started on "Designs, CAD files and meshes" and PNG/JPEG files were greyed out. Offer the image types first, as Insert SVG/DXF do (#1801). * Canvas and Decal: rustfmt the file-picker test --- crates/ui-egui/src/file_picker.rs | 8 +++++++- crates/ui-egui/src/sketch_tools.rs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/file_picker.rs b/crates/ui-egui/src/file_picker.rs index afd683ddd..56d0dcf59 100644 --- a/crates/ui-egui/src/file_picker.rs +++ b/crates/ui-egui/src/file_picker.rs @@ -310,7 +310,13 @@ mod tests { Box::pin(std::future::ready(None)) })); h.app.run("sketch.create", json!({"plane": "XY"})).unwrap(); - for (command, want) in [("sketch.insert_svg", vec!["svg"]), ("sketch.insert_dxf", vec!["dxf"]), ("file.insert_step", vec![])] { + for (command, want) in [ + ("sketch.insert_svg", vec!["svg"]), + ("sketch.insert_dxf", vec!["dxf"]), + ("file.insert_step", vec![]), + ("canvas.insert", vec!["png", "jpg", "jpeg"]), + ("canvas.decal", vec!["png", "jpg", "jpeg"]), + ] { h.app.start(command); tick(&mut h.app, &h.ctx); assert_eq!(asked.borrow().last().cloned(), Some(want.iter().map(|e| e.to_string()).collect::>()), "{command}"); diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs index 1e9b987df..bedd33883 100644 --- a/crates/ui-egui/src/sketch_tools.rs +++ b/crates/ui-egui/src/sketch_tools.rs @@ -276,7 +276,8 @@ pub fn start_hook(app: &mut SolveApp, id: &str) -> bool { return true; } let command = id.to_string(); - app.pick_open(move |app, path| { + // Offer the image types first: the default Open filter lists only designs and meshes. + app.pick_open_for(&["png", "jpg", "jpeg"], move |app, path| { if let Some(path) = path { IMAGE.with(|i| *i.borrow_mut() = Some(path)); app.last_command = solidcraft_engine::find_command(&command).map(|spec| (spec.id.into(), spec.label.into()));