mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-23 02:44:24 +01:00
Width tool: an Alt-double-click on one of several selected points edits them all
An Alt-press on a width point's center narrows the selection to that point, ready to drag a copy. A release without a drag kept it narrowed and did not remember the earlier selection, so an Alt-double-click on one of several selected points opened Width Point Edit for that point alone, where a plain double-click opens it for all of them. A release without a drag now remembers the earlier selection as a plain click does, and an Alt-drag still copies only the point under the pointer.
This commit is contained in:
1 parent
c86bb07a44
commit
94f4d54b04
1 file changed
+27
@@ -494,6 +494,18 @@ impl Tool for WidthTool {
|
||||
// Points moved together stay selected.
|
||||
(true, _, Some((id, ts))) if d.mode == Mode::Move => Some((id, ts.into_iter().map(|t| (t + dt).clamp(0.0, 1.0)).collect())),
|
||||
(true, _, sel) => sel,
|
||||
// An Alt-click without a drag copies nothing: like a plain click on one of
|
||||
// several selected points, it lets a double-click edit them all.
|
||||
(false, false, _) if d.mode == Mode::Copy && !ev.mods.shift => {
|
||||
if let Some(sel) = self
|
||||
.before_press
|
||||
.clone()
|
||||
.filter(|(owner, ts)| *owner == d.spot.owner && ts.len() > 1 && ts.iter().any(|t| (t - d.spot.t).abs() <= SAME_T))
|
||||
{
|
||||
self.before_click = Some((sel, false));
|
||||
}
|
||||
Some((d.spot.owner, vec![d.t]))
|
||||
}
|
||||
(false, _, _) => Some((d.spot.owner, vec![d.t])),
|
||||
};
|
||||
vec![Action::Commit]
|
||||
@@ -1107,6 +1119,21 @@ mod tests {
|
||||
assert!(v.get("indices").is_none());
|
||||
assert_eq!(t.selected_indices(&c, id), vec![2]);
|
||||
}
|
||||
// With Alt held, a double-click without a drag edits every selected point too.
|
||||
let alt = Mods { alt: true, ..Default::default() };
|
||||
let mut t = WidthTool::default();
|
||||
click(&mut t, 150.0, none);
|
||||
click(&mut t, 250.0, shift);
|
||||
let v = double_click(&mut t, 250.0, alt);
|
||||
assert_eq!((&v["indices"], v.get("index")), (&json!([1, 3]), None));
|
||||
assert_eq!(t.selected_indices(&c, id), vec![1, 3], "the selection is kept");
|
||||
// An Alt-drag still copies the one point under the pointer, and selects the copy alone.
|
||||
t.pointer(&c, &ev(PointerKind::Down, 250.0, 200.0, alt));
|
||||
let acts = t.pointer(&c, &ev(PointerKind::Drag, 270.0, 200.0, alt));
|
||||
let (cmd, v) = preview(&acts);
|
||||
assert_eq!((cmd, &v["index"]), ("stroke.widthPoint.copy", &json!(3)));
|
||||
t.pointer(&c, &ev(PointerKind::Up, 270.0, 200.0, alt));
|
||||
assert_eq!(t.selected.as_ref().map(|(_, ts)| ts.len()), Some(1));
|
||||
// A discontinuous point among them keeps both halves, and double-clicking it keeps the others.
|
||||
let (mut d2, _) = doc_line();
|
||||
let points = vec![(0.0, 1.0, 1.0), (0.25, 1.0, 1.0), (0.5, 1.0, 1.0), (0.5, 2.0, 2.0), (0.75, 1.0, 1.0), (1.0, 1.0, 1.0)];
|
||||
|
||||
Reference in new issue
Block a user