mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 06:38:44 +00:00
Swatches: a user swatch named with a leading bracket dropped on Delete Swatch is deleted
Delete Swatch took dragged rows through the name-prefix filter of the selection's click path, so a user swatch such as [Blue] dropped on the button was ignored. The drop now keeps color groups and every swatch of the document other than None and Registration, as swatch.delete does.
This commit is contained in:
@@ -111,7 +111,8 @@ pub(super) const DRAG_DOC: &str = "swatch-drag-doc";
|
||||
/// 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![] };
|
||||
deletable(&dragged_rows(app, ctx)).into_iter().filter(|n| st.doc.swatch_name_taken(n)).collect()
|
||||
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,
|
||||
|
||||
@@ -695,6 +695,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
|
||||
|
||||
Reference in New Issue
Block a user