Swatch libraries: hold the library's numbered names while a pattern comes in

A color a library pattern's art brings now skips the library's numbered
names while the pattern is imported, instead of being renamed after the
import. The rename also rewrote every other paint in the document linked
to the name the import first gave, such as art still linked to a deleted
"Ink 2", so adding the pattern changed that art. Now the names are held
with placeholder swatches during the import and removed afterwards, and
links that were already in the document stay as they were.

A pattern whose art brings both "Ink" and the library's "Ink 2" keeps the
library's "Ink 2" under its own name when the document gives "Ink"
another color, and the library's "Ink" takes the next free name. A library
pattern with a numbered name, such as "Tiles 2", keeps that name when the
document does not use it.
This commit is contained in:
dotCooCoo
2026-11-21 17:31:08 -08:00
parent ff26d5e4a3
commit 6404b0cebf
3 changed files with 128 additions and 26 deletions
+5
View File
@@ -138,6 +138,11 @@ pub(crate) fn brought_names(lib: &Document, name: &str) -> std::collections::Has
gather(lib, name).swatches.into_iter().map(|w| w.name).collect()
}
/// The names in `lib` of pattern `name` and of the patterns its art brings.
pub(crate) fn brought_patterns(lib: &Document, name: &str) -> std::collections::HashSet<String> {
gather(lib, name).patterns.into_iter().map(|p| p.name).collect()
}
/// The name pattern `name` has in the document `imported` went into.
pub(crate) fn imported_name(imported: &Imported, name: &str) -> String {
let renamed = imported.renamed.iter().find(|r| r["kind"] == "pattern" && r["from"] == name).and_then(|r| r["to"].as_str());