Magnetic Lasso right-click: an ⌥-drag's freehand segment keeps its menu (#11689)

The issue leaves a right-click during an ⌥-drag unmeasured, so it keeps
today's behaviour. `magnetic_drawing` held that menu back too; it now
skips a freehand segment.
This commit is contained in:
RickiNano committed 2026-11-06 22:21:45 +01:00
1 parent b471935d75
commit 9d16699d45
2 files changed
+19 -2

No files matched your search

@@ -467,10 +467,11 @@ pub fn applies(tool: Tool) -> bool {
/// A Magnetic Lasso border is being drawn on the document in front: a right-click opens no menu
/// over it, and the border stays live, as in Photoshop (#11689). A border left on another
/// document doesn't count, even before `magnetic_lasso_ui::frame` drops it: the control
/// channel's events run no frame.
/// channel's events run no frame. Nor does an ⌥-drag's freehand segment: that case wasn't
/// measured, so it keeps the menu it had.
pub fn magnetic_drawing(app: &PhotocraftApp) -> bool {
let m = &app.ui.magnetic;
m.active() && app.ui.tool == Tool::MagneticLasso && app.session.active().map(|d| d.doc.id.0) == Some(m.doc)
m.active() && !m.freehand && app.ui.tool == Tool::MagneticLasso && app.session.active().map(|d| d.doc.id.0) == Some(m.doc)
}
/// Tools whose canvas right-click opens the path menu ([`PEN_MENU`]): the Pen, and the Path
@@ -94,6 +94,22 @@ fn agent_right_click_on_another_document_still_opens_the_selection_menu() {
assert!(entries.iter().any(|e| e["id"] == "select.all"), "{menu}");
}
#[test]
fn agent_right_click_during_an_alt_drag_still_opens_the_selection_menu() {
// Not measured in Photoshop: a right-click while an ⌥-drag draws a freehand segment keeps
// today's behaviour, the selection menu.
let mut app = app();
agent_click(&mut app, CORNERS[0], "left", false);
let events = json!([{"kind": "down", "x": CORNERS[1][0], "y": CORNERS[1][1]}, {"kind": "move", "x": 200.0, "y": 120.0}]);
pointer(&mut app, json!({"tool": "MagneticLasso", "alt": true, "events": events}));
assert!(app.ui.magnetic.freehand, "an ⌥-drag is drawing a freehand segment");
agent_click(&mut app, INSIDE, "right", false);
let (_, menu) = inspect(&mut app);
let entries = menu["entries"].as_array().expect("the selection menu opened");
assert!(entries.iter().any(|e| e["id"] == "select.all"), "{menu}");
}
#[test]
fn agent_right_click_without_a_border_still_opens_the_selection_menu() {
let mut app = app();