Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Canvas and Decal: the file picker opens on PNG and JPEG images (#3266)

Nathan Charles3f7959b536aa
diff --git a/crates/ui-egui/src/file_picker.rs b/crates/ui-egui/src/file_picker.rs
index afd683ddd0..56d0dcf59a 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::<Vec<_>>()), "{command}");
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index 1e9b987df2..bedd33883b 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()));