diff --git a/crates/ui-egui/src/panels/swatches/dnd.rs b/crates/ui-egui/src/panels/swatches/dnd.rs index 36c8be4e5f..9d11d23bae 100644 --- a/crates/ui-egui/src/panels/swatches/dnd.rs +++ b/crates/ui-egui/src/panels/swatches/dnd.rs @@ -256,6 +256,15 @@ fn replaces(d: &Document, with: &str, target: &str) -> bool { } } +/// `paint` as swatch params. A solid color other than Registration is sent as the color the drag +/// carries, not as its base swatch and tint, which the command would resolve again at the drop. +fn shown_color_params(paint: &Paint) -> Value { + match paint.color() { + Some(c) if !paint.is_registration() => crate::panels::swatch_paint_params(&Paint::solid(c)), + _ => crate::panels::swatch_paint_params(paint), + } +} + /// Run a drop on the panel: move the swatches, give the paint of a swatch Alt-dropped on another of /// its kind to that one, or make a swatch of the proxy's paint (a color dropped on a folder or a /// grouped swatch joins that group; a color Cmd/Ctrl-dropped becomes a new spot color of the color @@ -274,15 +283,11 @@ pub(super) fn apply_drop(app: &mut VectorcraftApp, drop: Drop) { Drop::New { paint, target: Some(t), replace: true, .. } if d.swatch(&t).is_some_and(|w| !w.is_reserved() && w.tint_of().is_none() && same_kind(&w.paint, &paint)) => { - ("swatch.edit", json!({"name": t, "paint": crate::panels::swatch_paint_params(&paint)})) + ("swatch.edit", json!({"name": t, "paint": shown_color_params(&paint)})) } Drop::New { paint, target, spot, .. } => { - // A new spot color is made from the color the drag showed, not from its base swatch as it is now. - let source = match paint.color() { - Some(c) if spot && !paint.is_registration() => Paint::solid(c), - _ => paint.clone(), - }; - let mut p = crate::panels::swatch_paint_params(&source); + // Only a spot color needs a color of its own; other drops keep a tint's link to its base. + let mut p = if spot { shown_color_params(&paint) } else { crate::panels::swatch_paint_params(&paint) }; if paint.color().is_some() { if let Some(g) = target.and_then(|t| group_of(d, &t)) { p["group"] = json!(g); diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index f823e1c920..1c878794a5 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -1226,6 +1226,22 @@ fn a_cmd_dropped_tint_makes_its_spot_from_the_captured_color() { assert_eq!((newest.paint, newest.spot), (Paint::solid(shown), true), "{}", app.ui.status); } +/// A tint Cmd/Ctrl+Alt-dropped on a solid swatch gives it the color the drag showed, even when the +/// tint's base swatch changes between the drag start and the drop. +#[test] +fn a_tint_alt_dropped_on_a_swatch_replaces_it_with_the_captured_color() { + let mut app = app(); + let ctx = context(); + app.run("swatch.edit", json!({"name": "Orange", "global": true})).unwrap(); + app.run("swatch.new", json!({"swatch": "Orange", "tint": 40})).unwrap(); + let tint = app.session.doc().unwrap().doc.tint_paint("Orange", 0.4).expect("a tint of Orange"); + let shown = tint.color().expect("a color"); + app.run("swatch.edit", json!({"name": "Orange", "paint": {"color": "#2040c0"}})).unwrap(); + drop_paint_on(&mut app, &ctx, "Red", tint, Modifiers::COMMAND | Modifiers::ALT, 1.0); + let red = app.session.doc().unwrap().doc.swatch("Red").cloned().expect("Red"); + assert_eq!(red.paint.color(), Some(shown), "{}", app.ui.status); +} + /// A Recent Colors chip of the Color panel dragged onto the Swatches panel becomes a swatch; a click /// on it still paints the selected art. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 6b8eeacfc2..a11d457b2e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1740,7 +1740,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Unchecking Show Recent Colors in the Color panel's menu hides its Recent Colors row, and checking it shows the row again ([Select colors using the Color panel](https://helpx.adobe.com/illustrator/desktop/manage-colors/select-and-adjust-colors/select-colors-using-the-color-panel.html)). In VectorCraft the item is checked by default and kept between sessions, applied colors still join the list while the row is hidden, Hide Options hides the row either way, and the Swatches panel keeps its row (`ui.colorPanel {recentColors}`). Tests: `show_recent_colors_hides_and_shows_the_row` in `crates/ui-egui/src/panels/color/tests.rs`. The Swatches panel's menu has its own Show Recent Colors item: unchecking it hides the panel's Recent Colors row and checking it shows the row again ([Color Enhancements in Illustrator](https://community.adobe.com/announcements-651/color-enhancements-in-illustrator-816797) puts recent colors in the Color and Swatches panels; [Select colors using the Color panel](https://helpx.adobe.com/illustrator/desktop/manage-colors/select-and-adjust-colors/select-colors-using-the-color-panel.html) hides them with Show Recent Colors in the panel menu; a [community thread](https://community.adobe.com/questions-652/swatches-disappear-in-swatches-panel-when-switching-between-documents-in-29-7-1-on-macos-816823) turns it off from the Swatches panel). In VectorCraft it is checked by default, kept between sessions apart from the Color panel's, and applied colors still join the list while the row is hidden (#6617). Tests: `show_recent_colors_hides_and_shows_the_swatches_row` in `crates/ui-egui/src/panels/swatches/tests.rs`. A Recent Colors chip in the Color or Swatches panel drags into the Swatches panel's list to become a swatch of its color, in its color model, as one undo step ([Select colors using the Color panel](https://helpx.adobe.com/illustrator/desktop/manage-colors/select-and-adjust-colors/select-colors-using-the-color-panel.html)). In VectorCraft a chip dropped on a color group or one of its swatches joins that group, anywhere else in the list it joins the ungrouped swatches at the end, a color that is already a swatch is added again under another name, and dragging a chip does not paint the selected art (`swatch.new`). Tests: `a_recent_color_dragged_onto_the_list_becomes_a_swatch` and `a_recent_color_dragged_from_the_color_panel_becomes_a_swatch` in `crates/ui-egui/src/panels/swatches/tests.rs`. - A color dragged into the Swatches panel with Cmd (macOS) or Ctrl (Windows) held becomes a spot color swatch ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/use-swatches/create-spot-color-swatches.html) gives this drag from the Color panel as one way to make a spot color). VectorCraft's own rules: Ctrl works on Linux too, and the modifier is read on release; the Fill and Stroke squares, Recent Colors chips and Color Guide colors drag the same way; the new swatch is global, keeps the dragged color's model, joins the color group it is dropped on (anywhere else, the ungrouped swatches at the end), takes a name of its own and is one undo step that paints no art; a tint dragged this way becomes a new spot color of the tinted color, and its base swatch stays as it is; with Alt also held, a color dropped on a solid swatch replaces it, and one dropped on Registration or a tint swatch becomes a spot color; gradients, patterns, Registration and swatches dragged within the panel are not made spot colors (`swatch.new {spot: true}`). Tests: `a_color_cmd_dropped_on_the_panel_becomes_a_spot_swatch`, `a_color_cmd_dropped_on_empty_list_space_becomes_a_spot_swatch`, `a_cmd_drop_of_other_paints_or_rows_makes_no_spot_color` and `cmd_drops_of_tints_and_with_alt_follow_the_replacement_rule` in `crates/ui-egui/src/panels/swatches/tests.rs`. + A color dragged into the Swatches panel with Cmd (macOS) or Ctrl (Windows) held becomes a spot color swatch ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/use-swatches/create-spot-color-swatches.html) gives this drag from the Color panel as one way to make a spot color). VectorCraft's own rules: Ctrl works on Linux too, and the modifier is read on release; the Fill and Stroke squares, Recent Colors chips and Color Guide colors drag the same way; the new swatch is global, keeps the dragged color's model, joins the color group it is dropped on (anywhere else, the ungrouped swatches at the end), takes a name of its own and is one undo step that paints no art; a tint dragged this way becomes a new spot color of the tinted color, and its base swatch stays as it is; a drop uses the color the drag showed, also when the tint's base swatch changes before the release; with Alt also held, a color dropped on a solid swatch replaces it, and one dropped on Registration or a tint swatch becomes a spot color; gradients, patterns, Registration and swatches dragged within the panel are not made spot colors (`swatch.new {spot: true}`). Tests: `a_color_cmd_dropped_on_the_panel_becomes_a_spot_swatch`, `a_color_cmd_dropped_on_empty_list_space_becomes_a_spot_swatch`, `a_cmd_drop_of_other_paints_or_rows_makes_no_spot_color`, `cmd_drops_of_tints_and_with_alt_follow_the_replacement_rule`, `a_cmd_dropped_tint_makes_its_spot_from_the_captured_color` and `a_tint_alt_dropped_on_a_swatch_replaces_it_with_the_captured_color` in `crates/ui-egui/src/panels/swatches/tests.rs`. A Cmd/Ctrl-click on the Color panel's spectrum applies Complement and a Cmd/Ctrl+Shift-click applies Invert to the active Fill or Stroke (`paint.complement`, `paint.invert`); with Alt also held, the click recolors the inactive one, as the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) list them. The Color panel spectrum grows into the vertical space of a resized panel, with Show Options or Hide Options (#8005); compact auto-fit flyouts and embedded mixers retain their previous height. Regression: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. A double-click right of an RGB field switches the Color panel's R, G and B between percent and 0 to 255 ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), Color panel). In VectorCraft the color does not change, Web Safe RGB and the hex field stay in 0 to 255, and the panel keeps the choice between sessions (`ui.colorPanel {rgbPercent}`); the color mixer of the Fill and Stroke chips and the gradient stop dialog follow the same setting. Toggle RGB Percent (`ui.colorRgbPercent`) in the command palette and Keyboard Shortcuts switches the units from the keyboard. Tests: `rgb_percent_switches_the_rgb_fields_between_percent_and_0_to_255`, `rgb_percent_does_not_switch_while_the_rows_are_disabled`, `rgb_percent_comes_back_after_a_restart` and `toggle_rgb_percent_switches_the_units_from_the_keyboard` in `crates/ui-egui/src/panels/color/tests.rs`.