mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 04:11:52 +01:00
Swatches: a Cmd/Ctrl-dropped tint makes its spot color from the color the drag showed
The spot swatch is now made from the dragged paint's own color instead of resolving the base swatch and tint again at the drop, so a base that changed during the drag does not change the new swatch.
This commit is contained in:
1 parent
93da5fea01
commit
b3cbba36df
2 files changed
+22
-1
No files matched your search
@@ -277,7 +277,12 @@ pub(super) fn apply_drop(app: &mut VectorcraftApp, drop: Drop) {
|
||||
("swatch.edit", json!({"name": t, "paint": crate::panels::swatch_paint_params(&paint)}))
|
||||
}
|
||||
Drop::New { paint, target, spot, .. } => {
|
||||
let mut p = crate::panels::swatch_paint_params(&paint);
|
||||
// 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);
|
||||
if paint.color().is_some() {
|
||||
if let Some(g) = target.and_then(|t| group_of(d, &t)) {
|
||||
p["group"] = json!(g);
|
||||
|
||||
@@ -1210,6 +1210,22 @@ fn cmd_drops_of_tints_and_with_alt_follow_the_replacement_rule() {
|
||||
assert!(app.session.doc().unwrap().doc.swatch("Orange 40%").is_some_and(|w| w.tint_of().is_some()));
|
||||
}
|
||||
|
||||
/// A tint Cmd/Ctrl-dropped becomes a spot color of the color the drag showed, even when its base
|
||||
/// swatch changes between the drag start and the drop.
|
||||
#[test]
|
||||
fn a_cmd_dropped_tint_makes_its_spot_from_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, 1.0);
|
||||
let newest = newest_swatch(&app);
|
||||
assert_eq!((newest.paint, newest.spot), (Paint::solid(shown), true), "{}", 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]
|
||||
|
||||
Reference in new issue
Block a user