From 02da66521fad6d9442a88aa84dee64b2a4ce74f7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 06:54:13 -0800 Subject: [PATCH 1/2] Fix #7095: a double-click on a pattern swatch no longer paints its tile The second click of a double-click on a swatch also counted as a plain click. After the double-click opened pattern editing, which selects the tile art, that click applied the pattern swatch to the tile, so the pattern held a copy of itself. The second click now only opens the editor; the first click still applies and selects the swatch. Reported by erolkarino. #7164 by mockydevs makes the engine refuse painting the tile with its own pattern; this change stops the swatch panel from sending that paint on a double-click. --- crates/ui-egui/src/panels/swatches/dnd.rs | 5 ++- crates/ui-egui/src/panels/swatches/tests.rs | 36 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/swatches/dnd.rs b/crates/ui-egui/src/panels/swatches/dnd.rs index 2c36dabcb3..9946b0749f 100644 --- a/crates/ui-egui/src/panels/swatches/dnd.rs +++ b/crates/ui-egui/src/panels/swatches/dnd.rs @@ -144,7 +144,10 @@ pub(super) fn tile_input(ui: &Ui, resp: Response, e: &Entry, items: &[Entry], se }), _ => resp.on_hover_text(shown), }; - if resp.clicked() { + // A double-click's first click already applied and selected the swatch; its second only opens + // the editor. Pattern editing selects the tile art, which the second click would paint with + // the pattern itself. + if resp.clicked() && !resp.double_clicked() { ev.clicked = Some((e.clone(), ui.input(|i| i.modifiers))); } } diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index 8e313e9d77..0b9bb1d8b3 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -518,6 +518,42 @@ fn list_view_rows_take_double_clicks_and_folder_clicks_select_the_group() { assert_eq!(describe(&Paint::solid(Color::gray(0.5)), true, true), "Spot Color, Grayscale"); } +/// A double-click on a pattern swatch, its clicks on frames of their own as a pointer makes them: +/// the first click paints the selected art with the pattern, and the second opens pattern editing +/// on that pattern without painting the tile art, which editing selects, with the pattern itself +/// (#7095). +#[test] +fn double_clicking_a_pattern_edits_it_without_painting_its_tile() { + let mut app = app(); + let tile = app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + app.run("object.pattern.make", json!({"ids": [tile], "name": "Dots", "width": 20, "height": 20})).unwrap(); + app.run("object.pattern.done", json!({})).unwrap(); + let art = app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap(); + for view in [View::SmallThumb, View::SmallList] { + app.ui.swatches_view = view; + let ctx = context(); + // Only the pattern shows, so its row is on screen in the list view too. + set_pstate(&ctx, "swatch-show-find", true); + ctx.data_mut(|d| d.insert_temp(find_id(), "Dots".to_string())); + frame(&mut app, &ctx, vec![], 0.0, show); + let at = tile_center(&ctx, "Dots"); + let button = |pressed| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + for (i, e) in [Event::PointerMoved(at), button(true), button(false), button(true), button(false)].into_iter().enumerate() { + frame(&mut app, &ctx, vec![e], 1.0 + i as f64 * 0.05, show); + } + let d = &app.session.doc().unwrap().doc; + let pe = d.pattern_edit.as_ref().unwrap_or_else(|| panic!("{view:?}: the double-click opens pattern editing")); + assert_eq!(pe.pattern, "Dots"); + let fill = d.node(vectorcraft_doc::NodeId(art)).unwrap().appearance.fill_paint(); + assert!(matches!(fill, Paint::Pattern { pattern, .. } if pattern == "Dots"), "the first click paints the art"); + for n in d.node(pe.layer).unwrap().children().unwrap() { + assert!(!matches!(n.appearance.fill_paint(), Paint::Pattern { .. }), "{view:?}: the tile keeps its own fill: {}", app.ui.status); + } + app.run("object.pattern.done", json!({})).unwrap(); + app.run("select.set", json!({"ids": [art]})).unwrap(); + } +} + #[test] fn dragging_tiles_reorders_and_moves_into_groups_as_one_undo_step_each() { let mut app = app(); From c0342e63aac07dea3b7e9237541367b06469b911 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:59:01 -0800 Subject: [PATCH 2/2] Swatches: quick clicks after a double-click do not apply the swatch A third quick click on a swatch counts as a triple click, and so does each quick click after it. Those clicks still applied the swatch, so a triple click on a pattern swatch opened pattern editing and then painted the tile art with the pattern itself. Only the first click of a run of quick clicks now applies and selects the swatch. The test now sends four quick clicks and gives the art a solid fill in each view, so the list view's first click is checked on its own. --- crates/ui-egui/src/panels/swatches/dnd.rs | 8 ++++---- crates/ui-egui/src/panels/swatches/tests.rs | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/panels/swatches/dnd.rs b/crates/ui-egui/src/panels/swatches/dnd.rs index 9946b0749f..b432485d0b 100644 --- a/crates/ui-egui/src/panels/swatches/dnd.rs +++ b/crates/ui-egui/src/panels/swatches/dnd.rs @@ -144,10 +144,10 @@ pub(super) fn tile_input(ui: &Ui, resp: Response, e: &Entry, items: &[Entry], se }), _ => resp.on_hover_text(shown), }; - // A double-click's first click already applied and selected the swatch; its second only opens - // the editor. Pattern editing selects the tile art, which the second click would paint with - // the pattern itself. - if resp.clicked() && !resp.double_clicked() { + // Only the first click of a run of quick clicks applies and selects the swatch. The second + // opens the editor, and the later ones (counted as triple clicks) do nothing. Pattern editing + // selects the tile art, and a later click would paint it with the pattern itself. + if resp.clicked() && !resp.double_clicked() && !resp.triple_clicked() { ev.clicked = Some((e.clone(), ui.input(|i| i.modifiers))); } } diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index 0b9bb1d8b3..e84cfb1f59 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -518,10 +518,10 @@ fn list_view_rows_take_double_clicks_and_folder_clicks_select_the_group() { assert_eq!(describe(&Paint::solid(Color::gray(0.5)), true, true), "Spot Color, Grayscale"); } -/// A double-click on a pattern swatch, its clicks on frames of their own as a pointer makes them: -/// the first click paints the selected art with the pattern, and the second opens pattern editing -/// on that pattern without painting the tile art, which editing selects, with the pattern itself -/// (#7095). +/// The test sends each click on its own frame, as a real pointer does. The first click paints the +/// selected art with the pattern. The second click opens pattern editing on that pattern, which +/// selects the tile art. Neither the second click nor quick clicks after it paint the tile art +/// with the pattern itself (#7095). #[test] fn double_clicking_a_pattern_edits_it_without_painting_its_tile() { let mut app = app(); @@ -530,6 +530,9 @@ fn double_clicking_a_pattern_edits_it_without_painting_its_tile() { app.run("object.pattern.done", json!({})).unwrap(); let art = app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap(); for view in [View::SmallThumb, View::SmallList] { + // A solid fill each time, so the first click must paint the art in this view too. + app.run("paint.setFill", json!({"ids": [art], "color": "#2050a0"})).unwrap(); + app.run("select.set", json!({"ids": [art]})).unwrap(); app.ui.swatches_view = view; let ctx = context(); // Only the pattern shows, so its row is on screen in the list view too. @@ -538,19 +541,23 @@ fn double_clicking_a_pattern_edits_it_without_painting_its_tile() { frame(&mut app, &ctx, vec![], 0.0, show); let at = tile_center(&ctx, "Dots"); let button = |pressed| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; - for (i, e) in [Event::PointerMoved(at), button(true), button(false), button(true), button(false)].into_iter().enumerate() { + // Four quick clicks: a double-click, then two more that count as triple clicks. + let mut events = vec![Event::PointerMoved(at)]; + for _ in 0..4 { + events.extend([button(true), button(false)]); + } + for (i, e) in events.into_iter().enumerate() { frame(&mut app, &ctx, vec![e], 1.0 + i as f64 * 0.05, show); } let d = &app.session.doc().unwrap().doc; let pe = d.pattern_edit.as_ref().unwrap_or_else(|| panic!("{view:?}: the double-click opens pattern editing")); assert_eq!(pe.pattern, "Dots"); let fill = d.node(vectorcraft_doc::NodeId(art)).unwrap().appearance.fill_paint(); - assert!(matches!(fill, Paint::Pattern { pattern, .. } if pattern == "Dots"), "the first click paints the art"); + assert!(matches!(fill, Paint::Pattern { pattern, .. } if pattern == "Dots"), "{view:?}: the first click paints the art"); for n in d.node(pe.layer).unwrap().children().unwrap() { assert!(!matches!(n.appearance.fill_paint(), Paint::Pattern { .. }), "{view:?}: the tile keeps its own fill: {}", app.ui.status); } app.run("object.pattern.done", json!({})).unwrap(); - app.run("select.set", json!({"ids": [art]})).unwrap(); } }