From 09ccd2e9cd5e45f888f3257802d742070b5d9e93 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:09:35 +0100 Subject: [PATCH 1/3] Alt+click on the new group button groups one active layer (#14717) Alt+click on the Layers panel's Create a new group button now opens New Group from Layers also with one non-Background layer active, and OK puts that layer into the group, as in Photoshop. With the Background or nothing active it still opens New Group (not measured). Fixes #14717 --- crates/ui-egui/src/new_group_button_tests.rs | 10 +- .../group_from_layers_alt_click_tests.rs | 123 ++++++++++++++++++ crates/ui-egui/src/panels/layers.rs | 11 +- 3 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 crates/ui-egui/src/panels/group_from_layers_alt_click_tests.rs diff --git a/crates/ui-egui/src/new_group_button_tests.rs b/crates/ui-egui/src/new_group_button_tests.rs index 54d8ff42a2..5496607f19 100644 --- a/crates/ui-egui/src/new_group_button_tests.rs +++ b/crates/ui-egui/src/new_group_button_tests.rs @@ -95,11 +95,11 @@ fn selecting_a_grouped_layer_opens_the_group() { assert!(rows.contains(&a.0) && rows.contains(&b.0), "{rows:?}"); } -/// ⌥-click asks in the New Group dialog first: New Group from Layers with several layers -/// selected, New Group with one. Nothing changes until OK. +/// ⌥-click asks in the New Group from Layers dialog first, with one layer selected too +/// (#14717). Nothing changes until OK. #[test] fn alt_click_opens_the_new_group_dialog() { - for (both, command) in [(true, "layer.new.groupFromLayers"), (false, "layer.new.group")] { + for (both, command) in [(true, "layer.new.groupFromLayers"), (false, "layer.new.groupFromLayers")] { let (mut h, a, b) = selected(both); h.get_by_label("Create a new group").click_modifiers(Modifiers::ALT); h.run_steps(4); @@ -114,7 +114,9 @@ fn alt_click_opens_the_new_group_dialog() { } else { let groups = groups(&h); assert_eq!(groups.len(), 1); - assert!(groups[0].children().unwrap().is_empty()); + assert_eq!(groups[0].children().unwrap().iter().map(|l| l.id).collect::>(), vec![b]); + let top: Vec = h.state().session.active().unwrap().doc.layers.iter().map(|l| l.id).collect(); + assert_eq!(top[1..], [a, groups[0].id]); } } } diff --git a/crates/ui-egui/src/panels/group_from_layers_alt_click_tests.rs b/crates/ui-egui/src/panels/group_from_layers_alt_click_tests.rs new file mode 100644 index 0000000000..12d9f59c12 --- /dev/null +++ b/crates/ui-egui/src/panels/group_from_layers_alt_click_tests.rs @@ -0,0 +1,123 @@ +//! #14717: ⌥-click on the Layers panel's "Create a new group" button opens New Group from Layers +//! and, on OK, puts the active layer into the new group also when it is the only selected layer, +//! as in Photoshop. With the Background or nothing active it keeps opening New Group (not +//! measured); plain, ⌘ and Shift clicks are unchanged. + +use egui::Modifiers; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use photocraft_doc::{Layer, LayerId}; +use serde_json::json; + +use crate::PhotocraftApp; + +/// White Background, then Red, Green and Blue; only `active` is selected (`None`: no active layer). +fn document(active: Option<&str>) -> (Harness<'static, PhotocraftApp>, Vec) { + let mut s = photocraft_engine::Session::new(); + s.execute("prefs.set", json!({"path": "interface.language", "value": "en"})).unwrap(); + s.execute("file.new", json!({"width": 40, "height": 30, "background": "white"})).unwrap(); + let mut ids = vec![s.active().unwrap().doc.layers[0].id]; + for name in ["Red", "Green", "Blue"] { + ids.push(LayerId(s.execute("layer.new.layer", json!({"name": name})).unwrap()["layer"].as_u64().unwrap())); + } + match active { + Some(name) => { + let i = ["Background", "Red", "Green", "Blue"].iter().position(|n| *n == name).unwrap(); + s.execute("layer.select", json!({"layer": ids[i].0})).unwrap(); + } + None => { + s.execute("select.deselectLayers", json!({})).unwrap(); + } + } + let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_max_steps(64).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + PhotocraftApp::new(s, crate::Services::default()) + }); + h.run_steps(4); + (h, ids) +} + +fn groups(h: &Harness<'static, PhotocraftApp>) -> Vec { + h.state().session.active().unwrap().doc.walk().into_iter().map(|(_, _, l)| l).filter(|l| l.is_group()).cloned().collect() +} + +/// ⌥-clicks the button and returns the opened dialog's id and command. +fn alt_click(h: &mut Harness<'static, PhotocraftApp>) -> (u64, String) { + h.get_by_label("Create a new group").click_modifiers(Modifiers::ALT); + h.run_steps(4); + assert!(groups(h).is_empty(), "nothing happens before OK"); + let d = h.state().ui.dialogs.last().expect("a group dialog opened"); + assert!(crate::new_group_ui::owns(&d.fields)); + (d.id, d.fields["__command"].as_str().unwrap_or_default().to_string()) +} + +#[test] +fn alt_click_with_one_layer_opens_new_group_from_layers_and_groups_it() { + let (mut h, ids) = document(Some("Blue")); + let (id, command) = alt_click(&mut h); + assert_eq!(command, crate::new_group_ui::FROM_LAYERS); + assert_eq!(h.state().ui.dialogs.last().unwrap().fields["__label"], "New Group from Layers…"); + crate::dialogs::confirm(h.state_mut(), id).unwrap(); + h.run_steps(4); + let groups = groups(&h); + assert_eq!(groups.len(), 1); + let children: Vec = groups[0].children().unwrap().iter().map(|l| l.id).collect(); + assert_eq!(children, vec![ids[3]], "Blue moves into the new group"); + let top: Vec = h.state().session.active().unwrap().doc.layers.iter().map(|l| l.id).collect(); + assert_eq!(top, vec![ids[0], ids[1], ids[2], groups[0].id], "the group takes Blue's place"); + assert_eq!(h.state().session.active().unwrap().selected_layers(), vec![groups[0].id]); +} + +#[test] +fn alt_click_with_one_lower_layer_groups_it_in_place() { + let (mut h, ids) = document(Some("Red")); + let (id, command) = alt_click(&mut h); + assert_eq!(command, crate::new_group_ui::FROM_LAYERS); + crate::dialogs::confirm(h.state_mut(), id).unwrap(); + h.run_steps(4); + let groups = groups(&h); + let children: Vec = groups[0].children().unwrap().iter().map(|l| l.id).collect(); + assert_eq!(children, vec![ids[1]]); + let top: Vec = h.state().session.active().unwrap().doc.layers.iter().map(|l| l.id).collect(); + assert_eq!(top, vec![ids[0], groups[0].id, ids[2], ids[3]]); +} + +/// Not measured: with the Background active, ⌥-click keeps opening New Group, and OK adds an +/// empty group. +#[test] +fn alt_click_with_the_background_active_keeps_opening_new_group() { + let (mut h, _) = document(Some("Background")); + let (id, command) = alt_click(&mut h); + assert_eq!(command, crate::new_group_ui::NEW_GROUP); + crate::dialogs::confirm(h.state_mut(), id).unwrap(); + h.run_steps(4); + assert!(groups(&h)[0].children().unwrap().is_empty()); +} + +/// Not measured: with nothing active, ⌥-click keeps opening New Group. +#[test] +fn alt_click_with_nothing_active_keeps_opening_new_group() { + let (mut h, _) = document(None); + assert!(h.state().session.active().unwrap().active_layer.is_none()); + let (_, command) = alt_click(&mut h); + assert_eq!(command, crate::new_group_ui::NEW_GROUP); +} + +/// With one layer selected a plain click still adds an empty group above it, and Shift-click +/// still groups it. +#[test] +fn plain_and_shift_click_with_one_layer_are_unchanged() { + let (mut h, _) = document(Some("Blue")); + h.get_by_label("Create a new group").click(); + h.run_steps(4); + assert!(h.state().ui.dialogs.is_empty()); + let g = groups(&h); + assert!(g[0].children().unwrap().is_empty()); + + let (mut h, ids) = document(Some("Blue")); + h.get_by_label("Create a new group").click_modifiers(Modifiers::SHIFT); + h.run_steps(4); + assert!(h.state().ui.dialogs.is_empty()); + let g = groups(&h); + assert_eq!(g[0].children().unwrap().iter().map(|l| l.id).collect::>(), vec![ids[3]]); +} diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index cc71b6884b..e48656e9ec 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -456,8 +456,11 @@ pub(super) fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let m = ui.input(|i| i.modifiers); let groups = (m.shift || selection.len() > 1) && active_layer.is_some(); if m.alt { - // Null params go through the menu path, which opens the dialog. - let cmd = if groups { crate::new_group_ui::FROM_LAYERS } else { crate::new_group_ui::NEW_GROUP }; + // Null params go through the menu path, which opens the dialog. Like Photoshop, + // ⌥-click asks for New Group from Layers also with one non-Background layer + // active, and OK puts that layer in the group (#14717). + let one = active_layer.is_some_and(|l| !doc.is_background(l.id)); + let cmd = if groups || one { crate::new_group_ui::FROM_LAYERS } else { crate::new_group_ui::NEW_GROUP }; actions.push((cmd.into(), Value::Null)); } else if m.command { actions.push(("layer.new.group".into(), json!({"position": "below"}))); @@ -621,3 +624,7 @@ pub(crate) fn fx_button(ui: &mut egui::Ui, size: f32, tip: &str) -> egui::Respon pub(super) fn channels(app: &mut PhotocraftApp, ui: &mut egui::Ui) { crate::channels_panel::show(app, ui); } + +#[cfg(test)] +#[path = "group_from_layers_alt_click_tests.rs"] +mod group_from_layers_alt_click_tests; From e6a77592747a36e3a5d0c286f25f10375455ed0c Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:25:50 +0100 Subject: [PATCH 2/3] Regenerate docs/scorecard.md --- docs/scorecard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index bd0456f013..3f01a2ece7 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -273,7 +273,7 @@ Menu wiring (`docs/parity-checklist.md`): 664 of 664 menu items live (100.0%). T | AUTO-219-5 | Batch: subfolders, open documents, naming template, progress/cancel, error log, stop | partial | [#219](https://github.com/storytold/photocraft/issues/219) | file_cmds/batch_run.rs and batch_naming.rs: flat subfolder output and last-result-wins names measured in Photoshop 2026; live open-document source; file naming components and serials; UTF-16 LE error log; stop-on-error; CLI and Batch dialog, #4579. Desktop Esc asks Continue/Stop, retaining one plan and error log; a read-only canvas preview shows each scratch-session input without a progress bar. Inputs are not live tabs with Layers panel content, so full window parity remains open. | | AUTO-219-6 | Plug-in ABI v2: panel kind, progress/cancel calls, read other layers, Last Filter repeats | missing | [#219](https://github.com/storytold/photocraft/issues/219) | runtime.rs:15 ABI_VERSION = 1; manifest.rs:18 Kind::Filter only | | AUTO-219-7 | Local ONNX models behind a flag, managed in Preferences; subject select, background removal | missing | [#219](https://github.com/storytold/photocraft/issues/219) | No ONNX runtime dependency | -| AUTO-219-8 | xtask check that every panel button routes through a command id | partial | [#219](https://github.com/storytold/photocraft/issues/219) | cargo xtask panel-commands (run by xtask ci and CI) fails on a shell click handler that changes the document or session directly; 1 allowlisted function left (panels/color.rs color_field assigns the foreground/background colour instead of tools.setColors) | +| AUTO-219-8 | xtask check that every panel button routes through a command id | partial | [#219](https://github.com/storytold/photocraft/issues/219) | cargo xtask panel-commands (run by xtask ci and CI) fails on a shell click handler that changes the document or session directly; no allowlisted function left (the Color panel field dispatches tools.setColors) | | AUTO-219-9 | Headless commands for in-canvas type editing, Liquify/Puppet strokes, transform handles | done | [#219](https://github.com/storytold/photocraft/issues/219) | type.hitTest, type.caret, type.navigate; filter.liquify strokes, edit.puppetWarp pins, type.edit, edit.transform | | AUTO-219-10 | Agent acceptance suite grown to 30-50 workflows | partial | [#219](https://github.com/storytold/photocraft/issues/219) | automation/tests/it/agent_tasks.rs runs 10 workflows over MCP | | AUTO-MCP-LIVE | Connect an MCP client to the running app without a terminal (no flags, ports or tokens to copy) | done | | 2026-11-12 (#5525, #11363, craft-ai-integrations#195): the ArtCraft Launcher's agents switch (the one consent; read through craft-ai-agents) starts and stops the loopback control server while the app runs (no restart) and publishes agent-connection.json; plain photocraft-cli mcp works in the open app on every call while agents are allowed (launch / headless / error while it is closed) and headless otherwise (--headless forces it); the launcher's Add buttons register every Craft app, PhotoCraft writes no client configuration. automation/tests/mcp_live.rs, ui-egui prefs_ui/agents_tests.rs, craft-automation tests/it/agents.rs | From 5bc88ca51dddc75a51ba205f0273bb6315b73272 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:17:59 +0100 Subject: [PATCH 3/3] Layers footer: Alt-click with a lone artboard keeps New Group An artboard can't go into a group, so New Group from Layers failed on OK when an artboard was the only active layer and no group was made. The single-layer route of #14717 now leaves artboards out, so a lone artboard gets the New Group dialog and its empty group as before. --- crates/ui-egui/src/layers_footer_tests.rs | 21 +++++++++++++++++++++ crates/ui-egui/src/panels/layers_events.rs | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/layers_footer_tests.rs b/crates/ui-egui/src/layers_footer_tests.rs index 1a2619e033..bbbc2ddf51 100644 --- a/crates/ui-egui/src/layers_footer_tests.rs +++ b/crates/ui-egui/src/layers_footer_tests.rs @@ -235,6 +235,27 @@ fn footer_buttons_run_photocraft_commands() { assert!(groups(h)[0].children().unwrap().is_empty()); }, }, + Case { + case: "Alt New Group, one artboard active: an empty group, the artboard stays a board", + doc: || { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 200, "height": 100})).unwrap(); + s.execute("layer.new.artboard", json!({"name": "Board", "rect": [0, 0, 100, 100]})).unwrap(); + s + }, + before: none, + button: "Create a new group", + mods: Modifiers::ALT, + after: |h| { + let id = h.state().framework.dialogs.stack().top().expect("the New Group dialog opened"); + confirm(h, id); + h.run_steps(4); + let plain: Vec = groups(h).into_iter().filter(|g| g.artboard().is_none()).collect(); + assert_eq!(plain.len(), 1, "OK adds one group: {:?}", top(h)); + assert!(plain[0].children().unwrap().is_empty()); + assert!(doc(h).layers.iter().any(|l| l.artboard().is_some()), "the artboard stays at the top level"); + }, + }, Case { case: "Cmd New Group, two selected: an empty group below the active layer", doc: || two(true), diff --git a/crates/ui-egui/src/panels/layers_events.rs b/crates/ui-egui/src/panels/layers_events.rs index 85a7a4f25f..36344f5f94 100644 --- a/crates/ui-egui/src/panels/layers_events.rs +++ b/crates/ui-egui/src/panels/layers_events.rs @@ -496,8 +496,9 @@ fn footer(app: &mut PhotocraftApp, picked: Option, if ask { // Null params go through the menu path, which opens the dialog. Like Photoshop, // ⌥-click asks for New Group from Layers also with one non-Background layer - // active, and OK puts that layer in the group (#14717). - let one = active.is_some_and(|l| !doc.is_background(l.id)); + // active, and OK puts that layer in the group (#14717). An artboard can't go into + // a group, so a lone artboard keeps New Group. + let one = active.is_some_and(|l| !doc.is_background(l.id) && l.artboard().is_none()); let cmd = if groups || one { crate::new_group_ui::FROM_LAYERS } else { crate::new_group_ui::NEW_GROUP }; actions.push((cmd.into(), Value::Null)); } else if below {