mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 09:54:09 +01:00
train: #8559
This commit is contained in:
commit
fcd178c105
2 files changed
+15
-1
No files matched your search
@@ -1412,11 +1412,17 @@ fn object_behind(cx: &ToolContext, p: Point) -> Option<NodeId> {
|
||||
/// object selected whole between it and the art under the pointer, such as members of a group
|
||||
/// picked with Group Selection. A press there keeps the selection and a drag moves it (#8047). A
|
||||
/// member with only some anchors or segments selected does not count: the press selects `top`.
|
||||
/// A member with every anchor selected (as `select.anchors` and `select.key` leave a path) counts.
|
||||
fn selected_under(cx: &ToolContext, h: &Hit, top: NodeId) -> Option<NodeId> {
|
||||
if cx.selection.contains(top) {
|
||||
return Some(top);
|
||||
}
|
||||
let whole = |id: NodeId| cx.selection.contains(id) && cx.selection.partial(id).is_none() && !cx.selection.segments.contains_key(&id);
|
||||
let every_anchor = |id: NodeId| {
|
||||
cx.selection
|
||||
.partial(id)
|
||||
.is_none_or(|picked| cx.doc.node(id).and_then(|n| n.path_data()).is_some_and(|p| p.anchors().all(|(s, i, _)| picked.contains(&(s, i)))))
|
||||
};
|
||||
let whole = |id: NodeId| cx.selection.contains(id) && every_anchor(id) && !cx.selection.segments.contains_key(&id);
|
||||
let below = h.ancestry.iter().position(|id| *id == top).map_or(&[][..], |i| h.ancestry.get(i..).unwrap_or_default());
|
||||
below.iter().copied().chain(std::iter::once(h.leaf)).find(|id| whole(*id))
|
||||
}
|
||||
|
||||
@@ -2889,4 +2889,12 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() {
|
||||
let c = cx(&d, &s, &p);
|
||||
let down = SelectionTool::default().pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
|
||||
assert_eq!(down, vec![Action::Exec("select.set".into(), json!({"ids": [outer.0]}))]);
|
||||
// Every anchor of the member picked (as `select.anchors` and `select.key` leave it) selects
|
||||
// it whole: the press moves it.
|
||||
s.anchors.insert(a, [(0, 0), (0, 1), (0, 2), (0, 3)].into_iter().collect());
|
||||
let c = cx(&d, &s, &p);
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "every anchor");
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
|
||||
assert!(!is_select(&down), "every anchor: {down:?}");
|
||||
}
|
||||
Reference in new issue
Block a user