Shape tools: Backtick held at the press measures the first copy from there

A drag that starts with Backtick already down set the copy spacing origin at the first drag event, so a short first stretch of the drag could leave no copy. The press now sets it.
This commit is contained in:
dotCooCoo
2026-11-16 05:34:43 -08:00
parent 9ecc8087c3
commit 69b4f3ae96
2 changed files with 19 additions and 0 deletions
+4
View File
@@ -676,6 +676,10 @@ impl Tool for ShapeTool {
self.inner = None;
self.before_drag = None;
self.clear_copies();
// Backtick already held at the press: the copies are measured from there.
if ev.backquote {
self.copy_from = Some(ev.pos);
}
vec![]
}
PointerKind::Drag => {
+15
View File
@@ -1433,6 +1433,21 @@ fn backtick_drag_leaves_copies_of_the_rectangle_being_drawn() {
assert_eq!(previewed_widths(&t.pointer(&c, &quote_drag(50.0, 30.0, false))), (false, vec![40.0]));
}
/// Backtick already held at the press measures the first copy from the pressed spot: the first
/// drag 10 pt away leaves one, and 5 pt more leaves none.
#[test]
fn backtick_held_at_the_press_measures_copies_from_there() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let mut t = ShapeTool::new("rectangle");
t.pointer(&c, &PointerEvent { backquote: true, ..PointerEvent::new(PointerKind::Down, 0.0, 0.0) });
assert_eq!(previewed_widths(&t.pointer(&c, &quote_drag(10.0, 10.0, true))), (true, vec![10.0]));
assert_eq!(previewed_widths(&t.pointer(&c, &quote_drag(15.0, 10.0, true))), (true, vec![10.0, 15.0]));
assert_eq!(t.pointer(&c, &PointerEvent { backquote: true, ..PointerEvent::new(PointerKind::Up, 15.0, 10.0) }), vec![Action::Commit]);
}
/// Every shape tool leaves copies of its own shape, drawn with the modifiers held when each copy
/// was left: Shift's square stays square, and Alt's from the centre stays centred.
#[test]