Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: #902 Direct Selection anchor pull selects the frame, not its content

aiongg55fb94242e7b
diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs
index 16ccbad0c..7f4c75780 100644
--- a/crates/tools/src/select.rs
+++ b/crates/tools/src/select.rs
@@ -714,7 +714,7 @@ impl SelectionTool {
{
let at = anchor_spread_point(cx, id, si, ai);
self.drag = Drag::Anchor { id, si, ai, handle: None, start: p, at };
- return vec![Action::Exec("selection.set".into(), json!({"ids": [id], "content": true})), Action::Begin("Move Anchor".into())];
+ return vec![Action::Exec("selection.set".into(), json!({"ids": [id], "content": false})), Action::Begin("Move Anchor".into())];
}
// A selected placed graphic's own handles resize it inside its frame (the
// frame's anchors, under Direct Selection, come first).
diff --git a/crates/tools/src/tests.rs b/crates/tools/src/tests.rs
index 03a19c73a..c216277aa 100644
--- a/crates/tools/src/tests.rs
+++ b/crates/tools/src/tests.rs
@@ -2082,3 +2082,18 @@ fn direct_selection_click_on_one_of_several_selected_frames_selects_only_it() {
let acts = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, p.x, p.y));
assert_eq!(acts, vec![Action::Exec("selection.set".into(), serde_json::json!({"ids": [a.0], "content": true}))]);
}
+
+#[test]
+fn pulling_a_corner_of_an_unselected_frame_selects_the_frame_not_its_content() {
+ let mut d = Document::new(&NewDocument::default());
+ let a = add_rect(&mut d, Rect::new(100.0, 100.0, 200.0, 200.0));
+ let (s, c, l) = (Selection::default(), Cache::new(), CanvasLayout::new(&d, false));
+ let cx = ctx(&d, &s, &c, &l);
+ let p = spread_pt(&l, 200.0, 100.0);
+ let mut t = create("directSelection");
+ let acts = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, p.x, p.y));
+ assert_eq!(
+ acts,
+ vec![Action::Exec("selection.set".into(), serde_json::json!({"ids": [a.0], "content": false})), Action::Begin("Move Anchor".into())]
+ );
+}