Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Path Selection: the canvas right-click opens the path menu, as the Pen's does (#1056)

Higgs32584944d0cf722e5
diff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rs
index da835a786..a02859c5c 100644
--- a/crates/ui-egui/src/canvas_tool_menu.rs
+++ b/crates/ui-egui/src/canvas_tool_menu.rs
@@ -284,8 +284,14 @@ pub fn applies(tool: Tool) -> bool {
| Tool::MagneticLasso
| Tool::MagicWand
| Tool::ObjectSelection
- | Tool::Pen
- )
+ ) || path_menu(tool)
+}
+
+/// 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).
+pub fn path_menu(tool: Tool) -> bool {
+ matches!(tool, Tool::Pen | Tool::PathSelection | Tool::DirectSelection)
}
/// Tools whose plain canvas right-click offers the view menu.
@@ -310,7 +316,7 @@ pub fn rows(menu: &CanvasToolMenu) -> &'static [Row] {
VIEW_MENU
} else if menu.text {
TYPE_EDIT_MENU
- } else if menu.tool == Tool::Pen {
+ } else if path_menu(menu.tool) {
PEN_MENU
} else {
selection_rows(menu.has_selection)
@@ -471,7 +477,7 @@ pub fn pasteboard_at(app: &PhotocraftApp, tool: Tool, doc: [f64; 2]) -> bool {
let Some(st) = app.session.active() else { return false };
let (w, h) = (f64::from(st.doc.size.width), f64::from(st.doc.size.height));
let outside = doc.iter().all(|v| v.is_finite()) && (doc[0] < 0.0 || doc[1] < 0.0 || doc[0] >= w || doc[1] >= h);
- outside && tool != Tool::Pen && !crate::paint_mouse::has_brush_picker(tool) && !crate::paint_mouse::right_erases(app, tool) && app.ui.text_edit.is_none()
+ outside && !path_menu(tool) && !crate::paint_mouse::has_brush_picker(tool) && !crate::paint_mouse::right_erases(app, tool) && app.ui.text_edit.is_none()
}
/// Right-click on the pasteboard: its colour menu at screen point `pos`.
@@ -572,7 +578,7 @@ pub fn entry_enabled(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str)
c => TYPE_EDIT_MENU.iter().flatten().any(|(_, id)| *id == c) && crate::menus::is_enabled(app, c),
};
}
- if menu.transform || menu.tool != Tool::Pen {
+ if menu.transform || !path_menu(menu.tool) {
return crate::menus::is_enabled(app, command);
}
let Some(st) = app.session.active() else { return false };
@@ -699,7 +705,7 @@ pub fn choose(app: &mut PhotocraftApp, ctx: &Context, command: &str) {
choose_spelling(app, &menu, command)
} else if menu.text {
choose_type(app, ctx, command)
- } else if menu.tool == Tool::Pen && !menu.transform {
+ } else if path_menu(menu.tool) && !menu.transform {
choose_pen(app, ctx, &menu, command)
} else if command == "select.toWorkPath" {
// Photoshop's Make Work Path… asks for the tolerance first.
@@ -1492,6 +1498,32 @@ mod tests {
assert!(app.session.active().unwrap().doc.selection.is_some());
}
+ /// #1056: the Path Selection and Direct Selection tools' right-click opens the path menu for
+ /// the selected path, as the Pen's does, instead of nothing.
+ #[test]
+ fn path_selection_tools_open_the_path_menu() {
+ for tool in [Tool::PathSelection, Tool::DirectSelection] {
+ let mut app = app();
+ app.ui.tool = Tool::Pen;
+ for (x, y) in [(2.0, 2.0), (20.0, 2.0), (20.0, 20.0)] {
+ crate::vector_ui::pen_down(&mut app, x, y, false);
+ crate::vector_ui::pen_up(&mut app);
+ }
+ crate::vector_ui::pen_commit(&mut app, false);
+ assert!(app.session.active().unwrap().doc.work_path.is_some());
+ app.ui.tool = tool;
+ assert!(applies(tool));
+ assert!(open(&mut app, &Context::default(), tool, [10.0, 10.0]), "{tool:?}");
+ let menu = app.ui.canvas_tool_menu.clone().unwrap();
+ assert_eq!(rows(&menu), PEN_MENU, "{tool:?}");
+ assert!(menu.has_path && entry_enabled(&app, &menu, "path.toSelection"), "{tool:?}");
+ choose(&mut app, &Context::default(), "path.toSelection");
+ let dialog = app.ui.dialogs.last().map(|d| d.id).unwrap();
+ crate::dialogs::confirm(&mut app, dialog).unwrap();
+ assert!(app.session.active().unwrap().doc.selection.is_some(), "{tool:?}: Make Selection made one");
+ }
+ }
+
#[test]
fn pen_menu_has_all_reference_rows_in_order_and_guards_unavailable_actions() {
let labels: Vec<_> = PEN_MENU.iter().map(|row| row.map(|(label, _)| label)).collect();
diff --git a/docs/context-menu-parity.md b/docs/context-menu-parity.md
index 76d6724b7..1e8abf9a6 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-13 · **Last updated:** 2026-10-13 · **Change:** minor (layer-mask thumbnail menu, #4575) · **Target:** Adobe Photoshop 2026
+> **Last reviewed:** 2026-10-13 · **Last updated:** 2026-10-15 · **Change:** minor (Path Selection canvas menu, #1056) · **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).
@@ -29,7 +29,7 @@ The “PhotoCraft at branch point” column records behavior before this PR. Pic
| Gradient, Paint Bucket | Gradient preset/type/mode or fill source/tolerance **(inferred context placement)** | No tool menu | P1 |
| Type | In text: cut/copy/paste, spelling suggestions, text formatting; outside text: type-layer action **(inferred context placement)** | While editing text (canvas_tool_menu.rs `TYPE_EDIT_MENU`): Undo, Cut, Copy, Paste, Select All (on the text), Check Spelling…, Find and Replace Text…, Faux Bold/Italic (checked), Rasterize Type, Create Work Path, Convert to Shape, Horizontal/Vertical and the anti-alias modes (checked), Convert to Paragraph/Point Text, Warp Text…; Esc closes only the menu. Over a misspelled word the menu starts with up to 3 spelling suggestions (replace the word) and Add to Dictionary (#4370); Ignore / Ignore All and the non-editing type-layer menu remain open | P1; separate editing and nonediting states; [Adobe type editing](https://helpx.adobe.com/photoshop/desktop/text-typography/get-started-with-text/edit-text.html) |
| Hand, Zoom | Fit on Screen, 100%, 200%, Print Size; zoom step choices **(inferred context placement)** | View menu (#3242): Zoom In, Zoom Out, Fit on Screen, Fill Screen, 100%, 200%, Print Size. Zoom In/Out step about the right-clicked point (Preferences › Tools › Zoom Clicked Point to Center centres it). Outside the image the pasteboard menu still wins. | P1; view actions stay out of document history; row order still needs a dated Photoshop capture |
-| Pen, Path Selection | Path/point actions, Make Selection, Fill/Stroke Path, Free Transform Path **(inferred context placement)** | Pen canvas right-click follows the user-provided 20-row Photoshop capture below. Paths rows offer Make Selection, Fill and Stroke. Path Selection's own canvas menu remains open. | P1; distinguish node, segment, path, and blank canvas |
+| Pen, Path Selection | Path/point actions, Make Selection, Fill/Stroke Path, Free Transform Path **(inferred context placement)** | Pen canvas right-click follows the user-provided 20-row Photoshop capture below. Paths rows offer Make Selection, Fill and Stroke. The Path Selection and Direct Selection tools open the same path menu for the selected path (#1056, 2026-10-15); node- and segment-specific rows remain open. | P1; distinguish node, segment, path, and blank canvas |
| Rectangle, Ellipse Shape, Triangle, Polygon, Line, Custom Shape | Shape/path operations, fill/stroke settings, transform **(inferred context placement)** | No tool menu | P2 |
| Slice, Slice Select | Slice properties, duplicate/delete, divide, guides **(inferred context placement)** | No tool menu | P2 |
| Any tool while Free Transform is active | Scale, Rotate, Skew, Distort, Perspective, Warp, rotate/flip variants, commit/cancel **(inferred exact context placement)** | Missing per docs/scorecard.md TOOL-214-5 | P0; transform operations [documented by Adobe](https://helpx.adobe.com/photoshop/desktop/crop-resize-transform/transform-manipulate-reshape/adjust-scale-rotation-and-perspective.html); type restrictions [documented here](https://helpx.adobe.com/photoshop/using/creating-type.html) |