From 772209808ba251d4b4cb8927ab8f24ce4e1fb322 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 14 Oct 2026 19:30:05 -0400 Subject: [PATCH 1/2] Pen options bar: Make Selection in Path mode (#5703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Photoshop's Pen options bar in Path mode offers "Make: Selection…". PhotoCraft had it only on the canvas's right-click menu. The options bar now has a Make Selection button (enabled when there's a path) that opens the same dialog for the path being drawn, finished into the Work Path first, or the active path. "Make Selection" gains its zh-Hans, zh-Hant and ko catalog rows. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas_tool_menu.rs | 40 ++++++++++++++++++++++++++ crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/vector_ui.rs | 12 ++++++++ 5 files changed, 55 insertions(+) diff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rs index da835a786f..92861a521c 100644 --- a/crates/ui-egui/src/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas_tool_menu.rs @@ -796,6 +796,20 @@ fn pen_dialog(app: &mut PhotocraftApp, command: &str, label: &str, name: &str) { spec_dialog(app, command, label, spec, fields); } +/// The Pen options bar's Make Selection (Path mode, #5703): the canvas menu's Make Selection… +/// dialog for the path being drawn (committed first, as the menu does) or the active path. +pub(crate) fn make_selection(app: &mut PhotocraftApp) -> Result<(), String> { + let pending = app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2); + let pending_layer = pending && (app.ui.tool_options.vector_mode == "shape" || app.ui.vector_mask_target); + if pending { + crate::vector_ui::pen_commit(app, false); + } + let name = if pending { Some(if pending_layer { "layer" } else { "work" }.to_string()) } else { crate::vector_ui::active_path_name(app) } + .ok_or_else(|| "No path is available for this action".to_string())?; + pen_dialog(app, "path.toSelection", "Make Selection…", &name); + Ok(()) +} + fn choose_pen(app: &mut PhotocraftApp, ctx: &Context, menu: &CanvasToolMenu, command: &str) -> Result<(), String> { if command == "select.isolateLayers" { crate::menus::invoke(app, ctx, command, json!({}))?; @@ -1492,6 +1506,32 @@ mod tests { assert!(app.session.active().unwrap().doc.selection.is_some()); } + /// #5703: the Pen options bar's Make Selection (Path mode) opens the same dialog for the path + /// being drawn (finished into the Work Path first), and OK selects inside it; with no path at + /// all it reports that instead. + #[test] + fn pen_options_bar_makes_a_selection_from_the_path() { + let mut app = app(); + app.ui.tool = Tool::Pen; + assert!(make_selection(&mut app).is_err(), "no path yet"); + assert!(app.ui.dialogs.is_empty()); + 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); + } + make_selection(&mut app).unwrap(); + let dialog = app.ui.dialogs.last().map(|d| d.id).unwrap(); + crate::dialogs::confirm(&mut app, dialog).unwrap(); + let st = app.session.active().unwrap(); + assert!(st.doc.work_path.is_some() && st.doc.selection.is_some()); + // The active (Work) path again, with no pen path in progress. + app.run("select.deselect", json!({})).unwrap(); + make_selection(&mut app).unwrap(); + 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()); + } + #[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/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index e76a3c9826..ab2bf52fd3 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3353,3 +3353,4 @@ curves Smooth 매끄럽게 # View › Guides › right-click a guide Edit Selected Guides 선택한 안내선 편집 Clear Selected Guides 선택한 안내선 지우기 + Make Selection 선택 영역 만들기 diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 2307739ed3..5d420b0981 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2790,3 +2790,4 @@ curves Smooth 平滑 # View › Guides › right-click a guide Edit Selected Guides 编辑所选参考线 Clear Selected Guides 清除所选参考线 + Make Selection 建立选区 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 478489f8c7..f13bda17cd 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2775,3 +2775,4 @@ curves Smooth 平滑 # View › Guides › right-click a guide Edit Selected Guides 編輯所選參考線 Clear Selected Guides 清除所選參考線 + Make Selection 建立選取範圍 diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs index f68a4a6a4e..cb0cd07ba4 100644 --- a/crates/ui-egui/src/vector_ui.rs +++ b/crates/ui-egui/src/vector_ui.rs @@ -1139,6 +1139,18 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo ), ), } + // Path mode: Make Selection from the path being drawn or the active path, as Photoshop's + // options bar's "Make: Selection…" does (#5703). + if app.ui.tool_options.vector_mode == "path" { + crate::widgets::vline(ui, 22.0); + let has_path = active_path_name(app).is_some() || app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2); + if ui.add_enabled(has_path, egui::Button::new(tl!("Make Selection"))).clicked() + && let Err(e) = crate::canvas_tool_menu::make_selection(app) + { + app.ui.status = e; + app.ui.status_error = true; + } + } return true; } let mut mode = "shape".to_string(); From 2187a1202a2cec482d81c51559d31f481bb35263 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 21:35:31 -0400 Subject: [PATCH 2/2] Pen options bar Make Selection: use the path the Pen committed to Make Selection named the committed path "work" or "layer" by itself, which could differ from where `pen_commit` put it: a vector mask targeted through the Channels target goes to the mask, and a path drawn with a saved path selected is added to that path, not the Work Path. It now decides the layer case with `targeted_vector_mask`, as `pen_commit` and `path_to_selection` do, and otherwise uses the active path, which the commit selects. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas_tool_menu.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rs index 23ad82826c..ff3809471c 100644 --- a/crates/ui-egui/src/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas_tool_menu.rs @@ -890,11 +890,14 @@ fn pen_dialog(app: &mut PhotocraftApp, command: &str, label: &str, name: &str) { /// dialog for the path being drawn (committed first, as the menu does) or the active path. pub(crate) fn make_selection(app: &mut PhotocraftApp) -> Result<(), String> { let pending = app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2); - let pending_layer = pending && (app.ui.tool_options.vector_mode == "shape" || app.ui.vector_mask_target); + // Where `pen_commit` puts the path being drawn: a shape layer or the targeted vector mask, + // else the Paths panel path it adds to (a selected saved path, or the Work Path), which it + // selects so it is the active path. + let pending_layer = pending && (app.ui.tool_options.vector_mode == "shape" || crate::vector_ui::targeted_vector_mask(app).is_some()); if pending { crate::vector_ui::pen_commit(app, false); } - let name = if pending { Some(if pending_layer { "layer" } else { "work" }.to_string()) } else { crate::vector_ui::active_path_name(app) } + let name = if pending_layer { Some("layer".to_string()) } else { crate::vector_ui::active_path_name(app) } .ok_or_else(|| "No path is available for this action".to_string())?; pen_dialog(app, "path.toSelection", "Make Selection…", &name); Ok(()) @@ -1706,6 +1709,16 @@ mod tests { 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()); + // Drawn with a saved path selected, the path is added to that one (#4721): the dialog is + // for it, not for a Work Path. + app.run("path.rename", json!({"name": "work", "to": "Cutout"})).unwrap(); + app.ui.selected_path = Some("Cutout".into()); + for (x, y) in [(4.0, 24.0), (12.0, 24.0), (12.0, 30.0)] { + crate::vector_ui::pen_down(&mut app, x, y, false); + crate::vector_ui::pen_up(&mut app); + } + make_selection(&mut app).unwrap(); + assert_eq!(app.ui.dialogs.last().and_then(|d| d.fields.get("name")), Some(&json!("Cutout"))); } /// #1056: the Path Selection and Direct Selection tools' right-click opens the path menu for