mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 08:52:45 +01:00
train: #8269
This commit is contained in:
commit
a494c940de
3 files changed
+235
-9
No files matched your search
@@ -83,10 +83,14 @@ pub(super) fn bottom(app: &mut VectorcraftApp, ui: &mut Ui, sel: &[String]) {
|
||||
app.run("ui.newColorGroup", json!({"swatches": deletable(sel)})).ok();
|
||||
}
|
||||
// Alt-click skips the dialog; Ctrl/Cmd-click makes a spot color, and Ctrl/Cmd+Shift-click
|
||||
// makes a global process color.
|
||||
if widgets::icon_button(ui, "dc-new-item", tl!("New Swatch"), false, 24.0).clicked() {
|
||||
// makes a global process color. Swatches dragged from the list and dropped on it are
|
||||
// duplicated.
|
||||
let copies = dragged_swatches(app, ui.ctx());
|
||||
let new = widgets::icon_button(ui, "dc-new-item", tl!("New Swatch"), false, 24.0);
|
||||
if new.clicked() {
|
||||
new_swatch(app, sel, ui.input(|i| i.modifiers));
|
||||
}
|
||||
drop_on_new(app, ui, &new, copies);
|
||||
// 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);
|
||||
@@ -106,12 +110,20 @@ pub(super) const DRAG_DOC: &str = "swatch-drag-doc";
|
||||
/// 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![] };
|
||||
let d = &st.doc;
|
||||
dragged_rows(app, ctx).into_iter().filter(|n| d.swatch_name_taken(n) && d.swatch(n).is_none_or(|w| !w.is_reserved())).collect()
|
||||
}
|
||||
|
||||
/// The names of the swatches or color groups of the active document being dragged from the list,
|
||||
/// in panel order. Empty for any other drag, and for a drag started in another document.
|
||||
fn dragged_rows(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(),
|
||||
Some(PanelDrag::Paint { rows: Some(r), .. }) => r.names.clone(),
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
@@ -133,6 +145,48 @@ fn drop_on_delete(app: &mut VectorcraftApp, ui: &Ui, button: &Response, names: V
|
||||
}
|
||||
}
|
||||
|
||||
/// The swatches of the active document being dragged from the list that New Swatch can duplicate,
|
||||
/// in panel order: the dragged rows ([`dragged_rows`]) that are swatches still in the document,
|
||||
/// other than None and Registration.
|
||||
fn dragged_swatches(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<String> {
|
||||
let Some(st) = app.session.active() else { return vec![] };
|
||||
dragged_rows(app, ctx).into_iter().filter(|n| st.doc.swatch(n).is_some_and(|w| !w.is_reserved())).collect()
|
||||
}
|
||||
|
||||
/// Swatches (`names`) dragged onto New Swatch (`button`): the button is outlined while they are
|
||||
/// held over it, and the release of the primary button duplicates them ([`duplicate`]), whatever
|
||||
/// modifiers are held. The release of another button ends the drag, and other drags are left to
|
||||
/// their own targets.
|
||||
fn drop_on_new(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() {
|
||||
duplicate(app, ui.ctx(), &names);
|
||||
}
|
||||
}
|
||||
|
||||
/// Duplicates the swatches `names` (`swatch.duplicate`, each copy just after its swatch and in its
|
||||
/// color group) in one undo step and selects the copies. A failure is shown in the status bar and
|
||||
/// changes nothing.
|
||||
fn duplicate(app: &mut VectorcraftApp, ctx: &egui::Context, names: &[String]) {
|
||||
let made = if let [name] = names {
|
||||
app.run("swatch.duplicate", json!({ "name": name })).map(|r| vec![r])
|
||||
} else {
|
||||
let commands: Vec<Value> = names.iter().map(|n| json!({ "command": "swatch.duplicate", "params": { "name": n } })).collect();
|
||||
app.run("command.batch", json!({ "label": "Duplicate Swatch", "commands": commands }))
|
||||
.map(|r| r["results"].as_array().cloned().unwrap_or_default())
|
||||
};
|
||||
match made {
|
||||
Ok(made) => set_pstate(ctx, "swatch-selected", made.iter().filter_map(|r| r["name"].as_str().map(str::to_string)).collect::<Vec<_>>()),
|
||||
Err(e) => app.status(e),
|
||||
}
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
|
||||
@@ -610,8 +610,13 @@ fn frame_out(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<Event>,
|
||||
|
||||
/// The Delete Swatch button in `out`: its rectangle and whether it is enabled.
|
||||
fn trash_button(out: &egui::FullOutput) -> (Rect, bool) {
|
||||
footer_button(out, "Delete Swatch")
|
||||
}
|
||||
|
||||
/// The button labeled `label` in `out`: its rectangle and whether it is enabled.
|
||||
fn footer_button(out: &egui::FullOutput, label: &str) -> (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 node = nodes.iter().map(|(_, n)| n).find(|n| n.label().is_some_and(|l| l.trim() == label)).unwrap_or_else(|| panic!("a {label} 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())
|
||||
}
|
||||
@@ -628,16 +633,23 @@ fn outlined(out: &egui::FullOutput, rect: Rect) -> bool {
|
||||
/// 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) {
|
||||
drag_to_button(app, ctx, name, "Delete Swatch", modifiers, time)
|
||||
}
|
||||
|
||||
/// Drag the tile of `name` with `modifiers` held onto the button labeled `label` 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_button(app: &mut VectorcraftApp, ctx: &egui::Context, name: &str, label: &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 (target, _) = footer_button(&frame_out(app, ctx, vec![], modifiers, time + 0.05), label);
|
||||
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);
|
||||
frame_out(app, ctx, vec![Event::PointerMoved(target.center())], modifiers, time + 0.3);
|
||||
let held = frame_out(app, ctx, vec![Event::PointerMoved(target.center())], modifiers, time + 0.4);
|
||||
let seen = (outlined(&held, target), footer_button(&held, label).1);
|
||||
frame_out(app, ctx, vec![Event::PointerMoved(target.center()), button(target.center(), false)], modifiers, time + 0.5);
|
||||
seen
|
||||
}
|
||||
|
||||
@@ -700,6 +712,14 @@ fn swatches_dropped_on_delete_swatch_are_deleted_after_asking() {
|
||||
assert_eq!(doc(&app), kept, "{name}");
|
||||
}
|
||||
assert_eq!(undo_steps(&app), undo + 2);
|
||||
// A swatch of the user's whose name starts with a bracket is an ordinary swatch.
|
||||
app.run("swatch.new", json!({"name": "[Blue]", "color": "#0000ff"})).unwrap();
|
||||
let undo = undo_steps(&app);
|
||||
assert_eq!(drag_to_trash(&mut app, &ctx, "[Blue]", Modifiers::NONE, 7.0), (true, true));
|
||||
assert_eq!(dialog_message(&app).as_deref(), Some("Delete “[Blue]”?"));
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert!(doc(&app).swatch("[Blue]").is_none(), "OK deletes it");
|
||||
assert_eq!(undo_steps(&app), undo + 1);
|
||||
}
|
||||
|
||||
/// Delete Swatch takes only swatches dragged from the active document's list: a paint dragged from
|
||||
@@ -767,6 +787,157 @@ fn delete_swatch_ignores_other_drags() {
|
||||
unchanged(&app, "the first document");
|
||||
}
|
||||
|
||||
/// Swatches dragged from the list onto New Swatch are duplicated without a dialog, in thumbnail
|
||||
/// and list views: each copy goes just after its swatch, in its color group, and is selected, and
|
||||
/// the copies of one drop are one undo step. A selected swatch carries the other selected swatches
|
||||
/// with it, but not the selected groups, None or Registration. Modifiers do not change the drop, a
|
||||
/// repeated name is numbered, and a group, None and Registration dragged alone duplicate nothing.
|
||||
#[test]
|
||||
fn swatches_dropped_on_new_swatch_are_duplicated() {
|
||||
let mut app = app();
|
||||
let ctx = context();
|
||||
let after = |app: &VectorcraftApp, group: Option<&str>, name: &str| {
|
||||
let n = names_of(app, group);
|
||||
n.iter().position(|x| x == name).and_then(|i| n.get(i + 1).cloned())
|
||||
};
|
||||
let undo = undo_steps(&app);
|
||||
// An unselected swatch, nothing selected.
|
||||
assert_eq!(drag_to_button(&mut app, &ctx, "Orange", "New Swatch", Modifiers::NONE, 1.0), (true, true), "outlined while held");
|
||||
assert!(app.ui.dialog.is_none(), "no dialog");
|
||||
assert_eq!(after(&app, None, "Orange").as_deref(), Some("Orange copy"));
|
||||
assert_eq!(selected(&ctx), ["Orange copy"], "the copy is selected");
|
||||
assert_eq!(undo_steps(&app), undo + 1, "one undo step");
|
||||
let copy = app.session.doc().unwrap().doc.swatch("Orange copy").cloned().unwrap();
|
||||
assert_eq!(copy.paint, app.session.doc().unwrap().doc.swatch("Orange").unwrap().paint, "the copy keeps the paint");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert!(app.session.doc().unwrap().doc.swatch("Orange copy").is_none(), "Undo removes the copy");
|
||||
app.run("edit.redo", json!({})).unwrap();
|
||||
assert_eq!(after(&app, None, "Orange").as_deref(), Some("Orange copy"), "Redo brings it back");
|
||||
// Again: the copy's name is numbered.
|
||||
set_pstate(&ctx, "swatch-selected", Vec::<String>::new());
|
||||
drag_to_button(&mut app, &ctx, "Orange", "New Swatch", Modifiers::NONE, 2.0);
|
||||
assert_eq!(after(&app, None, "Orange").as_deref(), Some("Orange copy 2"));
|
||||
assert_eq!(selected(&ctx), ["Orange copy 2"]);
|
||||
// A selected swatch carries the selected swatches, in panel order and into their groups, with
|
||||
// Alt held; the copies are one undo step.
|
||||
let sel = ["[None]", "Bright Red", "Grays", "Sunset", "Lime"].map(String::from).to_vec();
|
||||
set_pstate(&ctx, "swatch-selected", sel);
|
||||
let undo = undo_steps(&app);
|
||||
assert_eq!(drag_to_button(&mut app, &ctx, "Lime", "New Swatch", Modifiers::ALT, 3.0), (true, true));
|
||||
assert!(app.ui.dialog.is_none(), "no dialog with Alt");
|
||||
assert_eq!(after(&app, None, "Lime").as_deref(), Some("Lime copy"));
|
||||
assert_eq!(after(&app, None, "Sunset").as_deref(), Some("Sunset copy"));
|
||||
assert_eq!(after(&app, Some("Brights"), "Bright Red").as_deref(), Some("Bright Red copy"));
|
||||
assert_eq!(selected(&ctx), ["Lime copy", "Sunset copy", "Bright Red copy"]);
|
||||
assert_eq!(names_of(&app, Some("Grays")).len(), 9, "the group is not duplicated");
|
||||
assert_eq!(undo_steps(&app), undo + 1, "one undo step for all");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
let d = app.session.doc().unwrap().doc.clone();
|
||||
assert!(["Lime copy", "Sunset copy", "Bright Red copy"].iter().all(|n| d.swatch(n).is_none()), "Undo removes every copy");
|
||||
// A group, None and Registration dragged alone: nothing.
|
||||
set_pstate(&ctx, "swatch-selected", Vec::<String>::new());
|
||||
let (kept, undo) = (app.session.doc().unwrap().doc.clone(), undo_steps(&app));
|
||||
for (i, name) in ["Grays", "[None]", REGISTRATION].into_iter().enumerate() {
|
||||
assert_eq!(drag_to_button(&mut app, &ctx, name, "New Swatch", Modifiers::NONE, 4.0 + i as f64), (false, true), "{name}");
|
||||
assert!(app.ui.dialog.is_none(), "{name}");
|
||||
assert_eq!(app.session.doc().unwrap().doc, kept, "{name}");
|
||||
}
|
||||
assert_eq!(undo_steps(&app), undo);
|
||||
// A swatch of the user's whose name starts with a bracket is an ordinary swatch.
|
||||
app.run("swatch.new", json!({"name": "[Blue]", "color": "#0000ff"})).unwrap();
|
||||
assert_eq!(drag_to_button(&mut app, &ctx, "[Blue]", "New Swatch", Modifiers::NONE, 8.0), (true, true));
|
||||
assert_eq!(after(&app, None, "[Blue]").as_deref(), Some("[Blue] copy"));
|
||||
// In a list view.
|
||||
let undo = undo_steps(&app);
|
||||
app.ui.swatches_view = View::SmallList;
|
||||
assert_eq!(drag_to_button(&mut app, &ctx, "Red", "New Swatch", Modifiers::NONE, 9.0), (true, true));
|
||||
assert_eq!(after(&app, None, "Red").as_deref(), Some("Red copy"));
|
||||
assert_eq!(undo_steps(&app), undo + 1);
|
||||
}
|
||||
|
||||
/// New Swatch duplicates only swatches dragged from the active document's list that are still in
|
||||
/// it: a paint dragged from elsewhere, art, a swatch dragged from another document, and a swatch
|
||||
/// deleted while it is dragged duplicate nothing. A secondary button released while a swatch is
|
||||
/// held over the button ends the drag without duplicating, and a click still opens New Swatch.
|
||||
#[test]
|
||||
fn new_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 (new, _) = footer_button(&frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 0.0), "New Swatch");
|
||||
let (before, undo) = (app.session.doc().unwrap().doc.clone(), undo_steps(&app));
|
||||
let unchanged = |app: &VectorcraftApp, case: &str| {
|
||||
assert!(app.ui.dialog.is_none(), "{case}: no dialog");
|
||||
assert_eq!(app.session.doc().unwrap().doc, before, "{case}: duplicates 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(new.center())], Modifiers::NONE, 1.0 + i as f64);
|
||||
assert!(!outlined(&held, new), "{case}: not outlined");
|
||||
frame_out(&mut app, &ctx, vec![release(new.center())], Modifiers::NONE, 1.5 + i as f64);
|
||||
unchanged(&app, case);
|
||||
egui::DragAndDrop::clear_payload(&ctx);
|
||||
}
|
||||
let press = |at, button, pressed| Event::PointerButton { pos: at, button, pressed, modifiers: Modifiers::NONE };
|
||||
let hold_orange = |app: &mut VectorcraftApp, time: f64| {
|
||||
frame_out(app, &ctx, vec![], Modifiers::NONE, time);
|
||||
let from = tile_center(&ctx, "Orange");
|
||||
frame_out(app, &ctx, vec![Event::PointerMoved(from), press(from, PointerButton::Primary, true)], Modifiers::NONE, time + 0.1);
|
||||
frame_out(app, &ctx, vec![Event::PointerMoved(from + vec2(6.0, 4.0))], Modifiers::NONE, time + 0.2);
|
||||
assert!(egui::DragAndDrop::payload::<PanelDrag>(&ctx).is_some(), "Orange is dragged");
|
||||
};
|
||||
// A secondary release over the button, then the primary release.
|
||||
hold_orange(&mut app, 3.0);
|
||||
frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 3.3);
|
||||
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 3.4);
|
||||
assert!(outlined(&held, new), "Orange is held over the button");
|
||||
frame_out(&mut app, &ctx, vec![press(new.center(), PointerButton::Secondary, true)], Modifiers::NONE, 3.5);
|
||||
frame_out(&mut app, &ctx, vec![press(new.center(), PointerButton::Secondary, false)], Modifiers::NONE, 3.6);
|
||||
unchanged(&app, "a secondary release");
|
||||
frame_out(&mut app, &ctx, vec![release(new.center())], Modifiers::NONE, 3.7);
|
||||
unchanged(&app, "the primary release after it");
|
||||
// A swatch deleted while it is dragged.
|
||||
hold_orange(&mut app, 4.0);
|
||||
app.run("swatch.delete", json!({"names": ["Orange"]})).unwrap();
|
||||
let (gone, undo_gone) = (app.session.doc().unwrap().doc.clone(), undo_steps(&app));
|
||||
frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 4.3);
|
||||
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 4.4);
|
||||
assert!(!outlined(&held, new), "a deleted swatch is not outlined");
|
||||
frame_out(&mut app, &ctx, vec![release(new.center())], Modifiers::NONE, 4.5);
|
||||
assert_eq!((app.session.doc().unwrap().doc.clone(), undo_steps(&app)), (gone, undo_gone), "a deleted swatch is not duplicated");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
// A swatch dragged from this document while another document with the same swatches becomes
|
||||
// active.
|
||||
hold_orange(&mut app, 5.0);
|
||||
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
|
||||
let (other, undo_new) = (app.session.doc().unwrap().doc.clone(), undo_steps(&app));
|
||||
frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 5.3);
|
||||
let held = frame_out(&mut app, &ctx, vec![Event::PointerMoved(new.center())], Modifiers::NONE, 5.4);
|
||||
let (new_other, _) = footer_button(&held, "New Swatch");
|
||||
assert!(!outlined(&held, new_other), "not outlined in the other document");
|
||||
frame_out(&mut app, &ctx, vec![release(new_other.center())], Modifiers::NONE, 5.5);
|
||||
assert_eq!((app.session.doc().unwrap().doc.clone(), undo_steps(&app)), (other, undo_new), "the other document duplicates nothing");
|
||||
assert!(app.session.set_active(0));
|
||||
unchanged(&app, "the first document");
|
||||
// A click still opens New Swatch.
|
||||
frame_out(&mut app, &ctx, vec![], Modifiers::NONE, 6.0);
|
||||
let click = vec![
|
||||
Event::PointerMoved(new.center()),
|
||||
press(new.center(), PointerButton::Primary, true),
|
||||
press(new.center(), PointerButton::Primary, false),
|
||||
];
|
||||
frame_out(&mut app, &ctx, click, Modifiers::NONE, 6.1);
|
||||
assert!(app.ui.dialog.is_some(), "a click opens the New Swatch dialog");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn art_dropped_on_the_panel_becomes_a_pattern_swatch() {
|
||||
let mut app = app();
|
||||
|
||||
@@ -1729,6 +1729,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
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`.
|
||||
Dragging swatches onto New Swatch duplicates them ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/use-swatches/duplicate-swatches.html) gives this drag as another way to duplicate the selected swatches): a swatch dragged from the Swatches panel, in any view, and released on the New Swatch button is copied through `swatch.duplicate` without opening the New Swatch dialog. A swatch that is part of the selection carries the other selected swatches with it. VectorCraft's own rules: each copy goes just after its swatch and in its color group, named `<name> copy` and then `<name> copy 2`; the copies of one drop are one undo step and are selected; modifiers held on release do not change the drop; color groups, None and [Registration] are not duplicated; the button is outlined only while such a swatch of the active document is held over it, so a paint from another panel, art, a swatch dragged from another document and a swatch deleted during the drag duplicate nothing. Tests: `panels::swatches::tests::swatches_dropped_on_new_swatch_are_duplicated`, `new_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`.
|
||||
|
||||
Reference in new issue
Block a user