From 14a27b360f793cc6b45d3d0232e25d7889d12e3e Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Fri, 6 Nov 2026 20:18:16 +0100 Subject: [PATCH 1/4] Magnetic Lasso: a right-click while drawing opens no menu (#11689) With a Magnetic Lasso border in progress, a right-click on the canvas opened the selection tools' menu over the live border, in the window and over the control channel. As in Photoshop, it now opens nothing and the border stays live: Enter or Esc still close or cancel it. With no border in progress the menu opens as before. Cmd/Ctrl+right-click (the layer list) is unchanged, since it was not measured. Tests in crates/ui-egui/tests/it/magnetic_lasso_right_click.rs drive both paths; the two "while drawing" tests fail without the fix. --- crates/ui-egui/src/canvas.rs | 4 + crates/ui-egui/src/control/dispatch.rs | 4 + .../tests/it/magnetic_lasso_right_click.rs | 176 ++++++++++++++++++ crates/ui-egui/tests/it/main.rs | 1 + 4 files changed, 185 insertions(+) create mode 100644 crates/ui-egui/tests/it/magnetic_lasso_right_click.rs diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 2acba730f4..dca3941de9 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -911,10 +911,14 @@ fn handle_canvas_tool_menus(app: &mut PhotocraftApp, input: &CanvasToolInput<'_> crate::canvas_tool_menu::open_pasteboard(app, ctx, tool, [p.x, p.y]); } } + // A Magnetic Lasso border being drawn: no menu over it, and the border stays live, as in + // Photoshop (#11689). + let magnetic_drawing = tool == Tool::MagneticLasso && app.ui.magnetic.active(); if right_click && !lasso_retracted && !transforming && !guide_menu + && !magnetic_drawing && !crate::layer_pick_ui::is_gesture(tool, mods) && let Some(p) = right_at { diff --git a/crates/ui-egui/src/control/dispatch.rs b/crates/ui-egui/src/control/dispatch.rs index 6f81a7d4d9..888d9fe661 100644 --- a/crates/ui-egui/src/control/dispatch.rs +++ b/crates/ui-egui/src/control/dispatch.rs @@ -1436,6 +1436,10 @@ fn secondary_transform_or_crop_took(app: &mut PhotocraftApp, ctx: &egui::Context fn secondary_canvas_menu_took(app: &mut PhotocraftApp, ctx: &egui::Context, g: &PointerGesture, s: &PointerSample) -> bool { let (x, y) = (s.x, s.y); let down = matches!(s.ev, ToolEvent::Down { .. }); + // A Magnetic Lasso border being drawn: no menu over it, as on the canvas (#11689). + if app.ui.tool == crate::state::Tool::MagneticLasso && app.ui.magnetic.active() { + return true; + } if crate::canvas_tool_menu::pasteboard_at(app, app.ui.tool, [x, y]) { if down { crate::canvas_tool_menu::open_pasteboard(app, ctx, app.ui.tool, screen_point(app, x, y)); diff --git a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs new file mode 100644 index 0000000000..27fbff4588 --- /dev/null +++ b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs @@ -0,0 +1,176 @@ +//! Magnetic Lasso: a right-click while a border is being drawn opens no menu (#11689). +//! +//! Measured in Photoshop: with a Magnetic Lasso border in progress, a right-click on the canvas +//! opens nothing and changes nothing; the border stays live, and ↩ still closes it. With no border +//! in progress the right-click opens the selection tools' menu as before. PhotoCraft opened that +//! menu over the live border, from the canvas and from the control channel alike. +//! +//! The border is drawn with ⌥-clicks (straight segments), so its points don't depend on edges. +//! No GPU needed. + +use egui::{Event, Modifiers, PointerButton}; +use photocraft_ui_egui::PhotocraftApp; +use photocraft_ui_egui::canvas::ViewXform; +use photocraft_ui_egui::control::{ControlRequest, Outcome, handle}; +use serde_json::{Value, json}; + +type Harness = egui_kittest::Harness<'static, PhotocraftApp>; + +/// The border's corners: a plain click starts it, ⌥-clicks add the others. +const CORNERS: [[f64; 2]; 3] = [[50.0, 50.0], [250.0, 50.0], [150.0, 200.0]]; + +/// Where the right-click goes: inside the border, on the image. +const INSIDE: [f64; 2] = [150.0, 100.0]; + +fn app() -> PhotocraftApp { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).expect("new document"); + app.sync_views(); + app +} + +fn call(app: &mut PhotocraftApp, method: &str, params: Value) -> Value { + let ctx = egui::Context::default(); + let (req, _rx) = ControlRequest::new(method, params); + let Outcome::Done(v) = handle(app, &ctx, &req) else { panic!("{method} didn't finish") }; + v +} + +fn pointer(app: &mut PhotocraftApp, params: Value) { + let v = call(app, "ui.pointer", params); + assert_eq!(v["ok"], true, "{v}"); +} + +/// Clicks at `p` through `ui.pointer` with the Magnetic Lasso. +fn agent_click(app: &mut PhotocraftApp, p: [f64; 2], button: &str, alt: bool) { + let events = json!([{"kind": "down", "x": p[0], "y": p[1]}, {"kind": "up", "x": p[0], "y": p[1]}]); + pointer(app, json!({"tool": "MagneticLasso", "button": button, "alt": alt, "events": events})); +} + +/// `ui.inspect`'s Magnetic Lasso border and canvas tool menu. +fn inspect(app: &mut PhotocraftApp) -> (Value, Value) { + let v = call(app, "ui.inspect", json!({})); + let r = &v["result"]; + (r["magnetic"].clone(), r["canvasToolMenu"].clone()) +} + +#[test] +fn agent_right_click_while_drawing_opens_no_menu_and_keeps_the_border() { + let mut app = app(); + agent_click(&mut app, CORNERS[0], "left", false); + agent_click(&mut app, CORNERS[1], "left", true); + agent_click(&mut app, CORNERS[2], "left", true); + let (before, menu) = inspect(&mut app); + assert!(menu.is_null(), "no menu yet: {menu}"); + assert_eq!(before["anchors"].as_array().map(Vec::len), Some(3), "a border is in progress: {before}"); + + agent_click(&mut app, INSIDE, "right", false); + let (after, menu) = inspect(&mut app); + assert!(menu.is_null(), "a right-click over a live border opens no menu: {menu}"); + assert_eq!(after["path"], before["path"], "the border is unchanged"); + assert_eq!(after["anchors"], before["anchors"], "its fastening points are unchanged"); + assert!(app.session.active().expect("a document").doc.selection.is_none(), "nothing is selected yet"); + + // The border is still live: closing it selects it. + photocraft_ui_egui::magnetic_lasso_ui::close(&mut app, true); + let sel = app.session.active().expect("a document").doc.selection.as_ref().expect("the border closed into a selection"); + assert!(sel.sample_channel(150, 100, 0) > 0.9, "the inside is selected"); +} + +#[test] +fn agent_right_click_without_a_border_still_opens_the_selection_menu() { + let mut app = app(); + agent_click(&mut app, INSIDE, "right", false); + let (magnetic, menu) = inspect(&mut app); + assert_eq!(magnetic["path"], json!([]), "a right-click starts no border"); + let entries = menu["entries"].as_array().expect("the selection menu opened"); + assert!(entries.iter().any(|e| e["id"] == "select.all"), "{menu}"); +} + +/// The app's document area alone, at 100 %, the Magnetic Lasso selected. +fn harness() -> Harness { + let mut app = app(); + app.ui.tool = photocraft_ui_egui::state::Tool::MagneticLasso; + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1000.0, 700.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + let ctx = ui.ctx().clone(); + if !ctx.fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + photocraft_ui_egui::shortcuts::handle(app, &ctx); + egui::CentralPanel::default().show(ui, |ui| photocraft_ui_egui::canvas::document_area(app, ui)); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, Default::default()); + h.run_steps(4); + let v = &mut h.state_mut().ui.views[0]; + (v.zoom, v.center, v.fit_pending) = (1.0, [200.0, 150.0], false); + h.run_steps(2); + h +} + +/// The screen point of document point `p`. +fn screen(h: &Harness, p: [f64; 2]) -> egui::Pos2 { + let app = h.state(); + let v = &app.ui.views[0]; + let xf = ViewXform { + rect: photocraft_ui_egui::rulers::content_rect(app, app.last_canvas_rect), + zoom: v.zoom, + center: v.center, + flip: false, + rotation: v.rotation, + aspect: 1.0, + }; + xf.to_screen(p[0] as f32, p[1] as f32) +} + +/// Moves the pointer to `p`. +fn hover(h: &mut Harness, p: [f64; 2], modifiers: Modifiers) { + let pos = screen(h, p); + h.event(Event::ModifiersChanged(modifiers)); + h.event(Event::PointerMoved(pos)); + h.run_steps(2); +} + +fn mouse_click(h: &mut Harness, p: [f64; 2], button: PointerButton, modifiers: Modifiers) { + hover(h, p, modifiers); + let pos = screen(h, p); + h.event(Event::PointerButton { pos, button, pressed: true, modifiers }); + h.run_steps(1); + h.event(Event::PointerButton { pos, button, pressed: false, modifiers }); + h.run_steps(2); +} + +#[test] +fn canvas_right_click_while_drawing_opens_no_menu_and_enter_still_closes_the_border() { + let mut h = harness(); + mouse_click(&mut h, CORNERS[0], PointerButton::Primary, Modifiers::NONE); + mouse_click(&mut h, CORNERS[1], PointerButton::Primary, Modifiers::ALT); + mouse_click(&mut h, CORNERS[2], PointerButton::Primary, Modifiers::ALT); + // The pointer goes where the right-click will be first: moves with the button up fasten points + // along the way, as they should. + hover(&mut h, INSIDE, Modifiers::NONE); + let before = h.state().ui.magnetic.clone(); + assert!(before.anchors.len() >= 3, "a border is in progress: {before:?}"); + + mouse_click(&mut h, INSIDE, PointerButton::Secondary, Modifiers::NONE); + assert!(h.state().ui.canvas_tool_menu.is_none(), "a right-click over a live border opens no menu"); + let after = &h.state().ui.magnetic; + assert_eq!((&after.path, &after.anchors), (&before.path, &before.anchors), "the border is unchanged"); + + h.event(Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }); + h.event(Event::Key { key: egui::Key::Enter, physical_key: None, pressed: false, repeat: false, modifiers: Modifiers::NONE }); + h.run_steps(2); + assert!(!h.state().ui.magnetic.active(), "↩ closed the border"); + let sel = h.state().session.active().expect("a document").doc.selection.as_ref().expect("the border closed into a selection"); + assert!(sel.sample_channel(150, 100, 0) > 0.9, "the inside is selected"); +} + +#[test] +fn canvas_right_click_without_a_border_still_opens_the_selection_menu() { + let mut h = harness(); + mouse_click(&mut h, INSIDE, PointerButton::Secondary, Modifiers::NONE); + assert!(!h.state().ui.magnetic.active(), "a right-click starts no border"); + assert!(h.state().ui.canvas_tool_menu.is_some(), "the selection menu opened"); +} diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index b8fdb2987d..8cb0fc0938 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -28,6 +28,7 @@ mod full_res_preview; mod gpu_device_loss; mod layout_perf; mod live_stroke_canvas; +mod magnetic_lasso_right_click; mod marching_ants_pixels; mod marquee_autoscroll; mod paint_bucket_all_layers; From 8519977bc1ea4aa40bb09d80fec75fe24d220f3a Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Fri, 6 Nov 2026 21:06:45 +0100 Subject: [PATCH 2/4] Magnetic Lasso: a border on another document holds back no menu (#11689) The right-click check asked only whether a border existed. Over the control channel no frame runs between events, so a border left on one document stayed in place after a switch and kept the selection menu from opening on the next. The check, now magnetic_lasso_ui::drawing, also asks that the border belongs to the document in front, the same test frame() uses to drop a stale border. The canvas, the control channel and frame() share it. agent_right_click_on_another_document_still_opens_the_selection_menu fails without this change. The context-menu parity doc records the behaviour. --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/control/dispatch.rs | 2 +- crates/ui-egui/src/tools/magnetic_lasso_ui.rs | 11 +++++++++-- .../tests/it/magnetic_lasso_right_click.rs | 17 +++++++++++++++++ docs/context-menu-parity.md | 5 +++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index dca3941de9..6c9af248e4 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -913,7 +913,7 @@ fn handle_canvas_tool_menus(app: &mut PhotocraftApp, input: &CanvasToolInput<'_> } // A Magnetic Lasso border being drawn: no menu over it, and the border stays live, as in // Photoshop (#11689). - let magnetic_drawing = tool == Tool::MagneticLasso && app.ui.magnetic.active(); + let magnetic_drawing = crate::magnetic_lasso_ui::drawing(app); if right_click && !lasso_retracted && !transforming diff --git a/crates/ui-egui/src/control/dispatch.rs b/crates/ui-egui/src/control/dispatch.rs index 888d9fe661..13f462f25f 100644 --- a/crates/ui-egui/src/control/dispatch.rs +++ b/crates/ui-egui/src/control/dispatch.rs @@ -1437,7 +1437,7 @@ fn secondary_canvas_menu_took(app: &mut PhotocraftApp, ctx: &egui::Context, g: & let (x, y) = (s.x, s.y); let down = matches!(s.ev, ToolEvent::Down { .. }); // A Magnetic Lasso border being drawn: no menu over it, as on the canvas (#11689). - if app.ui.tool == crate::state::Tool::MagneticLasso && app.ui.magnetic.active() { + if crate::magnetic_lasso_ui::drawing(app) { return true; } if crate::canvas_tool_menu::pasteboard_at(app, app.ui.tool, [x, y]) { diff --git a/crates/ui-egui/src/tools/magnetic_lasso_ui.rs b/crates/ui-egui/src/tools/magnetic_lasso_ui.rs index 28ef343212..442c5dbf34 100644 --- a/crates/ui-egui/src/tools/magnetic_lasso_ui.rs +++ b/crates/ui-egui/src/tools/magnetic_lasso_ui.rs @@ -365,10 +365,17 @@ pub fn replaces_selection(app: &PhotocraftApp) -> bool { app.ui.magnetic.active() && app.ui.magnetic.mode == "replace" } +/// The Magnetic Lasso is drawing a border on the document in front. A border left behind by a +/// tool or document switch doesn't count, even before [`frame`] drops it: the control channel's +/// events run no frame. +pub fn 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) +} + /// Once a frame: a border left behind by a tool or document switch is dropped. pub fn frame(app: &mut PhotocraftApp) { - let m = &app.ui.magnetic; - if m.active() && (app.ui.tool != Tool::MagneticLasso || app.session.active().map(|d| d.doc.id.0) != Some(m.doc)) { + if app.ui.magnetic.active() && !drawing(app) { cancel(app); } } diff --git a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs index 27fbff4588..99dd83997a 100644 --- a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs +++ b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs @@ -77,6 +77,23 @@ fn agent_right_click_while_drawing_opens_no_menu_and_keeps_the_border() { assert!(sel.sample_channel(150, 100, 0) > 0.9, "the inside is selected"); } +#[test] +fn agent_right_click_on_another_document_still_opens_the_selection_menu() { + // A border left on the first document doesn't hold the menu back on the second: the agent's + // events run no frame, so nothing has dropped that border yet. + let mut app = app(); + agent_click(&mut app, CORNERS[0], "left", false); + agent_click(&mut app, CORNERS[1], "left", true); + app.run("file.new", json!({"width": 400, "height": 300})).expect("second document"); + app.sync_views(); + assert!(app.ui.magnetic.active(), "the first document's border is still there"); + + 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(); diff --git a/docs/context-menu-parity.md b/docs/context-menu-parity.md index 1ef971ef33..c0eca73f08 100644 --- a/docs/context-menu-parity.md +++ b/docs/context-menu-parity.md @@ -1,6 +1,6 @@ # Context-menu parity contract -> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-21 · **Change:** minor (Crop tool menu on a pending crop, #6561; Zoom tool menu order, #6005; Type tool menu over committed type, #7324; earlier: Path Selection canvas menu, #1056; pasteboard row: the menu exists, #2462) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-11-06 · **Change:** minor (Magnetic Lasso: no menu over a border being drawn, #11689; earlier: Crop tool menu on a pending crop, #6561; Zoom tool menu order, #6005; Type tool menu over committed type, #7324; earlier: Path Selection canvas menu, #1056; pasteboard row: the menu exists, #2462) · **Target:** Adobe Photoshop 2026 Status: implementation contract, updated 2026-10-09. Scope: canvas, document tabs, and panels. “Right-click” means a secondary pointer click; macOS Control-click should also open the same menu where the platform sends a context-menu gesture. Photoshop changes a context menu with the active tool, selection, and panel item. Adobe documents that principle but does not publish a complete current menu catalog. **Documented** means an Adobe source explicitly names the gesture or action. **Inferred** means a PhotoCraft design target or an item known from a main menu whose presence in a Photoshop context menu still needs a current-product capture. Do not present inferred rows as exact Photoshop menus. [Adobe: panels and menus](https://helpx.adobe.com/photoshop/using/panels-menus.html), [Adobe: shortcuts and context menus](https://helpx.adobe.com/sa_en/photoshop/using/customizing-keyboard-shortcuts.html). @@ -21,7 +21,7 @@ The “PhotoCraft at branch point” column records behavior before this PR. Pic | Tool(s) in PhotoCraft | Photoshop / desired contextual action | PhotoCraft at branch point | Priority, evidence | |---|---|---|---| | Move | Choose a layer at the point; an auto-select choice also exists in the options bar | Layers | P0; [Adobe layer movement](https://helpx.adobe.com/photoshop/using/moving-stacking-locking-layers.html); exact pop-up layout requires capture | -| Rectangular/Elliptical Marquee, Lasso, Polygonal Lasso, Magnetic Lasso, Magic Wand, Quick Selection, Object Selection | Active selection: the 2026 selection menu (see *Selection canvas reference* below); no selection: making a selection | Quick Selection: Picker (a brush tool, as in Photoshop); the other six: the selection menu below (#614, #738) | P1; no-selection variant still needs a dated capture | +| Rectangular/Elliptical Marquee, Lasso, Polygonal Lasso, Magnetic Lasso, Magic Wand, Quick Selection, Object Selection | Active selection: the 2026 selection menu (see *Selection canvas reference* below); no selection: making a selection | Quick Selection: Picker (a brush tool, as in Photoshop); the other six: the selection menu below (#614, #738). A Magnetic Lasso border being drawn gets no menu, and the border stays live (measured in Photoshop, #11689); ⌘/Ctrl+right-click still lists the layers | P1; no-selection variant still needs a dated capture | | Crop | During crop: ratio/preset, overlay, clear/reset, commit/cancel **(inferred context placement)** | On a pending crop (canvas_tool_menu.rs `crop_rows`, #6561): the options bar's preset dropdown in its order (Ratio, W x H x Resolution, the ratios, the size presets, saved crop presets, Front Image), Clear, New/Delete Crop Preset…, the six overlays and Auto/Always/Never Show Overlay (checked as in the bar), Cancel and Crop; also outside the image while a crop is pending. The untouched default frame has no menu. Esc closes only the menu. Reset remains open (no reset of frame, rotation and ratio yet, nor the options bar's ↺). Photoshop's menu also lists Reset Crop and Rotate Crop Box ([Kost](https://jkost.com/blog/2017/05/essential-tips-for-cropping-in-photoshop-cc.html)); both missing | P1; pending crop target; item list still needs a dated Photoshop capture | | Eyedropper | Sample-size/source choices **(inferred)** | No tool menu | P2; [Adobe illustration uses Eyedropper](https://helpx.adobe.com/photoshop/using/panels-menus.html), but does not publish item text | | Ruler, Note, Count | Unit / measurement, note edit/delete, count-group operations **(inferred)** | No tool menu | P2 | @@ -100,6 +100,7 @@ Each slice needs pure model tests (including every item dispatching a known comm | Date | Change | Summary | |---|---|---| +| 2026-11-06 | minor | Magnetic Lasso: no menu over a border being drawn (#11689) | | 2026-10-21 | minor | Crop tool menu on a pending crop (#6561) | | 2026-10-20 | trivial | Zoom tool menu order (#6005) | | 2026-10-18 | minor | Type tool menu over committed type (#7324) | From b471935d75f6677664e0c2221e71c25ea84dd3ff Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Fri, 6 Nov 2026 21:20:05 +0100 Subject: [PATCH 3/4] Magnetic Lasso right-click: keep to the files #11689 names The issue lists the files this item may touch and leaves the parity docs to its epic. The right-click check moves from magnetic_lasso_ui.rs to canvas_tool_menu.rs as magnetic_drawing, where the issue allows it, with the same document check. magnetic_lasso_ui.rs and docs/context-menu-parity.md are back as on main. --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/canvas/canvas_tool_menu.rs | 9 +++++++++ crates/ui-egui/src/control/dispatch.rs | 2 +- crates/ui-egui/src/tools/magnetic_lasso_ui.rs | 11 ++--------- docs/context-menu-parity.md | 5 ++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 6c9af248e4..3fcf22afd4 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -913,7 +913,7 @@ fn handle_canvas_tool_menus(app: &mut PhotocraftApp, input: &CanvasToolInput<'_> } // A Magnetic Lasso border being drawn: no menu over it, and the border stays live, as in // Photoshop (#11689). - let magnetic_drawing = crate::magnetic_lasso_ui::drawing(app); + let magnetic_drawing = crate::canvas_tool_menu::magnetic_drawing(app); if right_click && !lasso_retracted && !transforming diff --git a/crates/ui-egui/src/canvas/canvas_tool_menu.rs b/crates/ui-egui/src/canvas/canvas_tool_menu.rs index f633dc91e0..568e1f104e 100644 --- a/crates/ui-egui/src/canvas/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas/canvas_tool_menu.rs @@ -464,6 +464,15 @@ pub fn applies(tool: Tool) -> bool { ) || path_menu(tool) } +/// 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. +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) +} + /// Tools whose canvas right-click opens the path menu ([`PEN_MENU`]): the Pen, and the Path /// Selection and Direct Selection tools, whose Photoshop menu offers the same whole-path actions /// for the selected path (#1056). diff --git a/crates/ui-egui/src/control/dispatch.rs b/crates/ui-egui/src/control/dispatch.rs index 13f462f25f..3ce9c3834f 100644 --- a/crates/ui-egui/src/control/dispatch.rs +++ b/crates/ui-egui/src/control/dispatch.rs @@ -1437,7 +1437,7 @@ fn secondary_canvas_menu_took(app: &mut PhotocraftApp, ctx: &egui::Context, g: & let (x, y) = (s.x, s.y); let down = matches!(s.ev, ToolEvent::Down { .. }); // A Magnetic Lasso border being drawn: no menu over it, as on the canvas (#11689). - if crate::magnetic_lasso_ui::drawing(app) { + if crate::canvas_tool_menu::magnetic_drawing(app) { return true; } if crate::canvas_tool_menu::pasteboard_at(app, app.ui.tool, [x, y]) { diff --git a/crates/ui-egui/src/tools/magnetic_lasso_ui.rs b/crates/ui-egui/src/tools/magnetic_lasso_ui.rs index 442c5dbf34..28ef343212 100644 --- a/crates/ui-egui/src/tools/magnetic_lasso_ui.rs +++ b/crates/ui-egui/src/tools/magnetic_lasso_ui.rs @@ -365,17 +365,10 @@ pub fn replaces_selection(app: &PhotocraftApp) -> bool { app.ui.magnetic.active() && app.ui.magnetic.mode == "replace" } -/// The Magnetic Lasso is drawing a border on the document in front. A border left behind by a -/// tool or document switch doesn't count, even before [`frame`] drops it: the control channel's -/// events run no frame. -pub fn 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) -} - /// Once a frame: a border left behind by a tool or document switch is dropped. pub fn frame(app: &mut PhotocraftApp) { - if app.ui.magnetic.active() && !drawing(app) { + let m = &app.ui.magnetic; + if m.active() && (app.ui.tool != Tool::MagneticLasso || app.session.active().map(|d| d.doc.id.0) != Some(m.doc)) { cancel(app); } } diff --git a/docs/context-menu-parity.md b/docs/context-menu-parity.md index c0eca73f08..1ef971ef33 100644 --- a/docs/context-menu-parity.md +++ b/docs/context-menu-parity.md @@ -1,6 +1,6 @@ # Context-menu parity contract -> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-11-06 · **Change:** minor (Magnetic Lasso: no menu over a border being drawn, #11689; earlier: Crop tool menu on a pending crop, #6561; Zoom tool menu order, #6005; Type tool menu over committed type, #7324; earlier: Path Selection canvas menu, #1056; pasteboard row: the menu exists, #2462) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-21 · **Change:** minor (Crop tool menu on a pending crop, #6561; Zoom tool menu order, #6005; Type tool menu over committed type, #7324; earlier: Path Selection canvas menu, #1056; pasteboard row: the menu exists, #2462) · **Target:** Adobe Photoshop 2026 Status: implementation contract, updated 2026-10-09. Scope: canvas, document tabs, and panels. “Right-click” means a secondary pointer click; macOS Control-click should also open the same menu where the platform sends a context-menu gesture. Photoshop changes a context menu with the active tool, selection, and panel item. Adobe documents that principle but does not publish a complete current menu catalog. **Documented** means an Adobe source explicitly names the gesture or action. **Inferred** means a PhotoCraft design target or an item known from a main menu whose presence in a Photoshop context menu still needs a current-product capture. Do not present inferred rows as exact Photoshop menus. [Adobe: panels and menus](https://helpx.adobe.com/photoshop/using/panels-menus.html), [Adobe: shortcuts and context menus](https://helpx.adobe.com/sa_en/photoshop/using/customizing-keyboard-shortcuts.html). @@ -21,7 +21,7 @@ The “PhotoCraft at branch point” column records behavior before this PR. Pic | Tool(s) in PhotoCraft | Photoshop / desired contextual action | PhotoCraft at branch point | Priority, evidence | |---|---|---|---| | Move | Choose a layer at the point; an auto-select choice also exists in the options bar | Layers | P0; [Adobe layer movement](https://helpx.adobe.com/photoshop/using/moving-stacking-locking-layers.html); exact pop-up layout requires capture | -| Rectangular/Elliptical Marquee, Lasso, Polygonal Lasso, Magnetic Lasso, Magic Wand, Quick Selection, Object Selection | Active selection: the 2026 selection menu (see *Selection canvas reference* below); no selection: making a selection | Quick Selection: Picker (a brush tool, as in Photoshop); the other six: the selection menu below (#614, #738). A Magnetic Lasso border being drawn gets no menu, and the border stays live (measured in Photoshop, #11689); ⌘/Ctrl+right-click still lists the layers | P1; no-selection variant still needs a dated capture | +| Rectangular/Elliptical Marquee, Lasso, Polygonal Lasso, Magnetic Lasso, Magic Wand, Quick Selection, Object Selection | Active selection: the 2026 selection menu (see *Selection canvas reference* below); no selection: making a selection | Quick Selection: Picker (a brush tool, as in Photoshop); the other six: the selection menu below (#614, #738) | P1; no-selection variant still needs a dated capture | | Crop | During crop: ratio/preset, overlay, clear/reset, commit/cancel **(inferred context placement)** | On a pending crop (canvas_tool_menu.rs `crop_rows`, #6561): the options bar's preset dropdown in its order (Ratio, W x H x Resolution, the ratios, the size presets, saved crop presets, Front Image), Clear, New/Delete Crop Preset…, the six overlays and Auto/Always/Never Show Overlay (checked as in the bar), Cancel and Crop; also outside the image while a crop is pending. The untouched default frame has no menu. Esc closes only the menu. Reset remains open (no reset of frame, rotation and ratio yet, nor the options bar's ↺). Photoshop's menu also lists Reset Crop and Rotate Crop Box ([Kost](https://jkost.com/blog/2017/05/essential-tips-for-cropping-in-photoshop-cc.html)); both missing | P1; pending crop target; item list still needs a dated Photoshop capture | | Eyedropper | Sample-size/source choices **(inferred)** | No tool menu | P2; [Adobe illustration uses Eyedropper](https://helpx.adobe.com/photoshop/using/panels-menus.html), but does not publish item text | | Ruler, Note, Count | Unit / measurement, note edit/delete, count-group operations **(inferred)** | No tool menu | P2 | @@ -100,7 +100,6 @@ Each slice needs pure model tests (including every item dispatching a known comm | Date | Change | Summary | |---|---|---| -| 2026-11-06 | minor | Magnetic Lasso: no menu over a border being drawn (#11689) | | 2026-10-21 | minor | Crop tool menu on a pending crop (#6561) | | 2026-10-20 | trivial | Zoom tool menu order (#6005) | | 2026-10-18 | minor | Type tool menu over committed type (#7324) | From 9d16699d45dbcb156ef910b6af7add882bd5c9e5 Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:21:45 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Magnetic=20Lasso=20right-click:=20an=20?= =?UTF-8?q?=E2=8C=A5-drag's=20freehand=20segment=20keeps=20its=20menu=20(#?= =?UTF-8?q?11689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/ui-egui/src/canvas/canvas_tool_menu.rs | 5 +++-- .../tests/it/magnetic_lasso_right_click.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/canvas_tool_menu.rs b/crates/ui-egui/src/canvas/canvas_tool_menu.rs index 568e1f104e..b2e377e0ec 100644 --- a/crates/ui-egui/src/canvas/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas/canvas_tool_menu.rs @@ -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 diff --git a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs index 99dd83997a..7e2079c8a4 100644 --- a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs +++ b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs @@ -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();