From 2fc221e66ba3c79adb67c721b5db2aed1fa449c0 Mon Sep 17 00:00:00 2001 From: bazmarth Date: Wed, 14 Oct 2026 22:27:37 +0000 Subject: [PATCH 1/3] Color: a picked colour recolours the selected type and shapes, as in Photoshop The Color panel, the Swatches panel and the Color Picker set the foreground; like Photoshop, the new colour now also goes to what is selected, depending on the tool in hand (new apply_color.rs, which the three already call through): - characters selected while editing type: those characters (as before); - a Type tool, not editing: every selected type layer (type.setStyle); - a shape tool, a Pen or a path selection tool: every selected shape layer's fill (shape.edit); - any other tool (Move, brushes...): only the foreground. One pick is one history step for all the layers it recolours; a drag in the Color panel's field or sliders is one step too (coalesce). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 94 ++++++++++++++++ crates/ui-egui/src/apply_color_tests.rs | 144 ++++++++++++++++++++++++ crates/ui-egui/src/color_picker_ui.rs | 2 +- crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/panels.rs | 6 +- crates/ui-egui/src/state.rs | 4 + crates/ui-egui/src/swatches_ui.rs | 5 +- docs/ui-parity.md | 4 +- 8 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/apply_color.rs create mode 100644 crates/ui-egui/src/apply_color_tests.rs diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs new file mode 100644 index 00000000000..ce51b23fe19 --- /dev/null +++ b/crates/ui-egui/src/apply_color.rs @@ -0,0 +1,94 @@ +//! A new foreground colour recolours the selected objects, as in Photoshop: the Color panel, the +//! Swatches panel and the Color Picker set the foreground, and depending on the tool in hand it +//! also goes to what is selected: +//! +//! * characters selected while editing type: those characters (`type_tool::foreground_changed`); +//! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); +//! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer +//! (`shape.edit` with `fill`); +//! * any other tool (Move, the brushes…): nothing, only the foreground changes. +//! +//! One pick is one history step for all the layers it recolours; a drag in the Color panel's field +//! or sliders is one step too. + +use egui::Context; +use photocraft_doc::LayerContent; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +fn hex(c: [f32; 4]) -> String { + let b = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; + format!("#{:02x}{:02x}{:02x}", b(c[0]), b(c[1]), b(c[2])) +} + +/// Does a new foreground recolour selected shape layers with `tool`? +fn recolours_shapes(tool: Tool) -> bool { + crate::vector_ui::is_shape_tool(tool) + || matches!( + tool, + Tool::PathSelection + | Tool::DirectSelection + | Tool::Pen + | Tool::FreeformPen + | Tool::CurvaturePen + | Tool::AddAnchorPoint + | Tool::DeleteAnchorPoint + | Tool::ConvertPoint + ) +} + +/// Is the pointer still held from an earlier frame (a drag in the Color panel), so this pick +/// joins the previous one's history step? +pub fn continuing(ctx: &Context) -> bool { + ctx.input(|i| i.pointer.any_down() && !i.pointer.any_pressed()) +} + +/// The foreground colour just changed through the Color panel, the Swatches panel or the Color +/// Picker: recolour what is selected, as the tool in hand says (see the module docs). +/// `continuing` (a drag still in progress) joins the previous pick's history step. +pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { + // Editing type: the selected characters, in the editing session's step; nothing else. + if app.ui.text_edit.is_some() { + crate::type_tool::foreground_changed(app); + return; + } + let tool = app.ui.tool; + let type_tool = tool.is_type() && !tool.is_type_mask(); + if !type_tool && !recolours_shapes(tool) { + return; + } + let Some(st) = app.session.active() else { return }; + let (texts, shapes): (Vec, Vec) = { + let selected: Vec<_> = st.selected_layers().into_iter().filter_map(|id| st.doc.layer(id)).collect(); + let pick = |want: fn(&LayerContent) -> bool| selected.iter().filter(|l| want(&l.content)).map(|l| l.id.0).collect::>(); + (pick(|c| matches!(c, LayerContent::Text(_))), pick(|c| matches!(c, LayerContent::Shape(_)))) + }; + let targets = if type_tool { &texts } else { &shapes }; + if targets.is_empty() { + return; + } + let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { + Some(k) => k, + None => { + let k = format!("apply-color-{}", app.ui.alloc_id()); + app.ui.apply_color_key = Some(k.clone()); + k + } + }; + let color = hex(app.session.tools.foreground); + let result = if type_tool { + app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key})).map(|_| ()) + } else { + shapes.iter().try_for_each(|id| app.run("shape.edit", json!({"layer": id, "fill": color, "coalesce": key})).map(|_| ())) + }; + if let Err(e) = result { + app.ui.status = e; + app.ui.status_error = true; + } +} + +#[cfg(test)] +#[path = "apply_color_tests.rs"] +mod tests; diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs new file mode 100644 index 00000000000..0a0accb6b22 --- /dev/null +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -0,0 +1,144 @@ +//! A new foreground colour recolours the selected type or shape layers, as the tool in hand says. + +use photocraft_doc::{Fill, LayerContent, LayerId}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; + +/// Two type layers and two shape layers (black, the default colours), all selected. +fn app(tool: Tool) -> (PhotocraftApp, Vec, Vec) { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + app.sync_views(); + app.run("tools.setColors", json!({"foreground": "#000000"})).unwrap(); + let mut texts = Vec::new(); + for y in [40, 90] { + texts.push(LayerId(app.run("type.create", json!({"x": 20, "y": y, "text": "Hello", "size": 20})).unwrap()["layer"].as_u64().unwrap())); + } + let mut shapes = Vec::new(); + for x in [150, 220] { + app.run("shape.create", json!({"kind": "rect", "rect": [x, 20, 50, 50], "fill": "#000000"})).unwrap(); + shapes.push(app.session.active().unwrap().active_layer.unwrap()); + } + for id in texts.iter().chain(&shapes) { + app.run("layer.select", json!({"layer": id.0, "mode": "add"})).unwrap(); + } + app.ui.tool = tool; + (app, texts, shapes) +} + +fn text_rgb(app: &PhotocraftApp, id: LayerId) -> [f32; 3] { + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Text(t) => { + let c = t.char_runs().into_iter().next().map_or(t.color, |r| r.style.color); + [c.c[0], c.c[1], c.c[2]] + } + _ => panic!("type layer"), + } +} + +fn fill_rgb(app: &PhotocraftApp, id: LayerId) -> Option<[f32; 3]> { + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Shape(sh) => match &sh.fill { + Some(Fill::Solid(c)) => Some([c.c[0], c.c[1], c.c[2]]), + _ => None, + }, + _ => panic!("shape layer"), + } +} + +fn red(c: [f32; 3]) -> bool { + (c[0] - 1.0).abs() < 1e-3 && c[1].abs() < 1e-3 && c[2].abs() < 1e-3 +} + +fn steps(app: &PhotocraftApp) -> usize { + app.session.active().unwrap().history.entries().len() +} + +fn pick(app: &mut PhotocraftApp, c: [f32; 4], continuing: bool) { + app.session.tools.foreground = c; + super::foreground_changed(app, continuing); +} + +#[test] +fn a_type_tool_recolours_every_selected_type_layer_in_one_step() { + for tool in [Tool::Type, Tool::VerticalType] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "{tool:?}"); + assert!(shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}: shapes keep their fill"); + assert_eq!(steps(&app), n + 1, "one history step"); + assert!(app.session.undo()); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id)))); + } +} + +#[test] +fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { + for tool in [Tool::Rectangle, Tool::Polygon, Tool::PathSelection, Tool::DirectSelection, Tool::Pen, Tool::CurvaturePen] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "{tool:?}"); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))), "{tool:?}: type keeps its colour"); + assert_eq!(steps(&app), n + 1, "{tool:?}: one history step for both layers"); + } +} + +#[test] +fn other_tools_only_change_the_foreground() { + for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert_eq!(app.session.tools.foreground, RED); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}"); + assert_eq!(steps(&app), n, "{tool:?}: nothing recorded"); + } +} + +#[test] +fn a_color_panel_drag_is_one_history_step_and_a_new_pick_another() { + let (mut app, _, shapes) = app(Tool::Rectangle); + let n = steps(&app); + pick(&mut app, [0.2, 0.0, 0.0, 1.0], false); + pick(&mut app, [0.6, 0.0, 0.0, 1.0], true); + pick(&mut app, RED, true); + assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); + assert_eq!(steps(&app), n + 1, "the drag is one step"); + pick(&mut app, [0.0, 0.0, 1.0, 1.0], false); + assert_eq!(steps(&app), n + 2, "a new pick is another"); +} + +#[test] +fn a_swatch_and_the_color_picker_go_through_it() { + let (mut app, _, shapes) = app(Tool::Rectangle); + let same = |app: &PhotocraftApp, id: LayerId| { + let f = app.session.tools.foreground; + fill_rgb(app, id).is_some_and(|c| (0..3).all(|i| (c[i] - f[i]).abs() < 1e-3)) + }; + // A swatch from the default library (the first one that isn't black). + let names = app.run("swatches.list", json!({})).unwrap(); + let name = names["groups"] + .as_array() + .into_iter() + .flatten() + .flat_map(|g| g["swatches"].as_array().cloned().unwrap_or_default()) + .find(|w| w["hex"].as_str().is_some_and(|h| h != "#000000")) + .and_then(|w| w["name"].as_str().map(str::to_string)) + .expect("a default swatch"); + crate::swatches_ui::use_swatch(&mut app, &name, false); + assert_ne!(app.session.tools.foreground, [0.0, 0.0, 0.0, 1.0]); + assert!(shapes.iter().all(|id| same(&app, *id)), "the swatch recoloured the shapes"); + // The Color Picker's OK for the foreground. + let mut f = serde_json::Map::new(); + f.insert("__colorPicker".into(), json!("foreground")); + f.insert("color".into(), json!("#0000ff")); + crate::color_picker_ui::confirm(&mut app, &f).unwrap(); + assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); + assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); +} diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs index 09a3ce8d4c0..f275fcf4d9b 100644 --- a/crates/ui-egui/src/color_picker_ui.rs +++ b/crates/ui-egui/src/color_picker_ui.rs @@ -824,7 +824,7 @@ pub fn confirm(app: &mut PhotocraftApp, f: &Map) -> Result, /// A live rectangle's corner radius widget being dragged (TOOL-214-12). #[serde(skip)] pub corner_radius: Option, @@ -1344,6 +1347,7 @@ impl Default for UiState { pen: None, stroke_editor: None, direct_selection: Default::default(), + apply_color_key: None, corner_radius: None, selected_path: None, panels: Panels::default(), diff --git a/crates/ui-egui/src/swatches_ui.rs b/crates/ui-egui/src/swatches_ui.rs index a18ddee6401..6013ec779da 100644 --- a/crates/ui-egui/src/swatches_ui.rs +++ b/crates/ui-egui/src/swatches_ui.rs @@ -51,8 +51,9 @@ fn colors(app: &PhotocraftApp, ctx: &egui::Context) -> Arc>> { pub fn use_swatch(app: &mut PhotocraftApp, name: &str, background: bool) { let target = if background { "background" } else { "foreground" }; if run(app, "swatches.use", json!({"swatch": name, "target": target})).is_some() && !background { - // Clicking a swatch while characters are selected recolours them (#364). - crate::type_tool::foreground_changed(app); + // Clicking a swatch recolours the selected characters (#364), or the selected type or + // shape layers with a Type, shape or Pen tool, as in Photoshop. + crate::apply_color::foreground_changed(app, false); } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 7fbe8932cc1..e22aee3483e 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (a picked colour recolours the selected type and shapes; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026 How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation, @@ -207,6 +207,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -253,3 +254,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) | | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) | From 62ab7f38685f4c63959a1155babed9e01c378fef Mon Sep 17 00:00:00 2001 From: bazmarth Date: Thu, 15 Oct 2026 00:26:11 +0000 Subject: [PATCH 2/3] Color: the Move tool recolours the selected type and shapes too Layers picked with the Move tool (a click, Shift-click or its marquee) now take a colour picked in the Color or Swatches panel or the Color Picker: every selected type layer's colour and every selected shape's fill, in one history step. The brushes, the pixel selection tools and the other tools still change only the foreground. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 35 ++++++++++++--------- crates/ui-egui/src/apply_color_tests.rs | 42 ++++++++++++++++++++++++- docs/ui-parity.md | 4 +-- 3 files changed, 64 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs index ce51b23fe19..ed40823a047 100644 --- a/crates/ui-egui/src/apply_color.rs +++ b/crates/ui-egui/src/apply_color.rs @@ -1,12 +1,14 @@ -//! A new foreground colour recolours the selected objects, as in Photoshop: the Color panel, the -//! Swatches panel and the Color Picker set the foreground, and depending on the tool in hand it -//! also goes to what is selected: +//! A new foreground colour recolours the selected objects: the Color panel, the Swatches panel and +//! the Color Picker set the foreground, and depending on the tool in hand it also goes to what is +//! selected: //! //! * characters selected while editing type: those characters (`type_tool::foreground_changed`); //! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); //! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer //! (`shape.edit` with `fill`); -//! * any other tool (Move, the brushes…): nothing, only the foreground changes. +//! * the Move tool (layers picked by a click, ⇧-click or its marquee): both, every selected type +//! layer and shape; +//! * any other tool (the brushes, the pixel selection tools…): nothing, only the foreground. //! //! One pick is one history step for all the layers it recolours; a drag in the Color panel's field //! or sliders is one step too. @@ -55,18 +57,22 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { return; } let tool = app.ui.tool; - let type_tool = tool.is_type() && !tool.is_type_mask(); - if !type_tool && !recolours_shapes(tool) { - return; - } + // What the tool in hand recolours: type layers, shape layers, or both (the Move tool). + let (do_texts, do_shapes) = match tool { + Tool::Move => (true, true), + t if t.is_type() && !t.is_type_mask() => (true, false), + t if recolours_shapes(t) => (false, true), + _ => return, + }; let Some(st) = app.session.active() else { return }; let (texts, shapes): (Vec, Vec) = { let selected: Vec<_> = st.selected_layers().into_iter().filter_map(|id| st.doc.layer(id)).collect(); let pick = |want: fn(&LayerContent) -> bool| selected.iter().filter(|l| want(&l.content)).map(|l| l.id.0).collect::>(); (pick(|c| matches!(c, LayerContent::Text(_))), pick(|c| matches!(c, LayerContent::Shape(_)))) }; - let targets = if type_tool { &texts } else { &shapes }; - if targets.is_empty() { + let texts = if do_texts { texts } else { Vec::new() }; + let shapes = if do_shapes { shapes } else { Vec::new() }; + if texts.is_empty() && shapes.is_empty() { return; } let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { @@ -78,11 +84,12 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { } }; let color = hex(app.session.tools.foreground); - let result = if type_tool { - app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key})).map(|_| ()) - } else { + let result = (|| { + if !texts.is_empty() { + app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key}))?; + } shapes.iter().try_for_each(|id| app.run("shape.edit", json!({"layer": id, "fill": color, "coalesce": key})).map(|_| ())) - }; + })(); if let Err(e) = result { app.ui.status = e; app.ui.status_error = true; diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs index 0a0accb6b22..a007eb98450 100644 --- a/crates/ui-egui/src/apply_color_tests.rs +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -91,7 +91,7 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { #[test] fn other_tools_only_change_the_foreground() { - for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + for tool in [Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); pick(&mut app, RED, false); @@ -142,3 +142,43 @@ fn a_swatch_and_the_color_picker_go_through_it() { assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); } + +#[test] +fn the_move_tool_recolours_the_selected_type_and_shapes_together_in_one_step() { + // Layers picked with the Move tool (a click, ⇧-click or its marquee) take the colour, type and + // shapes alike. + let (mut app, texts, shapes) = app(Tool::Move); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "the type is red"); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "the shapes are red"); + assert_eq!(steps(&app), n + 1, "one history step for all four layers"); + assert!(app.session.undo()); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap()))); + // Only the selected ones: with one shape selected, the rest keep their colour. + app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); + pick(&mut app, RED, false); + assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); + assert!(!red(fill_rgb(&app, shapes[1]).unwrap()) && texts.iter().all(|id| !red(text_rgb(&app, *id)))); +} + +#[test] +fn a_move_tool_marquee_selection_takes_the_colour() { + // The video case: shapes box-selected with the Move tool's marquee, then a swatch. + let (mut app, _, shapes) = app(Tool::Move); + app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); + // The marquee from an empty spot across both shapes. + for (kind, x, y) in [("down", 140.0, 10.0), ("move", 200.0, 50.0), ("move", 290.0, 90.0), ("up", 290.0, 90.0)] { + let ev = match kind { + "down" => crate::canvas::ToolEvent::Down { x, y, pressure: 1.0 }, + "move" => crate::canvas::ToolEvent::Move { x, y, pressure: 1.0 }, + _ => crate::canvas::ToolEvent::Up { x, y }, + }; + crate::canvas::tool_event(&mut app, ev, egui::Modifiers::NONE); + } + let mut sel = app.session.active().unwrap().selected_layers(); + sel.sort_by_key(|l| l.0); + assert_eq!(sel, shapes, "the marquee selected both shapes"); + pick(&mut app, RED, false); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red))); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index e22aee3483e..adb6c2da4c2 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -207,7 +207,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | -| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; both with the Move tool (layers picked by click, ⇧-click or its marquee); only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -254,4 +254,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) | | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | -| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool), shape fills (shape, Pen and path selection tools), or both (Move tool) | From 52c1e211d1c8bb7fe3e8d006aa24e8c41cc01797 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 15:47:56 +0200 Subject: [PATCH 3/3] Integration: one undo step per Color panel gesture, no Move tool recolouring (#5842) A drag in the Color panel's field or sliders only reaches the panel after its press frame (egui decides click vs drag on a later frame), so `continuing()` was always true on a drag's first pick and the drag reused the previous pick's history key: a swatch, click or earlier drag followed by a drag became one undo step. The key is now the pointer's press time, as `type_tool::drag_key` does; swatches, the Color Picker and clicks get a fresh key. The kittest `color_panel_gestures_recolour_the_selected_shape_in_separate_steps` drives real clicks and drags (the first drag joined the click's step before). CodeRabbit flagged this on the PR. The R, G, B, HSB and hex fields apply every keystroke, so typing "128" into G with a shape selected left three undo steps (1, 12, 128). While no button is held, picks now share the focused field's step; a focus counter (`track_focus`, run by the panel each frame) makes a value typed after refocusing a field a new step, and a click (a release frame) is always its own; a sum (`2*64`) committed by Enter, after the field let go of the focus, keeps the step of the field focused last frame. Pinned by `typing_an_rgb_value_recolours_the_selected_shape_in_one_step` (5 steps instead of 3 for "128" before). With the Move tool (the default tool), Photoshop only changes the foreground when a colour is picked; the PR recoloured the selected type and shapes too, so a colour picked to paint with later rewrote them. The Move tool now joins `other_tools_only_change_the_foreground`. Co-authored-by: baz <57290335+bazmarth@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 61 +++++++++---- crates/ui-egui/src/apply_color_tests.rs | 69 ++++----------- crates/ui-egui/src/color_picker_ui.rs | 2 +- crates/ui-egui/src/panels.rs | 110 +++++++++++++++++++++++- crates/ui-egui/src/state.rs | 4 - crates/ui-egui/src/swatches_ui.rs | 2 +- docs/ui-parity.md | 4 +- 7 files changed, 170 insertions(+), 82 deletions(-) diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs index ed40823a047..a2b2fcbb2e4 100644 --- a/crates/ui-egui/src/apply_color.rs +++ b/crates/ui-egui/src/apply_color.rs @@ -6,14 +6,13 @@ //! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); //! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer //! (`shape.edit` with `fill`); -//! * the Move tool (layers picked by a click, ⇧-click or its marquee): both, every selected type -//! layer and shape; -//! * any other tool (the brushes, the pixel selection tools…): nothing, only the foreground. +//! * any other tool (the Move tool, the brushes, the pixel selection tools…): nothing, only the +//! foreground. //! //! One pick is one history step for all the layers it recolours; a drag in the Color panel's field //! or sliders is one step too. -use egui::Context; +use egui::{Context, Id}; use photocraft_doc::LayerContent; use serde_json::json; @@ -41,25 +40,53 @@ fn recolours_shapes(tool: Tool) -> bool { ) } -/// Is the pointer still held from an earlier frame (a drag in the Color panel), so this pick -/// joins the previous one's history step? -pub fn continuing(ctx: &Context) -> bool { - ctx.input(|i| i.pointer.any_down() && !i.pointer.any_pressed()) +/// The gesture a Color panel pick belongs to: the press while the pointer is held (a drag in its +/// field or sliders), else the field being typed into (its value changes with every keystroke); +/// `None` for a click. Every pick of one gesture joins one history step, and the next press or +/// focused field starts another. +pub fn gesture(ctx: &Context) -> Option { + if let Some(t) = ctx.input(|i| if i.pointer.any_down() { i.pointer.press_start_time() } else { None }) { + return Some(format!("press-{}", t.to_bits())); + } + // A click (reported on its release) is a step of its own, even while a field keeps the focus. + if ctx.input(|i| i.pointer.any_released()) { + return None; + } + // The focused field; on the frame Enter commits a typed sum (`2*64`) it has just let go, so + // the field focused last frame. + let (last, n) = ctx.data(|d| d.get_temp::<(Option, u64)>(focus_key())).unwrap_or_default(); + ctx.memory(|m| m.focused()).or(last).map(|id| format!("field-{}-{n}", id.value())) +} + +fn focus_key() -> Id { + Id::new("apply-color-focus") +} + +/// Counts the changes of keyboard focus, so two values typed into one field, each after +/// focusing it, are two history steps (see [`gesture`]). Called every frame by the Color panel. +pub fn track_focus(ctx: &Context) { + let focused = ctx.memory(|m| m.focused()); + ctx.data_mut(|d| { + let (last, n) = d.get_temp::<(Option, u64)>(focus_key()).unwrap_or_default(); + if last != focused { + d.insert_temp(focus_key(), (focused, n.wrapping_add(1))); + } + }); } /// The foreground colour just changed through the Color panel, the Swatches panel or the Color /// Picker: recolour what is selected, as the tool in hand says (see the module docs). -/// `continuing` (a drag still in progress) joins the previous pick's history step. -pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { +/// Picks of one `gesture` (a Color panel drag or typed value, see [`gesture`]) share one history +/// step; `None` (a swatch, the Color Picker, a click) is a step of its own. +pub fn foreground_changed(app: &mut PhotocraftApp, gesture: Option) { // Editing type: the selected characters, in the editing session's step; nothing else. if app.ui.text_edit.is_some() { crate::type_tool::foreground_changed(app); return; } let tool = app.ui.tool; - // What the tool in hand recolours: type layers, shape layers, or both (the Move tool). + // What the tool in hand recolours: type layers or shape layers. let (do_texts, do_shapes) = match tool { - Tool::Move => (true, true), t if t.is_type() && !t.is_type_mask() => (true, false), t if recolours_shapes(t) => (false, true), _ => return, @@ -75,13 +102,9 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { if texts.is_empty() && shapes.is_empty() { return; } - let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { - Some(k) => k, - None => { - let k = format!("apply-color-{}", app.ui.alloc_id()); - app.ui.apply_color_key = Some(k.clone()); - k - } + let key = match gesture { + Some(g) => format!("apply-color-{g}"), + None => format!("apply-color-{}", app.ui.alloc_id()), }; let color = hex(app.session.tools.foreground); let result = (|| { diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs index a007eb98450..b07d7317753 100644 --- a/crates/ui-egui/src/apply_color_tests.rs +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -58,9 +58,9 @@ fn steps(app: &PhotocraftApp) -> usize { app.session.active().unwrap().history.entries().len() } -fn pick(app: &mut PhotocraftApp, c: [f32; 4], continuing: bool) { +fn pick(app: &mut PhotocraftApp, c: [f32; 4], gesture: Option<&str>) { app.session.tools.foreground = c; - super::foreground_changed(app, continuing); + super::foreground_changed(app, gesture.map(str::to_string)); } #[test] @@ -68,7 +68,7 @@ fn a_type_tool_recolours_every_selected_type_layer_in_one_step() { for tool in [Tool::Type, Tool::VerticalType] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "{tool:?}"); assert!(shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}: shapes keep their fill"); assert_eq!(steps(&app), n + 1, "one history step"); @@ -82,7 +82,7 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { for tool in [Tool::Rectangle, Tool::Polygon, Tool::PathSelection, Tool::DirectSelection, Tool::Pen, Tool::CurvaturePen] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "{tool:?}"); assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))), "{tool:?}: type keeps its colour"); assert_eq!(steps(&app), n + 1, "{tool:?}: one history step for both layers"); @@ -91,10 +91,10 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { #[test] fn other_tools_only_change_the_foreground() { - for tool in [Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert_eq!(app.session.tools.foreground, RED); assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}"); assert_eq!(steps(&app), n, "{tool:?}: nothing recorded"); @@ -105,13 +105,18 @@ fn other_tools_only_change_the_foreground() { fn a_color_panel_drag_is_one_history_step_and_a_new_pick_another() { let (mut app, _, shapes) = app(Tool::Rectangle); let n = steps(&app); - pick(&mut app, [0.2, 0.0, 0.0, 1.0], false); - pick(&mut app, [0.6, 0.0, 0.0, 1.0], true); - pick(&mut app, RED, true); + pick(&mut app, [0.2, 0.0, 0.0, 1.0], None); + assert_eq!(steps(&app), n + 1, "a click or a swatch is one step"); + // One drag: every pick of one press. + pick(&mut app, [0.4, 0.0, 0.0, 1.0], Some("press-1")); + pick(&mut app, [0.6, 0.0, 0.0, 1.0], Some("press-1")); + pick(&mut app, RED, Some("press-1")); assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); - assert_eq!(steps(&app), n + 1, "the drag is one step"); - pick(&mut app, [0.0, 0.0, 1.0, 1.0], false); - assert_eq!(steps(&app), n + 2, "a new pick is another"); + assert_eq!(steps(&app), n + 2, "the drag is one step, not joined to the click before it"); + pick(&mut app, [0.0, 0.0, 1.0, 1.0], Some("press-2")); + assert_eq!(steps(&app), n + 3, "the next drag is another"); + pick(&mut app, [0.0, 1.0, 0.0, 1.0], None); + assert_eq!(steps(&app), n + 4, "a new pick is another"); } #[test] @@ -142,43 +147,3 @@ fn a_swatch_and_the_color_picker_go_through_it() { assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); } - -#[test] -fn the_move_tool_recolours_the_selected_type_and_shapes_together_in_one_step() { - // Layers picked with the Move tool (a click, ⇧-click or its marquee) take the colour, type and - // shapes alike. - let (mut app, texts, shapes) = app(Tool::Move); - let n = steps(&app); - pick(&mut app, RED, false); - assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "the type is red"); - assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "the shapes are red"); - assert_eq!(steps(&app), n + 1, "one history step for all four layers"); - assert!(app.session.undo()); - assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap()))); - // Only the selected ones: with one shape selected, the rest keep their colour. - app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); - pick(&mut app, RED, false); - assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); - assert!(!red(fill_rgb(&app, shapes[1]).unwrap()) && texts.iter().all(|id| !red(text_rgb(&app, *id)))); -} - -#[test] -fn a_move_tool_marquee_selection_takes_the_colour() { - // The video case: shapes box-selected with the Move tool's marquee, then a swatch. - let (mut app, _, shapes) = app(Tool::Move); - app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); - // The marquee from an empty spot across both shapes. - for (kind, x, y) in [("down", 140.0, 10.0), ("move", 200.0, 50.0), ("move", 290.0, 90.0), ("up", 290.0, 90.0)] { - let ev = match kind { - "down" => crate::canvas::ToolEvent::Down { x, y, pressure: 1.0 }, - "move" => crate::canvas::ToolEvent::Move { x, y, pressure: 1.0 }, - _ => crate::canvas::ToolEvent::Up { x, y }, - }; - crate::canvas::tool_event(&mut app, ev, egui::Modifiers::NONE); - } - let mut sel = app.session.active().unwrap().selected_layers(); - sel.sort_by_key(|l| l.0); - assert_eq!(sel, shapes, "the marquee selected both shapes"); - pick(&mut app, RED, false); - assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red))); -} diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs index 319413aaf97..d37deec36f0 100644 --- a/crates/ui-egui/src/color_picker_ui.rs +++ b/crates/ui-egui/src/color_picker_ui.rs @@ -828,7 +828,7 @@ pub fn confirm(app: &mut PhotocraftApp, f: &Map) -> Result match &sh.fill { + Some(Fill::Solid(c)) => srgb_bytes([c.c[0], c.c[1], c.c[2], 1.0]), + _ => panic!("a solid fill"), + }, + _ => panic!("not a shape layer"), + }; + let steps = |app: &PhotocraftApp| app.session.active().unwrap().history.entries().len(); + let before = steps(h.state()); + // The only spin buttons are R, G and B, in that order. + for (field, text, steps_after, want) in [(1, "128", 1, [0x00, 0x80, 0x00]), (2, "64", 2, [0x00, 0x80, 0x40])] { + h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(field).unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + for ch in text.chars() { + h.event(egui::Event::Text(ch.to_string())); + h.run_steps(1); + } + h.key_press(egui::Key::Tab); + h.run_steps(2); + assert_eq!(fill(h.state()), want, "{text}"); + assert_eq!(steps(h.state()), before + steps_after, "{text}: one step for the typed value"); + } + // Typing into B again and clicking the field while B still has the focus: two steps, the + // click is not part of the typed value. + h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(2).unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + h.event(egui::Event::Text("9".into())); + h.run_steps(1); + assert_eq!(fill(h.state()), [0x00, 0x80, 0x09]); + assert_eq!(steps(h.state()), before + 3, "the typed 9"); + let min = h.ctx.input(|i| i.viewport_rect()).min; + click(&mut h, min + vec2(60.0, 10.0)); + assert_eq!(steps(h.state()), before + 4, "the click after typing"); + // A sum applies when Enter commits it, after the field let go of the focus: still the + // step of the "2" typed before it. + h.query_all_by_role(egui::accesskit::Role::SpinButton).next().unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + for ch in "2*64".chars() { + h.event(egui::Event::Text(ch.to_string())); + h.run_steps(1); + } + h.key_press(egui::Key::Enter); + h.run_steps(2); + assert_eq!(fill(h.state())[0], 0x80, "2*64"); + assert_eq!(steps(h.state()), before + 5, "2*64 is one step"); + } + /// The pro Color panel's hex readout edits the foreground too. #[test] fn color_field_hex_field_takes_a_typed_hex() { @@ -4864,6 +4931,43 @@ mod color_tests { } } + /// With a shape tool and a shape layer selected, the field recolours its fill, and each + /// gesture is its own undo step: a click, every drag, and a swatch followed by a drag. A drag + /// only reaches the field after its press frame, so it must not join the step before it. + #[test] + fn color_panel_gestures_recolour_the_selected_shape_in_separate_steps() { + use photocraft_doc::{Fill, LayerContent, LayerId}; + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 64, "height": 48})).unwrap(); + let id = LayerId(app.run("shape.create", json!({"rect": [8, 8, 40, 30], "fill": "#000000"})).unwrap()["layer"].as_u64().unwrap()); + app.ui.tool = crate::state::Tool::Rectangle; + let mut h = field_harness(app); + let is_foreground = |app: &PhotocraftApp| { + let fg = app.session.tools.foreground; + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Shape(sh) => matches!(&sh.fill, Some(Fill::Solid(c)) if (0..3).all(|i| (c.c[i] - fg[i]).abs() < 0.01)), + _ => panic!("not a shape layer"), + } + }; + let steps = |app: &PhotocraftApp| app.session.active().unwrap().history.entries().len(); + let before = steps(h.state()); + let min = h.ctx.input(|i| i.viewport_rect()).min; + click(&mut h, min + vec2(60.0, 10.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 1, "the click"); + drag(&mut h, min + vec2(120.0, 40.0), min + vec2(250.0, 120.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 2, "the drag is one more step"); + drag(&mut h, min + vec2(200.0, 60.0), min + vec2(100.0, 150.0)); + assert_eq!(steps(h.state()), before + 3, "the next drag another"); + let name = h.state_mut().run("swatches.list", json!({})).unwrap()["groups"][0]["swatches"][0]["name"].as_str().unwrap().to_string(); + crate::swatches_ui::use_swatch(h.state_mut(), &name, false); + assert_eq!(steps(h.state()), before + 4, "the swatch"); + drag(&mut h, min + vec2(150.0, 30.0), min + vec2(220.0, 100.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 5, "a drag after a swatch is a step of its own"); + } + /// Press at `from`, move to `to` in six steps and release, as egui sees a drag. fn drag(h: &mut egui_kittest::Harness<'_, PhotocraftApp>, from: egui::Pos2, to: egui::Pos2) { h.hover_at(from); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 333f3455745..974d3fde358 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -1210,9 +1210,6 @@ pub struct UiState { /// Direct Selection tool: selected anchors and the drag in progress (#790). #[serde(default)] pub direct_selection: crate::direct_select::DirectSelection, - /// The history step a Color panel drag recolouring the selection joins (`apply_color`). - #[serde(skip)] - pub apply_color_key: Option, /// A live rectangle's corner radius widget being dragged (TOOL-214-12). #[serde(skip)] pub corner_radius: Option, @@ -1407,7 +1404,6 @@ impl Default for UiState { pen: None, stroke_editor: None, direct_selection: Default::default(), - apply_color_key: None, corner_radius: None, selected_path: None, panels: Panels::default(), diff --git a/crates/ui-egui/src/swatches_ui.rs b/crates/ui-egui/src/swatches_ui.rs index 6013ec779da..bc900c8c382 100644 --- a/crates/ui-egui/src/swatches_ui.rs +++ b/crates/ui-egui/src/swatches_ui.rs @@ -53,7 +53,7 @@ pub fn use_swatch(app: &mut PhotocraftApp, name: &str, background: bool) { if run(app, "swatches.use", json!({"swatch": name, "target": target})).is_some() && !background { // Clicking a swatch recolours the selected characters (#364), or the selected type or // shape layers with a Type, shape or Pen tool, as in Photoshop. - crate::apply_color::foreground_changed(app, false); + crate::apply_color::foreground_changed(app, None); } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 239af4d994c..418f1e7f868 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -209,7 +209,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | -| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; both with the Move tool (layers picked by click, ⇧-click or its marquee); only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools, the Move tool too; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -258,4 +258,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | -| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool), shape fills (shape, Pen and path selection tools), or both (Move tool) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) |