DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Direct Selection on a selected frame selects its image, so Delete keeps the frame
moppeeera04c805ad72d
diff --git a/ROADMAP.md b/ROADMAP.mdindex 2aacdaf9b..46f5907bf 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -347,6 +347,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-16** · A Direct Selection click on an image whose frame is already selected selects the image, so Delete removes only the image and leaves the empty frame, as in InDesign. No readiness percentage change.- **2026-10-14** · The Type tool draws a new text frame over a locked empty frame, as InDesign does, instead of turning the locked frame into a text frame. No readiness percentage change.- **2026-10-14** · 100% black shows as pure black on screen by default, as InDesign's Appearance of Black does out of the box (Display All Blacks as Rich Black); Preferences › Appearance of Black › Display All Blacks Accurately still shows it as the dark grey it prints, and a saved choice is kept. No readiness percentage change.- **2026-10-14** · Pathfinder keeps the frontmost object, as InDesign does: a photo placed over shapes and intersected with them shows through the shapes (it was dropped, and the shapes kept their black fill); Add, Exclude Overlap and Minus Back take the front object's fill too, Subtract still keeps the back one. No readiness percentage change.diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rsindex 616a86398..cdce8b218 100644--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@ -1110,3 +1110,34 @@ fn a_line_fits_when_its_baseline_does() {assert!(!overset(&mut s, 78.5), "the line is set; its descenders hang below the frame");assert!(overset(&mut s, 50.0), "a baseline below the frame still oversets the line");}++#[test]+fn direct_selection_on_a_selected_frame_deletes_only_its_image() {+ use designcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey};+ let dir = std::env::temp_dir().join(format!("dc-direct-delete-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let png = dir.join("photo.png");+ std::fs::write(&png, designcraft_render::Rendered { width: 100, height: 100, pixels: vec![40u8; 100 * 100 * 4] }.to_png()).unwrap();+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let frame = s.execute("frame.create", &json!({"rect": [100, 100, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ s.execute("file.place", &json!({"path": png.to_string_lossy(), "frame": frame})).unwrap();+ let v = ViewInfo::at_zoom(1.0);+ let click = |s: &mut Session| {+ s.pointer(&PointerEvent::new(PointerKind::Down, 150.0, 150.0), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Up, 150.0, 150.0), v).unwrap();+ };+ // The frame is selected with the Selection tool, then the image is clicked with Direct Selection.+ s.set_tool("selection");+ click(&mut s);+ assert!(!s.doc().unwrap().selection.content);+ s.set_tool("directSelection");+ click(&mut s);+ assert!(s.doc().unwrap().selection.content, "Direct Selection selects the image inside the selected frame");+ assert!(s.tool_key(ToolKey::Delete, Mods::default(), v).unwrap());+ let st = s.doc().unwrap();+ let it = st.doc.item(designcraft_doc::ItemId(frame)).expect("the frame stays");+ assert!(matches!(it.content, designcraft_doc::Content::Unassigned), "{:?}", it.content);+ assert_eq!(st.selection.items, vec![designcraft_doc::ItemId(frame)]);+ let _ = std::fs::remove_dir_all(&dir);+}diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rsindex 10da23f85..b66f0a0bd 100644--- a/crates/tools/src/select.rs+++ b/crates/tools/src/select.rs@@ -225,6 +225,11 @@ pub fn handles(r: Rect) -> [Point; 8] {]}+/// The item is a frame holding a placed graphic.+fn has_graphic(cx: &ToolContext, id: ItemId) -> bool {+ cx.doc.item(id).is_some_and(|it| matches!(it.content, designcraft_doc::Content::Graphic(_)))+}+fn handle_at(cx: &ToolContext, p: Point) -> Option<usize> {let b = cx.selection_bounds()?;let tol = cx.tol(5.0);@@ -538,7 +543,8 @@ impl Tool for SelectionTool {} else {out.push(Action::Exec("selection.toggle".into(), json!({"id": id.0})));}- } else if !cx.selection.contains(id) {+ } else if !cx.selection.contains(id) || (self.direct && !cx.selection.content && has_graphic(cx, id)) {+ // Direct Selection on a selected frame selects the graphic inside it.out.push(Action::Exec("selection.set".into(), json!({"ids": [id.0], "content": self.direct})));}self.drag = Drag::Pending { start: p, hit: true };