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.
This commit is contained in:
dotCooCoo
2026-11-17 07:59:01 -08:00
parent 02da66521f
commit c0342e63aa
2 changed files with 18 additions and 11 deletions
+4 -4
View File
@@ -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)));
}
}
+14 -7
View File
@@ -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();
}
}