mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
Shapes: a Circle tool click near the first point leaves no circle shown
A second press within 3 screen points of the first point but not on it, let go where it was pressed, placed nothing but left the pointer at the press, so the tool showed a circle about 2 pt across until the pointer moved. Such a click now puts the pointer back on the first point.
This commit is contained in:
@@ -163,9 +163,20 @@ impl Tool for CircleTool {
|
||||
if ev.kind == PointerKind::Up {
|
||||
if self.drags(cx, ev) {
|
||||
self.pointer(cx, &PointerEvent { kind: PointerKind::Drag, ..*ev });
|
||||
} else if let Some(Press::First { at, dragged, .. } | Press::Second { at, dragged, .. }) = &mut self.press {
|
||||
*dragged = false;
|
||||
self.pointer = Some(*at);
|
||||
} else if let Some(press) = &mut self.press {
|
||||
let (at, on_first) = match press {
|
||||
Press::First { at, dragged, .. } => {
|
||||
*dragged = false;
|
||||
(*at, false)
|
||||
}
|
||||
Press::Second { at, on_first, dragged, .. } => {
|
||||
*dragged = false;
|
||||
(*at, *on_first)
|
||||
}
|
||||
};
|
||||
// A click on the first point places nothing: the pointer goes back to that point, so
|
||||
// the tool shows no circle.
|
||||
self.pointer = if on_first { self.first } else { Some(at) };
|
||||
self.snap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,23 @@ fn a_release_near_the_press_is_a_click_after_a_drag() {
|
||||
assert!(t.ends_on_escape(&cx));
|
||||
}
|
||||
|
||||
/// A click within 3 screen points of the first point, also one dragged away and let go where it
|
||||
/// was pressed, places nothing and leaves no circle shown.
|
||||
#[test]
|
||||
fn a_click_near_the_first_point_shows_no_circle() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let (s, p) = (Selection::default(), paint());
|
||||
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
|
||||
let mut t = CircleTool::default();
|
||||
click(&mut t, &cx, (300.0, 300.0));
|
||||
assert_eq!(drag(&mut t, &cx, (302.0, 300.0), &[(302.0, 380.0), (302.0, 300.0)], Mods::default()), vec![]);
|
||||
assert_eq!(preview(&t.overlays(&cx)), None);
|
||||
assert_eq!(click(&mut t, &cx, (302.0, 300.0)), vec![]);
|
||||
assert_eq!(preview(&t.overlays(&cx)), None);
|
||||
assert!(t.ends_on_escape(&cx), "the first point stays");
|
||||
assert_eq!(click(&mut t, &cx, (380.0, 360.0)), circle(&[(300.0, 300.0), (380.0, 360.0)]));
|
||||
}
|
||||
|
||||
/// A press on the first point, dragged to snap to the rectangle's corner anchor and let go near
|
||||
/// the press, leaves no guides of the drag.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user