Shape Builder: the status bar says why a click or drag built nothing

A Shape Builder gesture that builds nothing now says why when it is
released: "select paths or compound paths" when nothing usable is
selected, "select all paths you want to merge" when the pointer is over
a path or compound path outside the selection, and "no region under the
pointer" otherwise. The message changes nothing in the document, the
selection or the undo history, and the next gesture that builds
something clears it. A gesture made while a large selection's map is
being built gives its message once, when it is replayed.

Tools get Action::Status, which the session passes to the status bar;
the new message has a row in every complete-message catalog.
This commit is contained in:
dotCooCoo
2026-11-16 05:05:16 -08:00
parent 7452b6f383
commit edecf9bf41
31 changed files with 241 additions and 12 deletions
+33
View File
@@ -582,6 +582,39 @@ fn shape_builder_tool_drives_the_command() {
assert_eq!(layer_children(&s), 1);
}
/// A Shape Builder click that builds nothing puts the reason in the status bar and leaves the
/// document, its undo history and the selection as they were; a click that merges shows no status.
#[test]
fn shape_builder_click_that_builds_nothing_shows_why() {
use vectorcraft_tools::builder::{NO_REGION, SELECT_ALL_PATHS, SELECT_PATHS};
let mut s = session();
let (a, _) = two(&mut s);
let v = ViewInfo::default();
s.select_tool("shapeBuilder", v).unwrap();
let click = |s: &mut Session, x: f64, y: f64| {
s.pointer(&PointerEvent::new(PointerKind::Down, x, y), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Up, x, y), v).unwrap()
};
let state = |s: &Session| {
let st = s.doc().unwrap();
(st.revision, st.history.undo.len(), st.history.redo.len(), st.selection.objects.clone(), st.is_dirty())
};
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
let before = state(&s);
assert_eq!(click(&mut s, 125.0, 50.0), vec![UiRequest::Status(SELECT_ALL_PATHS.into())]);
assert_eq!(click(&mut s, 400.0, 400.0), vec![UiRequest::Status(NO_REGION.into())]);
assert_eq!(state(&s), before, "nothing changed");
s.execute("select.none", &json!({})).unwrap();
let before = state(&s);
assert_eq!(click(&mut s, 75.0, 50.0), vec![UiRequest::Status(SELECT_PATHS.into())]);
assert_eq!(state(&s), before, "nothing changed");
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
assert_eq!(click(&mut s, 75.0, 50.0), vec![UiRequest::Status(String::new())], "a click that merges clears the status");
assert_eq!(s.journal.last().unwrap().0, "shapeBuilder.merge");
assert!(click(&mut s, 25.0, 50.0).is_empty(), "the next merge shows no status");
assert_eq!(s.journal.last().unwrap().0, "shapeBuilder.merge");
}
/// A click of the Shape Builder merges over the map the tool built for the hover, as does the
/// command over the same inputs with the same gap; another gap needs a map of its own.
#[test]
+1
View File
@@ -1530,6 +1530,7 @@ impl Session {
}
Action::Dialog(k, p) => ui.push(UiRequest::Dialog(k, p)),
Action::SwitchTool(t) => ui.push(UiRequest::SwitchTool(t)),
Action::Status(msg) => ui.push(UiRequest::Status(msg)),
Action::Notify(what) => {
let view = self.last_view;
self.with_tool_cx(view, |t, cx| t.notify(cx, &what));