Merge pull request #8249 from dotCooCoo/feat/swatches-drag-to-delete

Swatches: swatches dragged onto the Delete Swatch button are deleted
This commit is contained in:
BFlat
2026-11-18 03:20:53 +07:00
committed by GitHub
5 changed files with 226 additions and 5 deletions
+44 -3
View File
@@ -1,6 +1,9 @@
use super::dnd::{group_of, selection};
use super::libraries::SwatchLibraries;
use super::{Kind, LibraryKind, Ui, Value, VectorcraftApp, View, active_paint, json, library_panel, menu_item, pstate, set_pstate, widgets};
use super::{
Kind, LibraryKind, PanelDrag, Response, Ui, Value, VectorcraftApp, View, active_paint, json, library_panel, menu_item, pstate, set_pstate,
widgets,
};
/// The selected swatches and groups that can be deleted (all but None and Registration).
pub(super) fn deletable(sel: &[String]) -> Vec<String> {
@@ -84,14 +87,52 @@ pub(super) fn bottom(app: &mut VectorcraftApp, ui: &mut Ui, sel: &[String]) {
if widgets::icon_button(ui, "dc-new-item", tl!("New Swatch"), false, 24.0).clicked() {
new_swatch(app, sel, ui.input(|i| i.modifiers));
}
// Alt-click deletes without asking.
// Alt-click deletes without asking. Swatches or color groups dragged from the list can be
// dropped on it, also with nothing selected: the button is enabled while they are held.
let del = deletable(sel);
if widgets::icon_button_enabled(ui, "trash-2", tl!("Delete Swatch"), false, !del.is_empty(), 24.0).clicked() {
let dragged = dragged_deletable(app, ui.ctx());
let trash = widgets::icon_button_enabled(ui, "trash-2", tl!("Delete Swatch"), false, !del.is_empty() || !dragged.is_empty(), 24.0);
if trash.clicked() && !del.is_empty() {
delete(app, del, ui.input(|i| i.modifiers.alt));
}
drop_on_delete(app, ui, &trash, dragged);
});
}
/// The panel state key of the document (`uid`) the swatches being dragged from the list belong to.
pub(super) const DRAG_DOC: &str = "swatch-drag-doc";
/// The swatches and color groups of the active document being dragged from the list that Delete
/// Swatch can delete: neither None nor Registration, and still in the document. Empty for any other
/// drag, and for a drag started in another document.
fn dragged_deletable(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<String> {
let Some(st) = app.session.active() else { return vec![] };
if pstate::<Option<u64>>(ctx, DRAG_DOC) != Some(st.uid) {
return vec![];
}
match egui::DragAndDrop::payload::<PanelDrag>(ctx).as_deref() {
Some(PanelDrag::Paint { rows: Some(r), .. }) => deletable(&r.names).into_iter().filter(|n| st.doc.swatch_name_taken(n)).collect(),
_ => vec![],
}
}
/// Swatches or color groups (`names`) dragged onto Delete Swatch (`button`): the button is
/// outlined while they are held over it, and the release of the primary button asks to delete them
/// as a plain click does ([`delete`]); Alt does not skip the question. The release of another
/// button ends the drag, and other drags are left to their own targets.
fn drop_on_delete(app: &mut VectorcraftApp, ui: &Ui, button: &Response, names: Vec<String>) {
if names.is_empty() || button.dnd_hover_payload::<PanelDrag>().is_none() {
return;
}
widgets::drop_target_outline(ui, button.rect);
if !ui.input(|i| i.pointer.button_released(egui::PointerButton::Primary)) {
return;
}
if button.dnd_release_payload::<PanelDrag>().is_some() {
delete(app, names, false);
}
}
/// The colour group the selection points at: the last selected group, or the group of the last
/// selected swatch.
fn target_group(app: &VectorcraftApp, sel: &[String]) -> Option<String> {
+7 -2
View File
@@ -1,4 +1,4 @@
use super::actions::{bottom, edit_group};
use super::actions::{DRAG_DOC, bottom, edit_group};
use super::dnd::{TileEvents, apply_drop, click_selection, highlighted, selection, tile_input, zone_input};
use super::tiles::{
draw_folder, draw_registration, folder_tile, global_mark, list_icons, list_row, list_row_name, pattern_thumb, tile_grid, tile_id,
@@ -116,7 +116,9 @@ pub(super) fn body(app: &mut VectorcraftApp, ui: &mut Ui, salt: &'static str) {
}
}
});
let zone = ui.interact(out.inner_rect, ui.scope_id().with("swatch-drop"), Sense::hover());
// The drop zone ends where the list does, so it does not reach over the buttons below a list
// shrunk to its rows.
let zone = ui.interact(out.inner_rect.intersect(ui.min_rect()), ui.scope_id().with("swatch-drop"), Sense::hover());
zone_input(ui, &zone, &mut ev);
let r = ui.min_rect();
ui.ctx().accesskit_node_builder(ui.unique_id(), |node| {
@@ -130,6 +132,9 @@ pub(super) fn body(app: &mut VectorcraftApp, ui: &mut Ui, salt: &'static str) {
}
None => {}
}
if ev.started {
set_pstate(ui.ctx(), DRAG_DOC, app.session.active().map(|st| st.uid));
}
if let Some(drop) = ev.drop {
apply_drop(app, drop);
}
@@ -114,6 +114,8 @@ pub(super) struct TileEvents {
pub(super) drop: Option<Drop>,
/// A drag is held over a tile or row.
over: bool,
/// A drag of swatches or color groups started on a tile or row.
pub(super) started: bool,
}
/// Clicks, double-clicks, tooltips and drag and drop of the tile or row `resp` of entry `e`
@@ -133,6 +135,7 @@ pub(super) fn tile_input(ui: &Ui, resp: Response, e: &Entry, items: &[Entry], se
.map(|x| x.name().to_string())
.collect();
egui::DragAndDrop::set_payload(ui.ctx(), drag_of(e, names));
ev.started = true;
}
tile_drop(ui, &resp, e, list, ev);
// The default swatches' names show in the UI's language; the document keeps them as they are.
+171
View File
@@ -596,6 +596,177 @@ fn only_a_primary_drag_moves_swatches_and_groups() {
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1);
}
/// One frame of the panel at `time` with `modifiers` held and the accessibility tree on; returns
/// the frame's output.
fn frame_out(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<Event>, modifiers: Modifiers, time: f64) -> egui::FullOutput {
ctx.enable_accesskit();
let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(280.0, 700.0)));
let events = std::iter::once(Event::ModifiersChanged(modifiers)).chain(events).collect();
let input = egui::RawInput { events, time: Some(time), screen_rect, ..Default::default() };
let mut out = ctx.run_ui(input, |ui| show(app, ui));
out.textures_delta.clear();
out
}
/// The Delete Swatch button in `out`: its rectangle and whether it is enabled.
fn trash_button(out: &egui::FullOutput) -> (Rect, bool) {
let nodes = &out.platform_output.accesskit_update.as_ref().expect("an accessibility tree").nodes;
let node = nodes.iter().map(|(_, n)| n).find(|n| n.label().is_some_and(|l| l.trim() == "Delete Swatch")).expect("a Delete Swatch button");
let b = node.bounds().expect("the button's bounds");
(Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32)), !node.is_disabled())
}
/// Whether `out` draws the drop outline around `rect`.
fn outlined(out: &egui::FullOutput, rect: Rect) -> bool {
out.shapes.iter().any(|c| match &c.shape {
Shape::Rect(r) => r.rect.center().distance(rect.center()) < 0.5 && (r.stroke.width - 1.5).abs() < 0.01,
_ => false,
})
}
/// Drag the tile of `name` with `modifiers` held onto Delete Swatch and release the primary button
/// there, a frame per step from `time`. Returns whether the button was outlined and enabled while
/// the drag was held over it.
fn drag_to_trash(app: &mut VectorcraftApp, ctx: &egui::Context, name: &str, modifiers: Modifiers, time: f64) -> (bool, bool) {
frame_out(app, ctx, vec![], modifiers, time);
let (trash, _) = trash_button(&frame_out(app, ctx, vec![], modifiers, time + 0.05));
let from = tile_center(ctx, name);
let button = |pos, pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers };
frame_out(app, ctx, vec![Event::PointerMoved(from), button(from, true)], modifiers, time + 0.1);
frame_out(app, ctx, vec![Event::PointerMoved(from + vec2(6.0, 4.0))], modifiers, time + 0.2);
frame_out(app, ctx, vec![Event::PointerMoved(trash.center())], modifiers, time + 0.3);
let held = frame_out(app, ctx, vec![Event::PointerMoved(trash.center())], modifiers, time + 0.4);
let seen = (outlined(&held, trash), trash_button(&held).1);
frame_out(app, ctx, vec![Event::PointerMoved(trash.center()), button(trash.center(), false)], modifiers, time + 0.5);
seen
}
fn undo_steps(app: &VectorcraftApp) -> usize {
app.session.doc().unwrap().history.undo.len()
}
fn dialog_message(app: &VectorcraftApp) -> Option<String> {
app.ui.dialog.as_ref().map(|d| d.str("message"))
}
/// Swatches and color groups dragged from the list onto Delete Swatch are deleted as a plain click
/// on the button deletes the selection: the drop asks first, Cancel keeps them, and OK deletes them
/// in one undo step. The button is outlined and enabled while they are held over it, also with
/// nothing selected. A selected swatch carries the other selected swatches with it, but not the
/// selected groups, None or Registration, and Alt does not skip the question.
#[test]
fn swatches_dropped_on_delete_swatch_are_deleted_after_asking() {
let mut app = app();
let ctx = context();
let doc = |app: &VectorcraftApp| app.session.doc().unwrap().doc.clone();
let has_group = |app: &VectorcraftApp, g: &str| doc(app).swatch_groups.iter().any(|x| x.name == g);
assert!(!trash_button(&frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 0.0)).1, "disabled with nothing selected");
let undo = undo_steps(&app);
// An unselected swatch, nothing selected.
assert_eq!(drag_to_trash(&mut app, &ctx, "Orange", Modifiers::NONE, 1.0), (true, true), "outlined and enabled while held");
assert_eq!(dialog_message(&app).as_deref(), Some("Delete “Orange”?"));
crate::dialogs::cancel(&mut app);
assert!(doc(&app).swatch("Orange").is_some(), "Cancel keeps it");
assert_eq!(undo_steps(&app), undo, "Cancel adds no undo step");
drag_to_trash(&mut app, &ctx, "Orange", Modifiers::NONE, 2.0);
crate::dialogs::confirm(&mut app).unwrap();
assert!(app.ui.dialog.is_none() && doc(&app).swatch("Orange").is_none(), "OK deletes it");
assert_eq!(undo_steps(&app), undo + 1, "one undo step");
app.run("edit.undo", json!({})).unwrap();
assert!(doc(&app).swatch("Orange").is_some(), "Undo brings it back");
// A selected swatch carries the selected swatches; Alt still asks.
let sel = ["[None]", "Red", "Grays", "Lime"].map(String::from).to_vec();
set_pstate(&ctx, "swatch-selected", sel);
let undo = undo_steps(&app);
assert_eq!(drag_to_trash(&mut app, &ctx, "Lime", Modifiers::ALT, 3.0), (true, true));
assert_eq!(dialog_message(&app).as_deref(), Some("Delete these 2 swatches and groups?"));
crate::dialogs::confirm(&mut app).unwrap();
let d = doc(&app);
assert!(d.swatch("Red").is_none() && d.swatch("Lime").is_none(), "the dragged selection is deleted");
assert!(has_group(&app, "Grays") && d.swatch("[None]").is_some() && d.swatch("Orange").is_some(), "the rest stays");
assert_eq!(undo_steps(&app), undo + 1, "one undo step for both");
// A color group is deleted with its swatches.
drag_to_trash(&mut app, &ctx, "Grays", Modifiers::NONE, 4.0);
assert_eq!(dialog_message(&app).as_deref(), Some("Delete “Grays”?"));
crate::dialogs::confirm(&mut app).unwrap();
assert!(!has_group(&app, "Grays") && doc(&app).swatch("K=50").is_none());
assert_eq!(undo_steps(&app), undo + 2);
// None and Registration are never deleted, and the button does not take them.
set_pstate(&ctx, "swatch-selected", Vec::<String>::new());
let kept = doc(&app);
for (i, name) in ["[None]", REGISTRATION].into_iter().enumerate() {
assert_eq!(drag_to_trash(&mut app, &ctx, name, Modifiers::NONE, 5.0 + i as f64), (false, false), "{name}");
assert_eq!(dialog_message(&app), None, "{name}");
assert_eq!(doc(&app), kept, "{name}");
}
assert_eq!(undo_steps(&app), undo + 2);
}
/// Delete Swatch takes only swatches dragged from the active document's list: a paint dragged from
/// elsewhere, art, and a swatch dragged from another document whose name the active document also
/// has delete nothing, ask nothing and are not outlined. A secondary button released while a swatch
/// is held over the button ends the drag without asking.
#[test]
fn delete_swatch_ignores_other_drags() {
let mut app = app();
let id = app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap();
let ctx = context();
let (trash, _) = trash_button(&frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 0.0));
let (before, undo) = (app.session.doc().unwrap().doc.clone(), undo_steps(&app));
let unchanged = |app: &VectorcraftApp, case: &str| {
assert_eq!(dialog_message(app), None, "{case}: asks nothing");
assert_eq!(app.session.doc().unwrap().doc, before, "{case}: deletes nothing");
assert_eq!(undo_steps(app), undo, "{case}: no undo step");
};
// The payloads are set directly, as if dragged from this document's list.
set_pstate(&ctx, super::actions::DRAG_DOC, app.session.active().map(|st| st.uid));
let release = |at| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE };
let cases = [
("a paint", PanelDrag::paint(Paint::solid(Color::from_hex("#ed1c24").unwrap()))),
("art", PanelDrag::Art(vec![vectorcraft_doc::NodeId(id)])),
];
for (i, (case, drag)) in cases.into_iter().enumerate() {
egui::DragAndDrop::set_payload(&ctx, drag);
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(trash.center())], Modifiers::NONE, 1.0 + i as f64);
assert!(!outlined(&held, trash), "{case}: not outlined");
frame_out(&mut app, &ctx, vec![release(trash.center())], Modifiers::NONE, 1.5 + i as f64);
unchanged(&app, case);
egui::DragAndDrop::clear_payload(&ctx);
}
// A secondary release over the button, then the primary release.
frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 3.0);
let from = tile_center(&ctx, "Orange");
let press = |at, button, pressed| Event::PointerButton { pos: at, button, pressed, modifiers: Modifiers::NONE };
frame_out(&mut app, &ctx, vec![Event::PointerMoved(from), press(from, PointerButton::Primary, true)], Modifiers::NONE, 3.1);
frame_out(&mut app, &ctx, vec![Event::PointerMoved(from + vec2(6.0, 4.0))], Modifiers::NONE, 3.2);
frame_out(&mut app, &ctx, vec![Event::PointerMoved(trash.center())], Modifiers::NONE, 3.3);
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(trash.center())], Modifiers::NONE, 3.4);
assert!(outlined(&held, trash), "Orange is held over the button");
frame_out(&mut app, &ctx, vec![press(trash.center(), PointerButton::Secondary, true)], Modifiers::NONE, 3.5);
frame_out(&mut app, &ctx, vec![press(trash.center(), PointerButton::Secondary, false)], Modifiers::NONE, 3.6);
unchanged(&app, "a secondary release");
frame_out(&mut app, &ctx, vec![release(trash.center())], Modifiers::NONE, 3.7);
unchanged(&app, "the primary release after it");
// A swatch dragged from this document while another document with the same swatches becomes
// active.
frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 4.0);
let from = tile_center(&ctx, "Orange");
frame_out(&mut app, &ctx, vec![Event::PointerMoved(from), press(from, PointerButton::Primary, true)], Modifiers::NONE, 4.1);
frame_out(&mut app, &ctx, vec![Event::PointerMoved(from + vec2(6.0, 4.0))], Modifiers::NONE, 4.2);
assert!(egui::DragAndDrop::payload::<PanelDrag>(&ctx).is_some(), "Orange is dragged");
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
let undo_new = undo_steps(&app);
frame_out(&mut app, &ctx, vec![Event::PointerMoved(trash.center())], Modifiers::NONE, 4.3);
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(trash.center())], Modifiers::NONE, 4.4);
let (trash_new, enabled) = trash_button(&held);
assert!(!outlined(&held, trash_new) && !enabled, "not outlined or enabled in the other document");
frame_out(&mut app, &ctx, vec![release(trash_new.center())], Modifiers::NONE, 4.5);
assert_eq!(dialog_message(&app), None, "the other document asks nothing");
assert!(app.session.doc().unwrap().doc.swatch("Orange").is_some() && undo_steps(&app) == undo_new, "the other document keeps Orange");
assert!(app.session.set_active(0));
unchanged(&app, "the first document");
}
#[test]
fn art_dropped_on_the_panel_becomes_a_pattern_swatch() {
let mut app = app();
+1
View File
@@ -1727,6 +1727,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Swatches:** names follow the colour model and are unique; Swatch Options (process/spot, Global, Gray/RGB/HSB/CMYK/Web, live preview); editing a global or spot swatch recolours every linked fill, stroke and text run in one undo step; multi-select and delete with confirmation; New Swatch and New Color Group dialogs (a group from the selected artwork's colours); swatches in colour groups convert, separate and count like any other. The Swatches panel selects ranges and whole groups, has a find field, and drags swatches to reorder, regroup or paint art; Add Used Colors, Select All Unused, Merge, Ungroup and Sort by Kind; a CMYK document keeps applied colours in CMYK. Swatch libraries: nine generated colour libraries, seven gradient libraries (among them Organic Fades, soft perceptually mixed multi-stop fades that thin out to transparent, and Holographic, seven opaque linear foils of narrow pastel and pearl bands and seven radial glows that fade out to a clear edge) and three pattern libraries (Geometric Patterns; Grit Textures with eight seamless grain, speckle, stipple, scratch and fleck tiles; and Optical Effects with eight of VectorCraft's own seamless wave, ring, warped-check, stripe, chevron and lens tiles; their swatches bring their patterns) in a library panel, saved as `.vcswatches`, `.gpl`, swatch exchange (`.ase`) or CSS, and loaded from `.vcswatches`, `.gpl` and `.ase` files (`.ase` both ways: RGB, CMYK, Lab and Gray; global, spot and process; groups) and from color books (`.acb`, read only: the RGB, CMYK or Lab colors of a book such as a Pantone book a user owns, named with its prefix and suffix, spot unless it says process, #831); `swatch.library.copyToUser` copies a loaded library into the User Defined folder without replacing a file, and a file with the same extension and bytes as a User Defined library opens as that library. Tints of global and spot colours ("Name 40%") stay linked and separate as a percentage of their plate. Spot colours can be defined in Lab (Spot Colors options). A built-in [Registration] swatch prints on every plate.
Right-clicking a swatch in either list or thumbnail view selects it without applying paint and offers Swatch Options…, Duplicate Swatch and Delete Swatch for that item. None, [Registration] and missing swatches disable these actions. Existing active-item multiselection is retained; actions still target only the clicked item. Evidence: `panels::swatches::tests::context_menu` harness tests cover all five views, selection, dialog dispatch, duplicate/delete and Undo. All 39 Swatches tests pass; the regression fails with the menu hooks removed. Rendered headless list and thumbnail menus were inspected, and a fresh local deep CodeRabbit review reported zero findings. Full workspace CI passed on Linux/WSL on the merged branch (all 13 gates), including the test-helper correction for the upstream compile error tracked in #7727; native Windows full CI has two unchanged engine-test failures. Scores and estimates unchanged.
Validation on 2026-11-15: native Windows formatting, workspace Clippy and all 39 focused Swatches tests passed. Windows full CI stopped at unchanged engine tests `tests::package::a_confined_package_names_files_outside_the_read_root_by_name` (slash-sensitive report assertion) and `tests::plugins::plugin_storage_behind_a_link_is_left_alone` (storage-link setup returned AlreadyExists). Both cases pass in the Linux/WSL full CI run, which passed all 13 gates. No engine or CI workflow changes are included.
Dragging swatches onto Delete Swatch deletes them ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=136), Replace, merge, or delete swatches section, lists this drag as one of the ways to delete the selected swatches): a swatch or color group dragged from the Swatches panel, in any view, and released on the Delete Swatch button is deleted through `swatch.delete`, even while nothing was selected and the button is disabled for clicks. A swatch that is part of the selection carries the other selected swatches of its kind with it. VectorCraft's own rules: the drop asks first as a plain click does, and Alt does not skip the question; Cancel keeps everything, and OK deletes them in one undo step; None and [Registration] are never taken; the button is enabled while swatches are selected or while a swatch or group of the active document is being dragged, and it is outlined only while such a swatch or group is held over it, so a paint from another panel, art and a swatch dragged from another document delete nothing. Tests: `panels::swatches::tests::swatches_dropped_on_delete_swatch_are_deleted_after_asking`, `delete_swatch_ignores_other_drags`.
Editing, renaming, deleting or merging a global swatch also changes the colors linked to it in graph designs, the art of brushes and the tile that pattern editing's Cancel puts back, in the same undo step as the rest of the art; Default Swatches with replace unlinks them there too.
A swatch step in `command.batch` (Delete, Swatch Options, Merge, Edit Color Group) changes the fill and stroke for new art as the command run on its own does, so art drawn later in the batch or after it takes the same paint; a batch that fails, and a canceled batch preview, put back the paints it started with, and a canceled Swatch Options preview leaves them as they were. These swatch commands also change the fills and strokes of the appearance new art takes, and Undo and Redo of the command or the batch put the paints for new art back with the swatches. Spot Colors options (`swatch.spotOptions`) and Default Swatches with replace (`swatch.resetDefaults {replace: true}`) as `command.batch` steps also change the fill and stroke for new art as each command run on its own does: a fill or stroke linked to a Lab spot swatch keeps its link and tint and takes the Lab values or their CMYK equivalent, and one linked to a swatch the replace removes keeps its color and loses the link. Evidence: `swatch_steps_in_a_batch_change_the_new_art_paints_as_commands_do`, `spot_colors_options_in_a_batch_change_the_new_art_paints_as_the_command_does`, `default_swatches_replace_in_a_batch_unlinks_the_new_art_paints_as_the_command_does`, `undo_and_redo_of_a_swatch_edit_put_back_the_new_art_paints`, `swatch_edits_reach_the_paints_of_the_new_art_template`, `a_failed_batch_puts_back_the_new_art_paints_a_swatch_step_changed` and `canceling_a_swatch_options_preview_keeps_the_new_art_paints` in `crates/engine/src/tests/swatches.rs`.
Add Used Colors (`swatch.addUsedColors`) and Select All Unused (`swatch.unused`) look colors, swatch names, links, tints and gradients up in hash sets instead of searching every swatch and color for each color or linked paint (New Color Group from artwork too), and New Swatch with several colors (`swatch.new`), New Color Group (`swatch.newGroup`) and Edit Color Group (`swatch.editGroup`) name their new swatches from one set of the names already taken. The new swatches keep their names, order and links, and Select All Unused lists the same swatches. Evidence: `add_used_colors_adds_each_new_color_once_with_free_names`, `add_used_colors_global_links_every_paint_of_a_new_color`, `unused_matches_links_tints_colors_gradients_and_patterns_exactly`, `new_swatches_from_colors_are_numbered_after_names_already_taken`, `new_color_group_numbers_its_colors_after_the_group_and_its_moved_swatches`, `new_color_group_from_artwork_lists_each_color_once_with_free_names` and `edit_color_group_numbers_extra_colors_after_the_names_it_keeps` in `crates/engine/src/tests/swatchcmds.rs`; `free_swatch_names_match_naming_each_swatch_as_it_is_added` and `free_swatch_names_match_new_swatch_names_as_swatches_are_added` in `crates/doc/src/swatches.rs`.