mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 01:18:43 +00:00
Filter preview locator: drop a press made during an open tool drag
A ui.pointer press while a Brush or Crop gesture begun before the dialog was still open centred the preview and held a locator press, but the moves and release that followed went to the earlier gesture, so the preview stopped following and the stroke or frame changed instead. No mouse can press twice, so drop that press: it neither centres the preview nor reaches the tool, and the open gesture still finishes on its own moves and release. Tested, and the Crop test now checks the frame after the move as well as after the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e71659736
commit
fba4db2851
2 files changed
+30
-3
No files matched your search
@@ -1228,15 +1228,17 @@ fn pointer_event_intercepted(app: &mut PhotocraftApp, ctx: &egui::Context, g: &P
|
||||
/// (#9648). A press or drag with the primary button centres the window there; every other event
|
||||
/// is consumed too, so nothing reaches the tool under the dialog, except the moves and release of
|
||||
/// a tool gesture begun before the dialog opened, which finish it along the path they draw. A Crop
|
||||
/// frame or Straighten drag is one too, though the Crop tool keeps it apart from `app.drag`.
|
||||
/// frame or Straighten drag is one too, though the Crop tool keeps it apart from `app.drag`. While
|
||||
/// one is open, a second primary press (no mouse can make one) is dropped: it neither centres the
|
||||
/// window nor reaches the tool, so no locator press splits the gesture's moves and release.
|
||||
fn preview_locator_took(app: &mut PhotocraftApp, g: &PointerGesture, s: &PointerSample) -> bool {
|
||||
if crate::filter_preview_ui::locator(app).is_none() {
|
||||
return false;
|
||||
}
|
||||
let (down, up) = (matches!(s.ev, ToolEvent::Down { .. }), matches!(s.ev, ToolEvent::Up { .. }));
|
||||
let tool_gesture = app.drag.is_some() || app.crop.drag.is_some() || app.crop.straighten.line.is_some();
|
||||
if !down && !g.secondary && !g.middle && tool_gesture {
|
||||
return false;
|
||||
if !g.secondary && !g.middle && tool_gesture {
|
||||
return down;
|
||||
}
|
||||
if !g.secondary && !g.middle && !g.space {
|
||||
crate::filter_preview_ui::pointer_event(app, down, up, s.x, s.y);
|
||||
|
||||
@@ -282,9 +282,34 @@ fn a_crop_drag_begun_before_the_dialog_still_ends_under_it() {
|
||||
crate::filter_dialog::open(h.state_mut(), "filter.sharpen.smartSharpen").unwrap();
|
||||
h.run_steps(2);
|
||||
pointer(&mut h, json!([{"kind": "move", "x": 160, "y": 120}]));
|
||||
let r = h.state().ui.crop_rect.expect("a crop frame");
|
||||
assert!(r[2] > 150.0 && r[3] > 110.0, "the move under the dialog reached the frame before the release: {r:?}");
|
||||
pointer(&mut h, json!([{"kind": "up", "x": 160, "y": 120}]));
|
||||
assert!(h.state().crop.drag.is_none(), "the release reached the Crop tool");
|
||||
let r = h.state().ui.crop_rect.expect("a crop frame");
|
||||
assert!(r[2] > 150.0 && r[3] > 110.0, "the moves under the dialog reached the frame: {r:?}");
|
||||
assert!(near(centre(&h), [200.0, 150.0]), "the drag's moves and release are not locator presses: {:?}", centre(&h));
|
||||
}
|
||||
|
||||
/// A second press while an agent's Brush stroke is still open (no mouse can make one) is dropped:
|
||||
/// it neither centres the preview nor reaches the Brush, and the stroke's own moves and release
|
||||
/// still finish it.
|
||||
#[test]
|
||||
fn a_press_during_an_open_tool_gesture_is_dropped() {
|
||||
let mut h = harness(None, 0.0);
|
||||
let before = edits(&h);
|
||||
pointer(&mut h, json!([{"kind": "down", "x": 40, "y": 30}, {"kind": "move", "x": 80, "y": 30}]));
|
||||
crate::filter_dialog::open(h.state_mut(), "filter.sharpen.smartSharpen").unwrap();
|
||||
h.run_steps(2);
|
||||
let points = h.state().drag.as_ref().map(|d| d.points.len()).unwrap_or_default();
|
||||
pointer(&mut h, json!([{"kind": "down", "x": 300, "y": 200}]));
|
||||
assert!(near(centre(&h), [200.0, 150.0]), "the extra press doesn't centre the preview: {:?}", centre(&h));
|
||||
assert_eq!(h.state().drag.as_ref().map(|d| d.points.len()), Some(points), "nor does it reach the open stroke");
|
||||
pointer(&mut h, json!([{"kind": "move", "x": 80, "y": 120}]));
|
||||
assert!(near(centre(&h), [200.0, 150.0]), "the stroke's moves are not a locator drag: {:?}", centre(&h));
|
||||
let pts = h.state().drag.as_ref().map(|d| d.points.clone()).unwrap_or_default();
|
||||
assert!(pts.iter().any(|p| p[1] > 100.0), "the move reached the stroke: {pts:?}");
|
||||
pointer(&mut h, json!([{"kind": "up", "x": 80, "y": 120}]));
|
||||
assert!(h.state().drag.is_none(), "the release ended the stroke");
|
||||
assert_eq!(edits(&h).1, before.1 + 1, "the stroke is one history step");
|
||||
}
|
||||
Reference in new issue
Block a user