Shape Builder: Pick Color From defaults to Color Swatches

While the Shape Builder is active, a fill picked from a swatch or a color
changes only the current fill, and the selected art keeps its own. With
Pick Color From set to Artwork, a merge takes the look of the art, so the
picked color never reached the merged shape and the tool looked as if it
could not fill.

Pick Color From now defaults to Color Swatches: a merge fills with the
picked color, and the Left and Right arrow keys step through the color
swatches. A pickColorFrom saved with the preferences is kept, so a saved
Artwork stays Artwork; preferences saved without one take Color Swatches.
The shapeBuilder.merge command still defaults to artwork when its
pickColorFrom is left out.

Docs: docs/mcp.md and the tool options params text.
This commit is contained in:
dotCooCoo
2026-11-29 17:43:37 -08:00
parent cdc14eb007
commit 8e68c5edcf
7 changed files with 65 additions and 11 deletions
+29 -1
View File
@@ -1753,7 +1753,8 @@ fn shape_builder_swatches_keep_the_current_fill_and_the_first_covered_objects_lo
}
/// The Shape Builder tool sends the point where the drag started first and the point where it
/// ended last, so a drag from the hole into the square takes the square's look.
/// ended last, so with Pick Color From Artwork a drag from the hole into the square takes the
/// square's look.
#[test]
fn shape_builder_tool_drag_from_the_hole_takes_the_look_where_it_ends() {
let mut s = session();
@@ -1762,6 +1763,7 @@ fn shape_builder_tool_drag_from_the_hole_takes_the_look_where_it_ends() {
select_ids(&mut s, &bars.iter().copied().chain([red]).collect::<Vec<_>>());
let v = ViewInfo::default();
s.select_tool("shapeBuilder", v).unwrap();
s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": {"pickColorFrom": "artwork"}})).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Down, 50.0, 50.0), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 85.0, 50.0), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 120.0, 50.0), v).unwrap();
@@ -1853,6 +1855,7 @@ fn shape_builder_arrow_keys_step_the_current_fill_through_the_swatches() {
let v = ViewInfo::default();
s.select_tool("shapeBuilder", v).unwrap();
let chips = |s: &mut Session| s.overlays(v).iter().filter(|o| matches!(o, vectorcraft_tools::Overlay::Swatch { .. })).count();
s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": {"pickColorFrom": "artwork"}})).unwrap();
assert!(!s.tool_claims_key(ToolKey::Right, v), "Artwork leaves the arrows to nudging");
let values = json!({"pickColorFrom": "swatches", "cursorSwatchPreview": true});
s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": values})).unwrap();
@@ -2071,6 +2074,31 @@ fn shape_builder_fill_preview_is_put_back_by_a_cancel() {
assert_eq!(s.paint.fill, before, "the cancel puts the fill back");
}
/// With the Shape Builder's default options, a fill picked while it is active (a swatch or a
/// color) fills the next merge: the tool sends `pickColorFrom: "swatches"`, and the merged shape
/// is not the red or blue of the art.
#[test]
fn shape_builder_default_merge_fills_with_the_picked_fill() {
let v = ViewInfo::default();
for pick in [json!({"swatch": "Leaf"}), json!({"color": "#ff8800"})] {
let mut s = session();
two(&mut s);
s.execute("swatch.new", &json!({"name": "Leaf", "color": "#00ff00"})).unwrap();
s.select_tool("shapeBuilder", v).unwrap();
s.execute("paint.setFill", &pick).unwrap();
let picked = s.paint.fill.clone();
s.pointer(&PointerEvent::new(PointerKind::Down, 25.0, 50.0), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 75.0, 50.0), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 125.0, 50.0), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Up, 125.0, 50.0), v).unwrap();
let (cmd, params) = s.journal.last().unwrap().clone();
assert_eq!((cmd.as_str(), &params["pickColorFrom"]), ("shapeBuilder.merge", &json!("swatches")), "{pick}");
let d = &s.doc().unwrap().doc;
let fills: Vec<Paint> = d.children(d.default_layer()).into_iter().flatten().map(|n| n.appearance.fill_paint()).collect();
assert_eq!(fills, vec![picked], "{pick}: the two squares merged into one shape with the picked fill");
}
}
/// With Pick Color From Color Swatches, a merge fills with the fill chosen while the Shape Builder
/// is active, and the Gradient panel's eyedropper samples into a stop of that fill's gradient.
#[test]
+25
View File
@@ -698,3 +698,28 @@ fn a_parametric_shape_kind_and_its_values_set_together() {
assert_eq!(s.tool_options_of("parametricShape")["kind"], json!("star"), "a refused call sets nothing");
}
}
/// The Shape Builder picks colors from the color swatches by default: a fresh session, and saved
/// preferences that hold other Shape Builder options but no `pickColorFrom`, give `swatches`. A
/// saved `artwork` (or `swatches`) is kept.
#[test]
fn shape_builder_pick_color_from_defaults_to_swatches_and_keeps_a_saved_choice() {
let mut s = session();
select(&mut s, "shapeBuilder");
assert_eq!(s.tool_options()["pickColorFrom"], json!("swatches"), "a fresh session");
for (saved, want) in [
(json!({"highlightFill": false}), "swatches"),
(json!({"pickColorFrom": "artwork"}), "artwork"),
(json!({"pickColorFrom": "swatches"}), "swatches"),
] {
let mut prefs = s.prefs.clone();
prefs.tool_settings.insert("shapeBuilder".into(), saved.as_object().unwrap().clone());
let saved_text = serde_json::to_string(&prefs).unwrap();
let mut next = session();
next.apply_prefs(serde_json::from_str(&saved_text).unwrap());
select(&mut next, "shapeBuilder");
assert_eq!(next.tool_options()["pickColorFrom"], json!(want), "saved {saved}");
select(&mut next, "selection");
assert_eq!(next.prefs.tool_settings["shapeBuilder"]["pickColorFrom"], json!(want), "stored again: {saved}");
}
}
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -66,11 +66,11 @@ pub struct ShapeBuilderOptions {
/// region as if an invisible edge closed it. When it is off, the path cuts the regions it crosses
/// as a line does.
pub open_filled_as_closed: bool,
/// Pick Color From Color Swatches (`pickColorFrom: "swatches"`; off: `"artwork"`): a merge
/// Pick Color From Color Swatches (`pickColorFrom: "swatches"`, on; off: `"artwork"`): a merge
/// fills the new shape with the current fill, and the Left and Right arrow keys step the current
/// fill through the document's color swatches. With Artwork, the shape takes the look of the
/// object where the drag starts, else of the one where it ends, else of the front-most selected
/// object.
/// object. A saved `pickColorFrom` is kept; preferences without one take Color Swatches.
pub swatches: bool,
/// Cursor Swatch Preview (`cursorSwatchPreview`, off): with Color Swatches, the current fill
/// and the swatches before and after it show as chips above the pointer while no drag is on.
@@ -105,7 +105,7 @@ impl Default for ShapeBuilderOptions {
fn default() -> Self {
Self {
open_filled_as_closed: true,
swatches: false,
swatches: true,
cursor_swatch_preview: false,
straight_line: false,
highlight_fill: true,
+1 -1
View File
@@ -631,7 +631,7 @@ pub(super) mod tests {
tool: "shapeBuilder",
opens_on: vec![
("openFilledAsClosed", json!(true)),
("pickColorFrom", json!("artwork")),
("pickColorFrom", json!("swatches")),
("cursorSwatchPreview", json!(false)),
("selection", json!("freeform")),
("highlightFill", json!(true)),
File diff suppressed because one or more lines are too long
+5 -4
View File
@@ -15725,10 +15725,11 @@ a flare into a plain group of its parts. The document saves a flare's settings.
The Shape Builder tool's options are its Shape Builder Tool Options (dialog `shapeBuilderOptions`):
`openFilledAsClosed` (on: a filled open path bounds a region as if an invisible edge closed it; a path counts as
filled when any of its fill rows is shown, painted and above 0% opacity, whichever row is on top; off: it cuts regions
as an unfilled path does), `pickColorFrom` (`artwork`, the default: a merged shape takes the appearance, opacity and
blending mode of the front-most selected object under the drag's first point, else of the one under its last point,
else of the front-most selected object; `swatches`: the current fill, and the Left and Right arrow keys without
Shift, Alt or Cmd/Ctrl step the current fill through the document's color swatches), `cursorSwatchPreview` (off; with `swatches`, chips above the
as an unfilled path does), `pickColorFrom` (`swatches`, the default: a merged shape fills with the current fill, and
the Left and Right arrow keys without Shift, Alt or Cmd/Ctrl step the current fill through the document's color
swatches; `artwork`: a merged shape takes the appearance, opacity and blending mode of the front-most selected object
under the drag's first point, else of the one under its last point, else of the front-most selected object; a
`pickColorFrom` saved with the preferences is kept, and preferences saved without one take `swatches`), `cursorSwatchPreview` (off; with `swatches`, chips above the
pointer show the current fill and the swatches before and after it), `selection` (`freeform`, the default, or
`straightLine`: a drag touches what the line from its first point to the pointer crosses), `highlightFill` (on by
default; when it is off, merge mode shades no regions), `gapDetection` (off) with `gapLength` (pt, 0 to 72; 3), `clickStrokeSplitsPath` (In Merge Mode,