VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Swatches: a Shift-click after switching documents starts a new range
dotCooCooa0da3faffeba
diff --git a/crates/ui-egui/src/panels/swatches/body.rs b/crates/ui-egui/src/panels/swatches/body.rsindex 9147960ba..611b12d6d 100644--- a/crates/ui-egui/src/panels/swatches/body.rs+++ b/crates/ui-egui/src/panels/swatches/body.rs@@ -159,6 +159,7 @@ pub(super) fn focus_swatch(app: &VectorcraftApp, ui: &Ui, active: Option<&str>)let reselected = last_art.as_ref().is_some_and(|l| *l != art);if reselected {set_pstate(ui.ctx(), "swatch-selected", Vec::<String>::new());+ set_pstate(ui.ctx(), "swatch-anchor", String::new());}let changed = reselected || last_art.is_none() || last_swatch.as_deref() != active;set_pstate(ui.ctx(), "swatch-focus", (Some(art), active.map(str::to_string)));diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rsindex 7d751fe9d..c65941370 100644--- a/crates/ui-egui/src/panels/swatches/tests.rs+++ b/crates/ui-egui/src/panels/swatches/tests.rs@@ -133,6 +133,21 @@ fn modifier_clicks_select_several_swatches_and_groups() {assert_eq!(selected(&ctx), ["Grays"], "a plain click on a group selects it alone");}+#[test]+fn switching_documents_clears_the_swatch_range_anchor() {+ let mut app = app();+ let ctx = context();+ click_tile(&mut app, &ctx, "White", Modifiers::NONE, 0.0);+ assert_eq!(selected(&ctx), ["White"]);++ app.run("file.new", json!({"width": 200, "height": 200})).unwrap();+ frame(&mut app, &ctx, vec![], 1.0, show);+ assert!(selected(&ctx).is_empty());++ click_tile(&mut app, &ctx, "Black", Modifiers::SHIFT, 2.0);+ assert_eq!(selected(&ctx), ["Black"]);+}+/// A color swatch or a recent color clicked in the panel becomes the Color Guide's base color/// (#3137); a modifier click only selects.#[test]