Swatches: a drop lands where the button came up, with the keys held then

A drop on the Swatches panel is decided by the position and modifiers of
the primary button's release, so moving on to another swatch or letting
go of Alt later in the same frame no longer changes which swatch takes
the drop or whether it replaces one. Hover feedback still follows the
pointer and the keys held now.

Replace Pattern Art also refuses type whose inline graphic shows a
symbol painted with the pattern, which would make a tile that refers to
itself.
This commit is contained in:
dotCooCoo
2026-11-18 17:07:36 -08:00
parent e496cfd103
commit 5e62518a09
4 changed files with 134 additions and 34 deletions
+8 -5
View File
@@ -473,9 +473,9 @@ enum Uses<'a> {
Brush(&'a str),
}
/// Does `art` paint pattern `name`, itself or through the symbols, patterns, graph designs and
/// brushes it uses? A graph's stored series and label paints count, since its marks and labels
/// take them each time it is drawn again.
/// Does `art` paint pattern `name`, itself or through the symbols (of its instances and of the
/// inline graphics in its type), patterns, graph designs and brushes it uses? A graph's stored
/// series and label paints count, since its marks and labels take them each time it is drawn again.
fn paints_pattern(d: &Document, art: &[Arc<Node>], name: &str) -> bool {
let brushes = vectorcraft_brush::library(d);
// What was already looked into, and the art left to look at.
@@ -484,8 +484,11 @@ fn paints_pattern(d: &Document, art: &[Arc<Node>], name: &str) -> bool {
while let Some(n) = left.pop() {
let mut used = vec![];
walk_with_masks(n, &mut |c| {
if let NodeKind::SymbolInstance { symbol, .. } = &c.kind {
used.push(Uses::Symbol(symbol.as_str()));
match &c.kind {
NodeKind::SymbolInstance { symbol, .. } => used.push(Uses::Symbol(symbol.as_str())),
// The symbol of every inline graphic in type counts, overset or not.
NodeKind::Text(t) => used.extend(t.runs.iter().filter_map(|r| r.inline.as_ref()).map(|a| Uses::Symbol(a.symbol.as_str()))),
_ => {}
}
for it in &c.appearance.items {
if let vectorcraft_doc::AppearanceItem::Stroke(sk) = it
+6 -1
View File
@@ -285,7 +285,8 @@ fn replace_art_that_matches_the_tile_art_records_nothing() {
/// Replace Pattern Art is refused, changing nothing, for a missing name or pattern, with no art,
/// while a pattern is edited, and for art painted with the pattern itself, directly, through
/// another pattern, through a symbol, through the paints a graph stores, through a graph design a
/// graph draws its columns with and through the art of a brush on a stroke.
/// graph draws its columns with, through the art of a brush on a stroke and through the symbol of an
/// inline graphic in type.
#[test]
fn replace_art_is_refused_without_changing_anything() {
let mut s = session();
@@ -321,6 +322,9 @@ fn replace_art_is_refused_without_changing_anything() {
s.execute("paint.setFill", &json!({"ids": [brushed.0], "none": true})).unwrap();
s.execute("paint.setStroke", &json!({"ids": [brushed.0], "color": "#000000"})).unwrap();
s.execute("brush.apply", &json!({"name": "Dotted brush", "ids": [brushed.0]})).unwrap();
// Type that shows symbol "Dotted" as an inline graphic.
let typed = id_of(&s.execute("text.create", &json!({"x": 20, "y": 420, "text": "Hi"})).unwrap());
s.execute("text.insertInline", &json!({"id": typed.0, "at": 0, "symbol": "Dotted"})).unwrap();
let plain = blue_rect(&mut s);
let unchanged = |s: &Session, before: &vectorcraft_doc::Document, steps: usize, case: &str| {
assert_eq!(doc(s), before, "{case}: the document stays");
@@ -337,6 +341,7 @@ fn replace_art_is_refused_without_changing_anything() {
("through a graph's paints", json!({"name": "Dots", "ids": [graph.0]}), "art painted with `Dots` can't be its tile".into()),
("through a graph design", json!({"name": "Dots", "ids": [designed.0]}), "art painted with `Dots` can't be its tile".into()),
("through a brush", json!({"name": "Dots", "ids": [brushed.0]}), "art painted with `Dots` can't be its tile".into()),
("through an inline graphic", json!({"name": "Dots", "ids": [typed.0]}), "art painted with `Dots` can't be its tile".into()),
] {
let err = s.execute("object.pattern.replaceArt", &p).unwrap_err();
assert!(err.to_string().contains(&why), "{case}: {err}");