mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 22:27:08 +00:00
Quick Pen: a length drag that keeps the length records no undo step
A drag across a line's length handle leaves the line's length as it was. It started an interaction and previewed the path anyway, so letting go recorded an undo step for an unchanged path. The drag now previews nothing until the length changes.
This commit is contained in:
@@ -762,6 +762,27 @@ fn a_length_drag_stays_on_the_canvas() {
|
||||
assert_eq!(only_path(&s).anchors.len(), 3, "the drawing went on");
|
||||
}
|
||||
|
||||
/// A length drag across a line, which leaves its length as it was, changes nothing and records no
|
||||
/// undo step, on the path being drawn and on a selected path.
|
||||
#[test]
|
||||
fn a_length_drag_that_keeps_the_length_records_no_undo_step() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
click(&mut s, 200.0, 100.0);
|
||||
let undo = undo_steps(&s);
|
||||
let before = only_path(&s);
|
||||
// The end handle is at (220, 100); the drag goes straight down from it.
|
||||
press(&mut s, &[(220.0, 100.0), (220.0, 160.0)]);
|
||||
assert_eq!(only_path(&s), before);
|
||||
assert_eq!(undo_steps(&s), undo);
|
||||
key(&mut s, ToolKey::Escape);
|
||||
let undo = undo_steps(&s);
|
||||
press(&mut s, &[(220.0, 100.0), (220.0, 160.0)]);
|
||||
assert_eq!(only_path(&s), before);
|
||||
assert_eq!(undo_steps(&s), undo);
|
||||
}
|
||||
|
||||
/// The paths of a selected compound path show length handles, also after a drag selected the
|
||||
/// compound again.
|
||||
#[test]
|
||||
|
||||
@@ -717,7 +717,9 @@ impl QuickPenTool {
|
||||
if !changed.is_some_and(|sp| on_canvas(&sp)) {
|
||||
return vec![];
|
||||
}
|
||||
if drag.begun && (length - drag.length).abs() <= 1e-12 * length.max(1.0) {
|
||||
// A length the end already has changes nothing: no preview, and no undo step before the
|
||||
// first change.
|
||||
if (length - drag.length).abs() <= 1e-12 * length.max(1.0) {
|
||||
return vec![];
|
||||
}
|
||||
let mut out = vec![];
|
||||
|
||||
Reference in New Issue
Block a user