mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-31 21:27:00 -06:00
Swatches: a Shift-click after switching documents starts a new range
The panel cleared its swatch selection when the active document or the selected art changed, but kept the Shift-click range anchor. A Shift-click in the other document then selected every swatch from a name clicked in the first document (for example White) to the clicked one. The anchor is now cleared with the selection, so the Shift-click selects only the clicked swatch.
This commit is contained in:
@@ -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)));
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user