PhotoCraft: An open-source, photo editor written by scratch in pure Rust
feat(ui): select guides, the guide context menu and Edit Selected Guides (#3734)
FinnNka61df64cc9fd
diff --git a/crates/engine/src/edit_cmds.rs b/crates/engine/src/edit_cmds.rsindex 20ef23a41..dcb89aa98 100644--- a/crates/engine/src/edit_cmds.rs+++ b/crates/engine/src/edit_cmds.rs@@ -835,6 +835,44 @@ fn guide_color(p: &Value) -> Result<Option<[u8; 3]>> {)}+/// Edit Selected Guides (the guide context menu): change one guide's orientation, position and+/// colour in one history step. A guide that keeps its orientation keeps its index; one that turns+/// goes to the end of the other list. Without `color` it keeps its own colour, or none.+fn edit_guide(s: &mut Session, p: &Value) -> Result<Value> {+ let orientation = |key: &str| match p.get(key).map(|v| v.as_str()) {+ None => Ok(None),+ Some(Some("horizontal")) => Ok(Some(false)),+ Some(Some("vertical")) => Ok(Some(true)),+ Some(_) => Err(EngineError::Other(format!("`{key}` must be \"horizontal\" or \"vertical\""))),+ };+ let from = orientation("orientation")?.unwrap_or(false);+ let to = orientation("newOrientation")?.unwrap_or(from);+ let index = p.get("index").and_then(Value::as_u64).ok_or(EngineError::Other("missing `index`".into()))?;+ let pos = guide_position(s, p, to)?;+ let color = guide_color(p)?;+ s.edit("Edit Guide", |doc, _| {+ let guides = &mut doc.guides;+ let list = if from { &guides.vertical } else { &guides.horizontal };+ let i = usize::try_from(index).ok().filter(|i| *i < list.len()).ok_or(EngineError::Other("no such guide".into()))?;+ let old = list[i];+ let at = pos.unwrap_or(old);+ let rgb = color.or_else(|| guides.color(from, old));+ if from == to {+ let list = if from { &mut guides.vertical } else { &mut guides.horizontal };+ list[i] = at;+ } else {+ (if from { &mut guides.vertical } else { &mut guides.horizontal }).remove(i);+ (if to { &mut guides.vertical } else { &mut guides.horizontal }).push(at);+ }+ guides.prune_colors();+ if rgb.is_some() {+ guides.set_color(to, at, rgb);+ }+ Ok(())+ })?;+ Ok(Value::Null)+}+/// View › New Guide / guide moves (undoable, like Photoshop's "New Guide"/"Move Guide" states).fn guide_cmd(s: &mut Session, p: &Value, op: &str) -> Result<Value> {let vertical = p.get("orientation").and_then(Value::as_str).unwrap_or("horizontal") == "vertical";@@ -1014,6 +1052,15 @@ pub fn specs() -> Vec<CommandSpec> {has_doc,|s, p| guide_cmd(s, p, "move")),+ spec!(+ "view.editGuide",+ "Edit Guide",+ &[],+ None,+ r##"{"orientation":"horizontal|vertical","index":n,"newOrientation":"horizontal|vertical"?,"position":px or "<number><unit>"?,"color":name or "#rrggbb"?} (Edit Selected Guides: units and colours as for view.newGuide; % is of the new orientation's extent; whatever is left out stays as it was)"##,+ has_doc,+ edit_guide+ ),spec!("view.deleteGuide", "Delete Guide", &[], None, r##"{"orientation":"horizontal|vertical","index":n}"##, has_doc, |s, p| guide_cmd(s, p, "delete")),spec!("view.clearGuides", "Clear Guides", &["View"], None, "{}", has_doc, |s, p| guide_cmd(s, p, "clear")),spec!(@@ -2082,6 +2129,60 @@ mod tests {assert_eq!(s.active().unwrap().history.can_undo(), undo_before);}+ #[test]+ fn editing_a_guide_changes_what_is_given_in_one_undoable_step() {+ let mut s = Session::new();+ s.execute("file.new", json!({"width": 400, "height": 200})).unwrap();+ s.execute("view.newGuide", json!({"orientation": "vertical", "position": 10})).unwrap();+ s.execute("view.newGuide", json!({"orientation": "vertical", "position": 20, "color": "magenta"})).unwrap();+ s.execute("view.newGuide", json!({"orientation": "vertical", "position": 30})).unwrap();+ let guides = |s: &Session| s.active().unwrap().doc.guides.clone();+ // Position only: the guide keeps its index and its own colour.+ s.execute("view.editGuide", json!({"orientation": "vertical", "index": 1, "position": "50%"})).unwrap();+ let g = guides(&s);+ assert_eq!(g.vertical, vec![10.0, 200.0, 30.0]);+ assert_eq!((g.color(true, 20.0), g.color(true, 200.0)), (None, Some([0xff, 0x00, 0xff])));+ // Colour only: an uncoloured guide gets one; the position stays.+ s.execute("view.editGuide", json!({"orientation": "vertical", "index": 0, "color": "#123456"})).unwrap();+ assert_eq!(guides(&s).color(true, 10.0), Some([0x12, 0x34, 0x56]));+ // Turning it: % is of the new orientation's extent, and the colour goes along.+ s.execute("view.editGuide", json!({"orientation": "vertical", "index": 1, "newOrientation": "horizontal", "position": "25%"})).unwrap();+ let g = guides(&s);+ assert_eq!((g.vertical.clone(), g.horizontal.clone()), (vec![10.0, 30.0], vec![50.0]));+ assert_eq!((g.color(true, 200.0), g.color(false, 50.0)), (None, Some([0xff, 0x00, 0xff])));+ // One step each: undo restores the vertical guide with its colour.+ s.undo();+ let g = guides(&s);+ assert_eq!((g.vertical.clone(), g.horizontal.is_empty()), (vec![10.0, 200.0, 30.0], true));+ assert_eq!(g.color(true, 200.0), Some([0xff, 0x00, 0xff]));+ }++ #[test]+ fn bad_guide_edits_are_refused_without_a_history_step() {+ let mut s = Session::new();+ s.execute("file.new", json!({"width": 400, "height": 200})).unwrap();+ s.execute("view.newGuide", json!({"orientation": "vertical", "position": 10, "color": "green"})).unwrap();+ let before = s.active().unwrap().doc.guides.clone();+ for bad in [+ json!({}),+ json!({"orientation": "vertical"}),+ json!({"orientation": "vertical", "index": 1}),+ json!({"orientation": "horizontal", "index": 0}),+ json!({"orientation": "vertical", "index": -1}),+ json!({"orientation": "vertical", "index": "0"}),+ json!({"orientation": "vertical", "index": u64::MAX}),+ json!({"orientation": "diagonal", "index": 0}),+ json!({"orientation": "vertical", "index": 0, "newOrientation": 3}),+ json!({"orientation": "vertical", "index": 0, "position": "far"}),+ json!({"orientation": "vertical", "index": 0, "position": 1e12}),+ json!({"orientation": "vertical", "index": 0, "color": "puce"}),+ ] {+ assert!(s.execute("view.editGuide", bad.clone()).is_err(), "{bad}");+ }+ assert_eq!(s.active().unwrap().doc.guides, before);+ assert_eq!(s.active().unwrap().history.undo_label(), Some("New Guide"));+ }+#[test]fn bad_guide_positions_are_refused_without_a_guide() {let mut s = Session::new();diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 1f79f8350..7a9592b69 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -3396,10 +3396,17 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:crate::lasso_ui::canvas_input(app, &ctx, &xf, &response);(buttons.started, buttons.dragged, buttons.stopped, buttons.clicked) = (false, false, false, false);}+ // Right-click on a guide where it could be dragged (the Move tool, or ⌘ with a selection+ // tool): select it and open the guide menu, as Photoshop does.+ let guide_menu = response.secondary_clicked()+ && !lasso_retracted+ && !transforming+ && response.interact_pointer_pos().is_some_and(|p| crate::canvas_tool_menu::open_guide(app, &ctx, tool, mods, [p.x, p.y], xf.to_doc(p)));// Right-click with the Move tool, or ⌘/Ctrl+right-click: the layers under the pointer.if response.secondary_clicked()&& !lasso_retracted&& !transforming+ && !guide_menu&& crate::layer_pick_ui::is_gesture(tool, mods)&& let Some(p) = response.interact_pointer_pos(){@@ -3413,6 +3420,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:if response.secondary_clicked()&& !lasso_retracted&& !transforming+ && !guide_menu&& !crate::layer_pick_ui::is_gesture(tool, mods)&& let Some(p) = response.interact_pointer_pos(){@@ -3590,6 +3598,12 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:Tool::MagneticLasso if response.double_clicked() || response.triple_clicked() => crate::magnetic_lasso_ui::close(app, mods.alt),// The first click placed (or grabbed) the point; the second toggles it.Tool::CurvaturePen if response.double_clicked() => crate::vector_ui::curvature_toggle(app, d[0], d[1]),+ // Double-clicking a guide opens Preferences › Guides, Grid & Slices, as in Photoshop.+ Tool::Move if response.double_clicked() && crate::rulers::guide_at(app, d[0], d[1]).is_some() => {+ if let Err(e) = crate::menus::invoke(app, &ctx, "edit.preferences.guidesGridAndSlices", json!({})) {+ app.ui.status = e;+ }+ }_ => {if tool == Tool::Move && app.ui.transform.is_none() {begin_transform_controls_at(app, &ctx, &xf, p);@@ -4923,6 +4937,13 @@ fn tool_move(app: &mut PhotocraftApp, x: f64, y: f64, pressure: f32, mods: egui:/// Tool state machine. Shared by mouse input and automation.pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) {+ // A press anywhere but on a guide deselects the selected guide (`guide_select`).+ if let ToolEvent::Down { x, y, .. } = ev+ && app.ui.selected_guide.is_some()+ && crate::rulers::guide_at(app, x, y).is_none()+ {+ crate::guide_select::clear(app);+ }if crate::symmetry_ui::pointer(app, ev, crate::workspace_ui::sticky_mods(app, mods)) {return;}@@ -5024,7 +5045,7 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)if let ToolEvent::Down { x, y, .. } = raw&& let Some((vertical, i)) = command_guide_at(app, app.active_tool(), [x, y], mods){- app.guide_drag = Some(crate::rulers::GuideDrag { vertical, index: Some(i), pos: if vertical { x } else { y } });+ app.guide_drag = Some(crate::rulers::GuideDrag::existing(vertical, i, [x, y]));crate::snap_ui::begin_guide(app, [x, y]);return;}@@ -5068,7 +5089,12 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)match ev {ToolEvent::Down { x, y, pressure } if tool == Tool::Move => {if let Some((vertical, i)) = crate::rulers::guide_at(app, x, y) {- app.guide_drag = Some(crate::rulers::GuideDrag { vertical, index: Some(i), pos: if vertical { x } else { y } });+ // ⌥-click turns the guide, through the point clicked, as in Photoshop.+ if mods.alt && !mods.shift && !mods.command {+ crate::guide_select::flip(app, vertical, i, [x, y]);+ return;+ }+ app.guide_drag = Some(crate::rulers::GuideDrag::existing(vertical, i, [x, y]));return;}// Auto-Select (or ⌘-click while it is off) picks the layer under the pointer firstdiff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rsindex 8d4837bd5..da835a786 100644--- a/crates/ui-egui/src/canvas_tool_menu.rs+++ b/crates/ui-egui/src/canvas_tool_menu.rs@@ -1,5 +1,5 @@//! Canvas context menus for the selection tools, the Pen, the Zoom and Hand tools, an active Free-//! Transform box, text being edited with a Type tool and the pasteboard (outside the image).+//! Transform box, text being edited with a Type tool, the pasteboard (outside the image) and a guide.use egui::Context;use photocraft_doc::LayerContent;@@ -31,6 +31,9 @@ pub struct CanvasToolMenu {/// Opened while a Type tool edits text: the text and type rows instead of the tool's actions.#[serde(default)]pub text: bool,+ /// Opened on a guide: the guide menu (`guide_select`) instead of the tool's actions.+ #[serde(default)]+ pub guide: bool,/// The misspelled word under the pointer when the type edit menu opened: its suggestions head/// the menu.#[serde(default)]@@ -145,6 +148,23 @@ const ENDS_TYPE_EDIT: [&str; 5] =/// The pasteboard menu's Select Custom Color… row.pub const PASTEBOARD_PICK: &str = "pasteboard.selectCustomColor";+/// The guide menu's Edit Selected Guides row: New Guide's dialog on the selected guide.+pub const GUIDE_EDIT: &str = "guides.editSelected";+/// The guide menu's Clear Selected Guides row.+pub const GUIDE_CLEAR: &str = "guides.clearSelected";++/// Photoshop's guide menu (right-click on a guide), in its order. Its two Selected Guides rows act+/// on the guide the right-click selected; the rest are the View menu's.+pub const GUIDE_MENU: &[Row] = &[+ Some(("Edit Selected Guides", GUIDE_EDIT)),+ None,+ Some(("Lock Guides", "view.lockGuides")),+ Some(("Clear Guides", "view.clearGuides")),+ Some(("Clear Canvas Guides", "view.clearCanvasGuides")),+ Some(("Clear Selected Guides", GUIDE_CLEAR)),+ Some(("Clear Selected Artboard Guides", "view.clearSelectedArtboardGuides")),+];+/// The pasteboard colours in the menu's order, which Space+F steps through.const CANVAS_COLORS: [CanvasColor; 6] =[CanvasColor::Default, CanvasColor::Black, CanvasColor::DarkGray, CanvasColor::MediumGray, CanvasColor::LightGray, CanvasColor::Custom];@@ -280,7 +300,9 @@ pub fn selection_rows(has_selection: bool) -> &'static [Row] {/// The rows of an open menu.pub fn rows(menu: &CanvasToolMenu) -> &'static [Row] {- if menu.pasteboard {+ if menu.guide {+ GUIDE_MENU+ } else if menu.pasteboard {PASTEBOARD_MENU} else if menu.transform {TRANSFORM_MENU@@ -304,6 +326,9 @@ pub fn available(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> b/// Scale stays Free Transform's mode (only Free Transform is checked). Rotate is its own mode./// Warp is not a box mode (it is its own session), and `for_command` would read it as Free.pub(crate) fn mode_checked(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool {+ if menu.guide {+ return command == "view.lockGuides" && app.ui.extras.lock_guides;+ }if menu.pasteboard {return pasteboard_choice(command) == Some(app.session.prefs().interface.canvas_color);}@@ -393,6 +418,7 @@ pub fn open_transform(app: &mut PhotocraftApp, ctx: &Context, pos: [f32; 2]) ->pasteboard: false,anchor: None,text: false,+ guide: false,spelling: None,});crate::canvas_popup::mark_open(ctx, menu_id());@@ -407,7 +433,15 @@ fn pasteboard_choice(command: &str) -> Option<CanvasColor> {/// The engine command (and params) a pasteboard row runs, for the automation policy: every row/// changes a preference.-pub fn engine_call(menu: &CanvasToolMenu, command: &str) -> (String, Value) {+pub fn engine_call(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> (String, Value) {+ if menu.guide {+ let selected = crate::guide_select::selected(app);+ return match command {+ GUIDE_EDIT => ("view.editGuide".into(), json!({})),+ GUIDE_CLEAR => ("view.deleteGuide".into(), selected.map_or(json!({}), |(v, i)| crate::guide_select::delete_params(v, i))),+ _ => (command.into(), json!({})),+ };+ }match pasteboard_choice(command) {Some(c) if menu.pasteboard => ("prefs.set".into(), json!({"values": {"interface.canvasColor": c.name()}})),_ if menu.pasteboard => ("prefs.set".into(), json!({})),@@ -457,12 +491,51 @@ pub fn open_pasteboard(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos:pasteboard: true,anchor: None,text: false,+ guide: false,spelling: None,});crate::canvas_popup::mark_open(ctx, menu_id());true}+/// Right-click at document point `doc` on a guide that `tool` could drag (the Move tool, or ⌘ with+/// a selection tool): select the guide and open the guide menu at screen point `pos`.+pub fn open_guide(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, mods: egui::Modifiers, pos: [f32; 2], doc: [f64; 2]) -> bool {+ if !pos.iter().all(|v| v.is_finite()) || !doc.iter().all(|v| v.is_finite()) {+ return false;+ }+ let hit = if tool == Tool::Move { crate::rulers::guide_at(app, doc[0], doc[1]) } else { crate::canvas::command_guide_at(app, tool, doc, mods) };+ let Some((vertical, index)) = hit else { return false };+ crate::guide_select::select(app, vertical, index);+ app.ui.brush_picker = None;+ app.ui.layer_menu = None;+ app.ui.canvas_tool_menu = Some(CanvasToolMenu {+ pos,+ tool,+ has_selection: false,+ has_path: false,+ path_name: None,+ transform: false,+ pasteboard: false,+ anchor: None,+ text: false,+ guide: true,+ spelling: None,+ });+ crate::canvas_popup::mark_open(ctx, menu_id());+ true+}++/// A guide row: the two Selected Guides rows act on the selected guide; the rest are the View+/// menu's commands.+fn choose_guide(app: &mut PhotocraftApp, ctx: &Context, command: &str) -> Result<(), String> {+ match command {+ GUIDE_EDIT => crate::new_guide_ui::open_edit(app).map(|_| ()),+ GUIDE_CLEAR => crate::guide_select::delete_selected(app).map(|_| ()),+ _ => crate::menus::invoke(app, ctx, command, json!({})).map(|_| ()),+ }+}+/// A pasteboard row: set the colour, or open the Color Picker on the custom one.fn choose_pasteboard(app: &mut PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> Result<(), String> {if command == PASTEBOARD_PICK {@@ -470,11 +543,17 @@ fn choose_pasteboard(app: &mut PhotocraftApp, menu: &CanvasToolMenu, command: &scrate::color_picker_ui::open_for_target(app, "pasteboard", "Color Picker (Custom Canvas Color)", rgb);return Ok(());}- let (command, params) = engine_call(menu, command);+ let (command, params) = engine_call(app, menu, command);app.run(&command, params).map(|_| ())}pub fn entry_enabled(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool {+ if menu.guide {+ return match command {+ GUIDE_EDIT | GUIDE_CLEAR => crate::guide_select::selected(app).is_some(),+ _ => GUIDE_MENU.iter().flatten().any(|(_, id)| *id == command) && crate::menus::is_enabled(app, command),+ };+ }if menu.pasteboard {return PASTEBOARD_MENU.iter().flatten().any(|(_, id)| *id == command);}@@ -549,7 +628,7 @@ pub fn open_at(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: [f32; 2]let path_name = crate::vector_ui::active_path_name(app);let spelling = if text { doc.and_then(|d| spelling_at(app, d)) } else { None };app.ui.canvas_tool_menu =- Some(CanvasToolMenu { pos, tool, has_selection, has_path, path_name, transform: false, pasteboard: false, anchor: None, text, spelling });+ Some(CanvasToolMenu { pos, tool, has_selection, has_path, path_name, transform: false, pasteboard: false, anchor: None, text, guide: false, spelling });crate::canvas_popup::mark_open(ctx, menu_id());true}@@ -572,6 +651,7 @@ pub fn open_view(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: [f32;pasteboard: false,anchor: Some(doc),text: false,+ guide: false,spelling: None,});crate::canvas_popup::mark_open(ctx, menu_id());@@ -609,7 +689,9 @@ pub fn choose(app: &mut PhotocraftApp, ctx: &Context, command: &str) {if !available(app, &menu, command) {return;}- let result = if menu.pasteboard {+ let result = if menu.guide {+ choose_guide(app, ctx, command)+ } else if menu.pasteboard {choose_pasteboard(app, &menu, command)} else if menu.anchor.is_some() {choose_view(app, ctx, &menu, command)@@ -635,7 +717,7 @@ pub fn choose(app: &mut PhotocraftApp, ctx: &Context, command: &str) {/// A spelling row: replace the word under the pointer (the caret lands after the replacement), or/// add it to the user dictionary.fn choose_spelling(app: &mut PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> Result<(), String> {- let (id, params) = engine_call(menu, command);+ let (id, params) = engine_call(app, menu, command);let result = app.run(&id, params)?;if let Some(end) = result["end"].as_u64().map(|e| e as usize)&& let Some(e) = app.ui.text_edit.as_mut()diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rsindex 44a9f4799..ff786be19 100644--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@ -397,7 +397,7 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest)return err("context action is unavailable");}// A pasteboard row changes a preference: the policy sees the `prefs.set` it runs.- let (command, params) = crate::canvas_tool_menu::engine_call(menu, id);+ let (command, params) = crate::canvas_tool_menu::engine_call(app, menu, id);if let Some(authorize) = app.services.automation_command.as_ref()&& let Err(error) = authorize(&command, ¶ms){@@ -1311,6 +1311,7 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value {"pos": menu.pos,"tool": menu.tool,"pasteboard": menu.pasteboard,+ "guide": menu.guide,"entries": context_entries(app, menu)})}),diff --git a/crates/ui-egui/src/guide_select.rs b/crates/ui-egui/src/guide_select.rsnew file mode 100644index 000000000..815d02862--- /dev/null+++ b/crates/ui-egui/src/guide_select.rs@@ -0,0 +1,110 @@+//! Selecting a guide on the canvas, as in Photoshop: a click on a guide with the Move tool selects+//! it (drawn in Photoshop's selected-guide blue), a press anywhere else deselects it, Delete+//! removes it, and right-click opens the guide menu (`canvas_tool_menu`), whose Edit Selected+//! Guides reopens New Guide on it.+//!+//! One guide at a time. The selection is view state, not a history step: it names the guide by+//! document, orientation and position, as guide colours do, so it lapses by itself when the guide+//! moves away, is deleted or undone, and the index is looked up when it is used.++use serde::{Deserialize, Serialize};+use serde_json::json;++use crate::PhotocraftApp;++/// Photoshop draws a selected guide in this blue, whatever the guide's own colour.+pub const SELECTED_COLOR: egui::Color32 = egui::Color32::from_rgb(0x00, 0x00, 0xff);++#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]+pub struct SelectedGuide {+ /// The document's index among the open documents.+ pub doc: usize,+ pub vertical: bool,+ pub position: f64,+}++/// The selected guide's orientation and index in the active document, while guides can be+/// interacted with (shown, unlocked).+pub fn selected(app: &PhotocraftApp) -> Option<(bool, usize)> {+ let sel = app.ui.selected_guide?;+ if !interactive(app) || app.session.active_index() != Some(sel.doc) {+ return None;+ }+ let guides = &app.session.active()?.doc.guides;+ let list = if sel.vertical { &guides.vertical } else { &guides.horizontal };+ list.iter().position(|p| *p == sel.position).map(|i| (sel.vertical, i))+}++/// Is the guide at `position` the selected one (drawn blue)?+pub fn is_selected(app: &PhotocraftApp, vertical: bool, position: f64) -> bool {+ selected(app).is_some() && app.ui.selected_guide.is_some_and(|s| s.vertical == vertical && s.position == position)+}++/// Guides take clicks only while they're shown and unlocked (as `rulers::guide_at` requires).+fn interactive(app: &PhotocraftApp) -> bool {+ app.ui.extras.guides && app.ui.view.shows(app.ui.view.show.canvas_guides) && !app.ui.extras.lock_guides+}++/// Select guide `index` of the active document.+pub fn select(app: &mut PhotocraftApp, vertical: bool, index: usize) {+ let Some(doc) = app.session.active_index() else { return };+ let Some(guides) = app.session.active().map(|st| &st.doc.guides) else { return };+ let list = if vertical { &guides.vertical } else { &guides.horizontal };+ app.ui.selected_guide = list.get(index).map(|position| SelectedGuide { doc, vertical, position: *position });+}++pub fn clear(app: &mut PhotocraftApp) {+ app.ui.selected_guide = None;+}++/// Delete the selected guide (Delete, Clear Selected Guides). False when no guide is selected.+pub fn delete_selected(app: &mut PhotocraftApp) -> Result<bool, String> {+ let Some((vertical, index)) = selected(app) else { return Ok(false) };+ app.run("view.deleteGuide", delete_params(vertical, index))?;+ clear(app);+ Ok(true)+}++pub fn delete_params(vertical: bool, index: usize) -> serde_json::Value {+ json!({"orientation": if vertical { "vertical" } else { "horizontal" }, "index": index})+}++/// ⌥-click on guide `index`: turn it, so a vertical guide becomes horizontal through the point+/// clicked (`at`, document pixels) and the other way round, as one undoable step (`view.editGuide`);+/// it stays selected.+pub fn flip(app: &mut PhotocraftApp, vertical: bool, index: usize, at: [f64; 2]) {+ let (from, to) = if vertical { ("vertical", "horizontal") } else { ("horizontal", "vertical") };+ let position = if vertical { at[1] } else { at[0] };+ let params = json!({"orientation": from, "index": index, "newOrientation": to, "position": (position * 1000.0).round() / 1000.0});+ match app.run("view.editGuide", params) {+ Ok(_) => {+ let last = app.session.active().map(|st| if vertical { st.doc.guides.horizontal.len() } else { st.doc.guides.vertical.len() });+ if let Some(n) = last.and_then(|n| n.checked_sub(1)) {+ select(app, !vertical, n);+ }+ }+ Err(e) => app.ui.status = e,+ }+}++/// Delete or Backspace with no modifiers while a guide is selected deletes the guide, before Edit ›+/// Clear can reach the pixels, as in Photoshop.+pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {+ use crate::shortcut_dispatch::Focus;+ // Text fields and widgets that delete with these keys themselves keep them (#1534).+ if selected(app).is_none() || app.ui.text_edit.is_some() || matches!(Focus::of(ctx), Focus::Text | Focus::DeletingWidget) {+ return false;+ }+ let mods = ctx.input(|i| i.modifiers);+ if !mods.is_none() || !ctx.input_mut(|i| i.consume_key(mods, egui::Key::Delete) || i.consume_key(mods, egui::Key::Backspace)) {+ return false;+ }+ if let Err(e) = delete_selected(app) {+ app.ui.status = e;+ app.ui.status_error = true;+ }+ true+}++#[cfg(test)]+mod tests;diff --git a/crates/ui-egui/src/guide_select/tests.rs b/crates/ui-egui/src/guide_select/tests.rsnew file mode 100644index 000000000..a591f4754--- /dev/null+++ b/crates/ui-egui/src/guide_select/tests.rs@@ -0,0 +1,308 @@+use egui::{Key, Modifiers, PointerButton, Pos2, vec2};+use egui_kittest::Harness;+use serde_json::json;++use super::*;+use crate::canvas::{ToolEvent, tool_event};+use crate::canvas_tool_menu::{GUIDE_CLEAR, GUIDE_EDIT};+use crate::state::Tool;++/// A 200 × 100 document with the Move tool, a vertical guide at 50 and a magenta horizontal one+/// at 30.+fn app() -> PhotocraftApp {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({"width": 200, "height": 100})).unwrap();+ app.sync_views();+ app.ui.tool = Tool::Move;+ app.run("view.newGuide", json!({"orientation": "vertical", "position": 50})).unwrap();+ app.run("view.newGuide", json!({"orientation": "horizontal", "position": 30, "color": "magenta"})).unwrap();+ app+}++fn click(app: &mut PhotocraftApp, x: f64, y: f64) {+ tool_event(app, ToolEvent::Down { x, y, pressure: 1.0 }, Modifiers::NONE);+ tool_event(app, ToolEvent::Up { x, y }, Modifiers::NONE);+}++fn guides(app: &PhotocraftApp) -> (Vec<f64>, Vec<f64>) {+ let g = &app.session.active().unwrap().doc.guides;+ (g.vertical.clone(), g.horizontal.clone())+}++fn past(app: &PhotocraftApp) -> usize {+ app.session.active().unwrap().history.past_len()+}++#[test]+fn a_click_selects_a_guide_without_moving_it_and_a_press_elsewhere_deselects() {+ let mut app = app();+ let steps = past(&app);+ click(&mut app, 50.0, 70.0);+ assert_eq!(selected(&app), Some((true, 0)));+ assert!(is_selected(&app, true, 50.0) && !is_selected(&app, false, 30.0));+ assert_eq!((guides(&app), past(&app)), ((vec![50.0], vec![30.0]), steps), "a click is not a move");+ // One guide at a time: clicking another selects it instead.+ click(&mut app, 120.0, 30.0);+ assert_eq!(selected(&app), Some((false, 0)));+ click(&mut app, 120.0, 70.0);+ assert_eq!(selected(&app), None);+ // A press with another tool deselects too.+ click(&mut app, 50.0, 70.0);+ app.ui.tool = Tool::RectMarquee;+ tool_event(&mut app, ToolEvent::Down { x: 150.0, y: 80.0, pressure: 1.0 }, Modifiers::NONE);+ assert_eq!(selected(&app), None);+}++#[test]+fn a_moved_guide_stays_selected_and_dragging_one_off_the_canvas_deletes_it() {+ let mut app = app();+ tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 70.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Move { x: 80.0, y: 70.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Up { x: 80.0, y: 70.0 }, Modifiers::NONE);+ assert_eq!(guides(&app).0, vec![80.0]);+ assert_eq!(selected(&app), Some((true, 0)));+ tool_event(&mut app, ToolEvent::Down { x: 80.0, y: 70.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Up { x: -20.0, y: 70.0 }, Modifiers::NONE);+ assert!(guides(&app).0.is_empty());+ assert_eq!(selected(&app), None);+}++#[test]+fn the_selection_lapses_when_its_guide_goes_or_guides_are_hidden_or_locked() {+ let mut app = app();+ click(&mut app, 50.0, 70.0);+ app.ui.extras.lock_guides = true;+ assert_eq!(selected(&app), None, "locked guides can't be selected");+ app.ui.extras.lock_guides = false;+ app.ui.extras.guides = false;+ assert_eq!(selected(&app), None, "nor hidden ones");+ app.ui.extras.guides = true;+ assert_eq!(selected(&app), Some((true, 0)));+ app.run("view.clearGuides", json!({})).unwrap();+ assert_eq!(selected(&app), None);+ app.session.undo();+ assert_eq!(selected(&app), Some((true, 0)), "undo brings the guide back, still selected");+ // Another document's guide at the same place isn't the selected one.+ app.run("file.new", json!({"width": 200, "height": 100})).unwrap();+ app.run("view.newGuide", json!({"orientation": "vertical", "position": 50})).unwrap();+ assert_eq!(selected(&app), None);+}++#[test]+fn delete_removes_the_selected_guide_and_leaves_the_pixels() {+ let mut app = app();+ app.run("select.all", json!({})).unwrap();+ let ctx = egui::Context::default();+ let press = |app: &mut PhotocraftApp, key| {+ let modifiers = Modifiers::NONE;+ let raw = egui::RawInput {+ events: vec![egui::Event::ModifiersChanged(modifiers), egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }],+ ..Default::default()+ };+ ctx.begin_pass(raw);+ crate::shortcuts::handle(app, &ctx);+ ctx.end_pass().textures_delta.clear();+ };+ click(&mut app, 120.0, 30.0);+ press(&mut app, Key::Delete);+ assert_eq!(guides(&app), (vec![50.0], vec![]));+ assert_eq!(selected(&app), None);+ click(&mut app, 50.0, 70.0);+ press(&mut app, Key::Backspace);+ assert_eq!(guides(&app), (vec![], vec![]));+ let st = app.session.active().unwrap();+ assert_eq!(st.history.undo_label(), Some("Delete Guide"), "Edit › Clear didn't run");+ assert!(st.doc.selection.is_some());+ // One undoable step per guide.+ app.session.undo();+ assert_eq!(guides(&app), (vec![50.0], vec![]));+}++fn harness(app: PhotocraftApp) -> Harness<'static, PhotocraftApp> {+ let mut h = Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(1.0 / 60.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;+ }+ egui::CentralPanel::default().show(ui, |ui| crate::canvas::document_area(app, ui));+ crate::canvas_tool_menu::show(app, &ctx);+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::default());+ h.run_steps(4);+ h+}++fn right_click(h: &mut Harness<'static, PhotocraftApp>, p: Pos2) {+ h.event(egui::Event::PointerMoved(p));+ h.run_steps(1);+ h.event(egui::Event::PointerButton { pos: p, button: PointerButton::Secondary, pressed: true, modifiers: Modifiers::NONE });+ h.run_steps(1);+ h.event(egui::Event::PointerButton { pos: p, button: PointerButton::Secondary, pressed: false, modifiers: Modifiers::NONE });+ h.run_steps(2);+}++/// The vertical guide through the middle of the document, on screen: the view centres the image.+fn guide_on_screen(h: &Harness<'static, PhotocraftApp>) -> Pos2 {+ h.state().last_canvas_rect.center() + vec2(0.0, 20.0)+}++fn centred_guide_app() -> PhotocraftApp {+ let mut app = app();+ app.run("view.clearGuides", json!({})).unwrap();+ app.run("view.newGuide", json!({"orientation": "vertical", "position": 100})).unwrap();+ app+}++#[test]+fn right_click_on_a_guide_selects_it_and_opens_photoshops_guide_menu() {+ let mut h = harness(centred_guide_app());+ let at = guide_on_screen(&h);+ right_click(&mut h, at);+ let menu = h.state().ui.canvas_tool_menu.clone().expect("the guide menu");+ assert!(menu.guide);+ assert_eq!(selected(h.state()), Some((true, 0)));+ let labels: Vec<Option<&str>> = crate::canvas_tool_menu::rows(&menu).iter().map(|r| r.map(|(label, _)| label)).collect();+ assert_eq!(+ labels,+ [+ Some("Edit Selected Guides"),+ None,+ Some("Lock Guides"),+ Some("Clear Guides"),+ Some("Clear Canvas Guides"),+ Some("Clear Selected Guides"),+ Some("Clear Selected Artboard Guides"),+ ]+ );+ let app = h.state();+ for id in [GUIDE_EDIT, GUIDE_CLEAR, "view.lockGuides", "view.clearGuides", "view.clearCanvasGuides"] {+ assert!(crate::canvas_tool_menu::available(app, &menu, id), "{id}");+ }+ assert!(!crate::canvas_tool_menu::available(app, &menu, "view.clearSelectedArtboardGuides"), "no artboard");+ assert!(!crate::canvas_tool_menu::available(app, &menu, "edit.freeTransform"), "not a guide row");+ // Off a guide, the Move tool's right-click is still the layer picker's.+ h.key_press(Key::Escape);+ h.run_steps(2);+ let off = h.state().last_canvas_rect.center() + vec2(-60.0, 20.0);+ right_click(&mut h, off);+ assert!(h.state().ui.canvas_tool_menu.is_none());+}++#[test]+fn guide_menu_rows_clear_the_selected_guide_and_lock_guides() {+ let mut h = harness(centred_guide_app());+ h.state_mut().run("view.newGuide", json!({"orientation": "vertical", "position": 20})).unwrap();+ let at = guide_on_screen(&h);+ right_click(&mut h, at);+ let ctx = h.ctx.clone();+ crate::canvas_tool_menu::choose(h.state_mut(), &ctx, GUIDE_CLEAR);+ assert_eq!(guides(h.state()).0, vec![20.0], "only the right-clicked guide goes");+ h.state_mut().run("view.newGuide", json!({"orientation": "vertical", "position": 100})).unwrap();+ h.run_steps(2);+ let at = guide_on_screen(&h);+ right_click(&mut h, at);+ crate::canvas_tool_menu::choose(h.state_mut(), &ctx, "view.lockGuides");+ assert!(h.state().ui.extras.lock_guides);+ assert_eq!(selected(h.state()), None, "locked guides aren't selected");+}++#[test]+fn edit_selected_guides_opens_new_guide_on_the_guide_and_applies_the_edit() {+ let mut app = app();+ app.run("prefs.set", json!({"path": "unitsAndRulers.rulers", "value": "percent"})).unwrap();+ click(&mut app, 120.0, 30.0);+ let id = crate::new_guide_ui::open_edit(&mut app).unwrap();+ let f = app.ui.dialogs.iter().find(|d| d.id == id).unwrap().fields.clone();+ assert_eq!((f["orientation"].as_str(), f["position"].as_str(), f["color"].as_str()), (Some("horizontal"), Some("30 %"), Some("magenta")));+ assert_eq!(f["__label"], "Edit Selected Guides");+ // Turn it vertical at 30 % of the width; the colour isn't touched, so it keeps its own.+ let mut edited = f.clone();+ edited.insert("orientation".into(), json!("vertical"));+ edited.insert("position".into(), json!("30"));+ app.ui.dialogs.retain(|d| d.id != id);+ crate::new_guide_ui::confirm(&mut app, &edited).unwrap();+ assert_eq!(guides(&app), (vec![50.0, 60.0], vec![]));+ let g = &app.session.active().unwrap().doc.guides;+ assert_eq!((g.color(true, 60.0), g.color(false, 30.0)), (Some([0xff, 0x00, 0xff]), None));+ assert_eq!(selected(&app), Some((true, 1)), "the edited guide stays selected");+}++#[test]+fn editing_an_uncoloured_guide_keeps_the_preference_colour_unless_one_is_chosen() {+ let mut app = app();+ click(&mut app, 50.0, 70.0);+ let id = crate::new_guide_ui::open_edit(&mut app).unwrap();+ let f = app.ui.dialogs.iter().find(|d| d.id == id).unwrap().fields.clone();+ // The default preference colour is Cyan's, so a guide dragged from a ruler shows as Cyan.+ assert_eq!(f["color"].as_str(), Some("cyan"));+ let params = crate::new_guide_ui::params(&app, &f);+ assert!(params.get("color").is_none(), "{params}");+ let mut yellow = f.clone();+ yellow.insert("color".into(), json!("yellow"));+ assert_eq!(crate::new_guide_ui::params(&app, &yellow)["color"], "yellow");+ // A refused position keeps the dialog open with the message and the guide untouched.+ let mut bad = f.clone();+ bad.insert("position".into(), json!("far"));+ app.ui.dialogs.retain(|d| d.id != id);+ assert!(crate::new_guide_ui::confirm(&mut app, &bad).is_err());+ assert_eq!(guides(&app).0, vec![50.0]);+ assert!(app.ui.dialogs.last().is_some_and(|d| d.fields.contains_key("__error")));+ // A preference colour that isn't a named one shows as Custom….+ app.ui.dialogs.clear();+ app.run("prefs.set", json!({"path": "guidesGridAndSlices.guideColor", "value": "#123456"})).unwrap();+ let id = crate::new_guide_ui::open_edit(&mut app).unwrap();+ let f = &app.ui.dialogs.iter().find(|d| d.id == id).unwrap().fields;+ assert_eq!((f["color"].as_str(), f["customColor"].as_str()), (Some("custom"), Some("#123456")));+}++#[test]+fn edit_selected_guides_needs_a_selected_guide() {+ let mut app = app();+ assert!(crate::new_guide_ui::open_edit(&mut app).is_err());+ assert!(app.ui.dialogs.is_empty());+}++/// ⌥-click turns a guide through the point clicked, keeping its colour, as one undoable step, and+/// leaves it selected; a locked guide can't be turned.+#[test]+fn alt_click_turns_a_guide_through_the_point_clicked() {+ let mut app = app();+ let alt = Modifiers::ALT;+ tool_event(&mut app, ToolEvent::Down { x: 120.0, y: 30.0, pressure: 1.0 }, alt);+ tool_event(&mut app, ToolEvent::Up { x: 120.0, y: 30.0 }, alt);+ assert_eq!(guides(&app), (vec![50.0, 120.0], vec![]), "the magenta horizontal guide is now vertical at x = 120");+ let g = &app.session.active().unwrap().doc.guides;+ assert_eq!(g.color(true, 120.0), Some([0xff, 0x00, 0xff]));+ assert_eq!(selected(&app), Some((true, 1)));+ assert_eq!(app.session.active().unwrap().history.undo_label(), Some("Edit Guide"));+ app.session.undo();+ assert_eq!(guides(&app), (vec![50.0], vec![30.0]));+ app.ui.extras.lock_guides = true;+ tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 70.0, pressure: 1.0 }, alt);+ tool_event(&mut app, ToolEvent::Up { x: 50.0, y: 70.0 }, alt);+ assert_eq!(guides(&app), (vec![50.0], vec![30.0]), "locked guides stay put");+}++/// Double-clicking a guide opens Preferences › Guides, Grid & Slices, as in Photoshop.+#[test]+fn double_click_on_a_guide_opens_the_guide_preferences() {+ let mut h = harness(centred_guide_app());+ let at = guide_on_screen(&h);+ h.hover_at(at);+ for _ in 0..40 {+ h.step();+ }+ for _ in 0..2 {+ h.event(egui::Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });+ h.step();+ h.event(egui::Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });+ h.step();+ }+ h.run_steps(3);+ let dialog = h.state().ui.dialogs.last().map(|d| serde_json::to_string(&d.fields).unwrap_or_default()).unwrap_or_default();+ assert!(dialog.contains("guidesGridAndSlices"), "{dialog}");+ assert_eq!(guides(h.state()).0, vec![100.0], "the guide didn't move");+}diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex b6ad351a0..8c98e2a05 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -3775,3 +3775,7 @@ navigator Zoom ZvětšeníChisel Hard Tvrdé tesáníChisel Soft Měkké tesáníOpen color-less EXR as ACEScg Otevřít EXR bez údaje o barevném prostoru jako ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Upravit vybraná vodítka+ Clear Selected Guides Vymazat vybraná vodítkadiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex bf86ec281..7ac806741 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -3166,3 +3166,7 @@ curves Smooth GlättenChisel Hard Meißeln hartChisel Soft Meißeln weichOpen color-less EXR as ACEScg Farbangabenloses EXR als ACEScg öffnen++# View › Guides › right-click a guide+ Edit Selected Guides Ausgewählte Hilfslinien bearbeiten+ Clear Selected Guides Ausgewählte Hilfslinien löschendiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex e503ef905..af9640298 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -3865,3 +3865,7 @@ curves Smooth ΕξομάλυνσηChisel Hard Σκληρή σμίλευσηChisel Soft Μαλακή σμίλευσηOpen color-less EXR as ACEScg Άνοιγμα EXR χωρίς χρωματική δήλωση ως ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Επεξεργασία επιλεγμένων οδηγών+ Clear Selected Guides Απαλοιφή επιλεγμένων οδηγώνdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 87b242cfc..0d4df6cc1 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -2853,3 +2853,7 @@ curves Smooth SuavizarChisel Hard Cincelar duroChisel Soft Cincelar suaveOpen color-less EXR as ACEScg Abrir EXR sin espacio de color como ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Editar guías seleccionadas+ Clear Selected Guides Borrar guías seleccionadasdiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex c3980316f..a2a9190d1 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -3170,3 +3170,7 @@ curves Smooth LisserChisel Hard Ciselage durChisel Soft Ciselage douxOpen color-less EXR as ACEScg Ouvrir les EXR sans espace colorimétrique en ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Modifier les repères sélectionnés+ Clear Selected Guides Effacer les repères sélectionnésdiff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsvindex 9a4d273bb..7387f6d7c 100644--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@ -4086,3 +4086,7 @@ cameraRaw Yellow SárgaChisel Hard Kemény vésésChisel Soft Lágy vésésOpen color-less EXR as ACEScg Színinformáció nélküli EXR megnyitása ACEScg-ként++# View › Guides › right-click a guide+ Edit Selected Guides Kijelölt segédvonalak szerkesztése+ Clear Selected Guides Kijelölt segédvonalak törlésediff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex e50bb15c1..50bbd522a 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -3157,3 +3157,7 @@ curves Smooth HaluskanChisel Hard Pahat KerasChisel Soft Pahat LembutOpen color-less EXR as ACEScg Buka EXR tanpa informasi warna sebagai ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Edit Panduan Terpilih+ Clear Selected Guides Hapus Panduan Terpilihdiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex e9b69e09d..baf638b3d 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -4289,3 +4289,6 @@ layerLabel Red Rossolayers Fill Riempimentolayers Fill: Riempimento:shape Appearance Aspetto+# View › Guides › right-click a guide+ Edit Selected Guides Modifica guide selezionate+ Clear Selected Guides Cancella guide selezionatediff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex e96160c1b..8ebbd44c4 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -3844,3 +3844,6 @@ curves Smooth スムーズChisel Hard チゼルハードChisel Soft チゼルソフトOpen color-less EXR as ACEScg 色空間のないEXRをACEScgとして開く+# View › Guides › right-click a guide+ Edit Selected Guides 選択したガイドを編集+ Clear Selected Guides 選択したガイドを消去diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex f206e328e..a05091a5c 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -3342,3 +3342,7 @@ curves Smooth 매끄럽게Chisel Hard 단단하게 조각Chisel Soft 부드럽게 조각Open color-less EXR as ACEScg 색 공간 정보 없는 EXR을 ACEScg로 열기++# View › Guides › right-click a guide+ Edit Selected Guides 선택한 안내선 편집+ Clear Selected Guides 선택한 안내선 지우기diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex f2b79e5ba..d78ceac79 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -3927,3 +3927,7 @@ curves Smooth Vloeiend makenChisel Hard Beitel hardChisel Soft Beitel zachtOpen color-less EXR as ACEScg EXR zonder kleurruimte als ACEScg openen++# View › Guides › right-click a guide+ Edit Selected Guides Geselecteerde hulplijnen bewerken+ Clear Selected Guides Geselecteerde hulplijnen wissendiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 89195e5ca..1c01293a4 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -3765,3 +3765,7 @@ curves Smooth WygładźChisel Hard Dłuto twardeChisel Soft Dłuto miękkieOpen color-less EXR as ACEScg Otwieraj EXR bez profilu koloru jako ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Edytuj zaznaczone prowadnice+ Clear Selected Guides Usuń zaznaczone prowadnicediff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 834211a01..fadb6a4e0 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -3957,3 +3957,7 @@ layerLabel No Color Sem corChisel Hard Cinzel duroChisel Soft Cinzel suaveOpen color-less EXR as ACEScg Abrir EXR sem espaço de cor como ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Editar guias selecionadas+ Clear Selected Guides Limpar guias selecionadasdiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex f67111495..a465ecd14 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -3135,3 +3135,7 @@ curves Smooth СгладитьChisel Hard Жесткая огранкаChisel Soft Мягкая огранкаOpen color-less EXR as ACEScg Открывать EXR без цветового профиля как ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Изменить выбранные направляющие+ Clear Selected Guides Удалить выбранные направляющиеdiff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsvindex 1c54d3a1a..96d788d59 100644--- a/crates/ui-egui/src/i18n/sr.tsv+++ b/crates/ui-egui/src/i18n/sr.tsv@@ -4240,3 +4240,7 @@ shape Appearance IzgledChisel Soft Meko klesanjeOpen color-less EXR as ACEScg Otvori EXR bez podatka o bojama kao ACEScgShow home recent files Prikaži nedavne datoteke na početnom ekranu++# View › Guides › right-click a guide+ Edit Selected Guides Uredi izabrane vodilje+ Clear Selected Guides Ukloni izabrane vodiljediff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsvindex a8f8ab80b..4dd69a2ad 100644--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@ -3897,3 +3897,7 @@ cameraData Lens LensChisel Hard Sert KeskiChisel Soft Yumuşak KeskiOpen color-less EXR as ACEScg Renk bilgisi olmayan EXR'yi ACEScg olarak aç++# View › Guides › right-click a guide+ Edit Selected Guides Seçili Kılavuzları Düzenle+ Clear Selected Guides Seçili Kılavuzları Temizlediff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex f414ac49c..8cbf0fef2 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -3866,3 +3866,7 @@ curves Smooth ЗгладитиChisel Hard Жорстке різьбленняChisel Soft М'яке різьбленняOpen color-less EXR as ACEScg Відкривати EXR без колірного профілю як ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Редагувати вибрані напрямні+ Clear Selected Guides Очистити вибрані напрямніdiff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsvindex 3026906f6..0b10fe048 100644--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@ -3653,3 +3653,7 @@ curves Smooth Làm mượtChisel Hard Đục cứngChisel Soft Đục mềmOpen color-less EXR as ACEScg Mở EXR không khai báo màu sắc dưới dạng ACEScg++# View › Guides › right-click a guide+ Edit Selected Guides Sửa đường căn đã chọn+ Clear Selected Guides Xóa đường căn đã chọndiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex 81ac081c1..4ab896e34 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -2778,3 +2778,7 @@ curves Smooth 平滑Chisel Hard 雕刻清晰Chisel Soft 雕刻柔和Open color-less EXR as ACEScg 将无色彩空间信息的 EXR 以 ACEScg 打开++# View › Guides › right-click a guide+ Edit Selected Guides 编辑所选参考线+ Clear Selected Guides 清除所选参考线diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex d729780b2..7bd773c25 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -2763,3 +2763,7 @@ curves Smooth 平滑Chisel Hard 雕刻清晰Chisel Soft 雕刻柔和Open color-less EXR as ACEScg 將無色彩空間資訊的 EXR 以 ACEScg 開啟++# View › Guides › right-click a guide+ Edit Selected Guides 編輯所選參考線+ Clear Selected Guides 清除所選參考線diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 58056ecb2..10b31f468 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -101,6 +101,7 @@ pub mod gpu_canvas;pub mod gpu_status;pub mod gradient_ui;pub mod guide_layout_ui;+pub mod guide_select;pub mod hold_keys;pub mod i18n;mod icon_data;diff --git a/crates/ui-egui/src/move_hover.rs b/crates/ui-egui/src/move_hover.rsindex d94015fbd..c3d07f313 100644--- a/crates/ui-egui/src/move_hover.rs+++ b/crates/ui-egui/src/move_hover.rs@@ -185,7 +185,7 @@ mod tests {assert_eq!(active_outline(&mut app, None, false, false), Some(a));// When a drag or transform is in progress, no outline:- app.guide_drag = Some(crate::rulers::GuideDrag { vertical: false, index: None, pos: 10.0 });+ app.guide_drag = Some(crate::rulers::GuideDrag { vertical: false, index: None, pos: 10.0, press: 10.0 });assert_eq!(active_outline(&mut app, None, false, false), None);app.guide_drag = None;diff --git a/crates/ui-egui/src/new_guide_ui.rs b/crates/ui-egui/src/new_guide_ui.rsindex 8b8a20928..07a8aef7b 100644--- a/crates/ui-egui/src/new_guide_ui.rs+++ b/crates/ui-egui/src/new_guide_ui.rs@@ -13,6 +13,11 @@//! Color lists Photoshop's guide colours (Cyan by default) and Custom…, whose swatch opens the//! Color Picker. The guide stores the chosen colour itself, so changing the preference guide//! colour later doesn't recolour it.+//!+//! Edit Selected Guides (the guide menu, `guide_select`) opens the same dialog on the selected+//! guide: its orientation, its position in the ruler unit and its colour. OK runs `view.editGuide`,+//! sending the colour only when it was changed, so a guide that uses the preference colour keeps+//! doing so.use photocraft_engine::edit_cmds::GUIDE_COLORS;use photocraft_engine::prefs::Unit;@@ -23,6 +28,11 @@ use crate::state::DialogKind;const MARK: &str = "__newGuide";const COMMAND: &str = "view.newGuide";+const EDIT_COMMAND: &str = "view.editGuide";+/// In an Edit Selected Guides dialog: the guide being edited, as `{"orientation", "index"}`, and+/// the colour it opened with.+const EDIT: &str = "__edit";+const INITIAL_COLOR: &str = "__initialColor";const CUSTOM: &str = "custom";/// New Guide's colour when nothing was remembered, as in Photoshop.const DEFAULT_COLOR: &str = "cyan";@@ -100,6 +110,44 @@ pub fn open(app: &mut PhotocraftApp) -> u64 {app.ui.open_dialog(DialogKind::Command, f)}+/// The list entry (and Custom… colour) showing `rgb`: a named colour when it is one, else Custom….+fn color_choice(rgb: [u8; 3]) -> (String, String) {+ let hex = format!("#{:02x}{:02x}{:02x}", rgb[0], rgb[1], rgb[2]);+ match GUIDE_COLORS.iter().find(|(.., c)| *c == rgb) {+ Some((name, ..)) => (name.to_string(), hex),+ None => (CUSTOM.to_string(), hex),+ }+}++/// Edit Selected Guides: the dialog on the selected guide, with its orientation, its position in+/// the current ruler unit and its colour (its own, or the preference colour it is drawn in).+pub fn open_edit(app: &mut PhotocraftApp) -> Result<u64, String> {+ let (vertical, index) = crate::guide_select::selected(app).ok_or_else(|| "No guide is selected".to_string())?;+ let (px, own) = app+ .session+ .active()+ .and_then(|st| {+ let g = &st.doc.guides;+ let p = *if vertical { &g.vertical } else { &g.horizontal }.get(index)?;+ Some((p, g.color(vertical, p)))+ })+ .ok_or_else(|| "No guide is selected".to_string())?;+ let pref = photocraft_engine::prefs::parse_hex(&app.session.prefs().guides_grid_and_slices.guide_color).unwrap_or([0x4a, 0xff, 0xff]);+ let (color, custom) = color_choice(own.unwrap_or(pref));+ let orientation = if vertical { "vertical" } else { "horizontal" };+ let mut f = Map::new();+ f.insert(MARK.into(), json!(true));+ f.insert("__command".into(), json!(EDIT_COMMAND));+ f.insert("__label".into(), json!("Edit Selected Guides"));+ f.insert(EDIT.into(), json!({"orientation": orientation, "index": index}));+ f.insert("orientation".into(), json!(orientation));+ f.insert("position".into(), json!(in_ruler_unit(app, px, vertical)));+ f.insert(INITIAL_COLOR.into(), json!(if color == CUSTOM { custom.clone() } else { color.clone() }));+ f.insert("color".into(), json!(color));+ f.insert("customColor".into(), json!(custom));+ Ok(app.ui.open_dialog(DialogKind::Command, f))+}+pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {let mut orientation = f.get("orientation").and_then(Value::as_str).unwrap_or("horizontal").to_string();let mut position = f.get("position").and_then(Value::as_str).unwrap_or_default().to_string();@@ -152,11 +200,23 @@ pub fn params(app: &PhotocraftApp, f: &Map<String, Value>) -> Value {};let color = f.get("color").and_then(Value::as_str).filter(|c| is_color_name(c)).unwrap_or(DEFAULT_COLOR);let color = if color == CUSTOM { custom_color(f) } else { color.to_string() };- json!({"orientation": orientation, "position": position, "color": color})+ match f.get(EDIT) {+ Some(edit) => {+ let mut p = json!({"orientation": edit["orientation"], "index": edit["index"], "newOrientation": orientation, "position": position});+ if f.get(INITIAL_COLOR).and_then(Value::as_str) != Some(color.as_str()) {+ p["color"] = json!(color);+ }+ p+ }+ None => json!({"orientation": orientation, "position": position, "color": color}),+ }}pub fn confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Value, String> {let params = params(app, f);+ if f.contains_key(EDIT) {+ return confirm_edit(app, f, ¶ms);+ }match app.run(COMMAND, params.clone()) {Ok(result) => {// Remember where the guide landed (so it reopens in whatever the ruler unit is then),@@ -182,5 +242,30 @@ pub fn confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Value,}}+/// Edit Selected Guides' OK: the edited guide stays selected (at the end of the other list if it+/// turned). A refused edit reopens the dialog, as New Guide does.+fn confirm_edit(app: &mut PhotocraftApp, f: &Map<String, Value>, params: &Value) -> Result<Value, String> {+ match app.run(EDIT_COMMAND, params.clone()) {+ Ok(result) => {+ let (from, to) = (params["orientation"] == "vertical", params["newOrientation"] == "vertical");+ let index = if from == to {+ params["index"].as_u64().and_then(|i| usize::try_from(i).ok())+ } else {+ app.session.active().map(|st| if to { st.doc.guides.vertical.len() } else { st.doc.guides.horizontal.len() }.saturating_sub(1))+ };+ if let Some(i) = index {+ crate::guide_select::select(app, to, i);+ }+ Ok(result)+ }+ Err(e) => {+ let mut again = f.clone();+ again.insert("__error".into(), json!(e));+ app.ui.open_dialog(DialogKind::Command, again);+ Err(e)+ }+ }+}+#[cfg(test)]mod tests;diff --git a/crates/ui-egui/src/rulers.rs b/crates/ui-egui/src/rulers.rsindex bb1b5b9d5..7f9086006 100644--- a/crates/ui-egui/src/rulers.rs+++ b/crates/ui-egui/src/rulers.rs@@ -93,6 +93,17 @@ pub struct GuideDrag {pub vertical: bool,pub index: Option<usize>,pub pos: f64,+ /// Where the pointer went down, on the guide's axis: released there, an existing guide is+ /// clicked (selected), not moved.+ pub press: f64,+}++impl GuideDrag {+ /// An existing guide taken at document point `p`.+ pub fn existing(vertical: bool, index: usize, p: [f64; 2]) -> Self {+ let at = if vertical { p[0] } else { p[1] };+ Self { vertical, index: Some(index), pos: at, press: at }+ }}/// Canvas area left after the rulers.@@ -178,8 +189,13 @@ pub fn draw_guides(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform,styled_line(painter, a, b, Stroke::new(1.0, color), style);};// A guide given a colour in New Guide keeps it; the rest use the preference colour (or, while- // New Guide Layout previews, the colour it will set).- let own = |vertical: bool, p: f64| guides.color(vertical, p).map_or(guide, |[r, g, b]| Color32::from_rgb(r, g, b));+ // New Guide Layout previews, the colour it will set). The selected guide is Photoshop's blue.+ let own = |vertical: bool, p: f64| {+ if crate::guide_select::is_selected(app, vertical, p) {+ return crate::guide_select::SELECTED_COLOR;+ }+ guides.color(vertical, p).map_or(guide, |[r, g, b]| Color32::from_rgb(r, g, b))+ };if app.ui.extras.guides || preview.is_some() {for (vertical, list) in [(true, &guides.vertical), (false, &guides.horizontal)] {for (i, p) in list.iter().enumerate() {@@ -219,16 +235,26 @@ pub fn guide_at(app: &PhotocraftApp, x: f64, y: f64) -> Option<(bool, usize)> {None}-/// Finish a guide drag: create, move, or delete (dropped outside the canvas).+/// Finish a guide drag: create, move, or delete (dropped outside the canvas). An existing guide+/// released where it was pressed is a click: it's selected and stays put, as in Photoshop; a+/// moved one stays selected.pub fn finish_drag(app: &mut PhotocraftApp, d: GuideDrag) {let Some(size) = app.session.active().map(|s| s.doc.size) else { return };+ if let Some(i) = d.index+ && (d.pos - d.press).abs() * f64::from(app.point_zoom().max(0.01)) < 0.5+ {+ crate::guide_select::select(app, d.vertical, i);+ return;+ }let extent = if d.vertical { size.width } else { size.height } as f64;let orientation = if d.vertical { "vertical" } else { "horizontal" };let inside = d.pos >= 0.0 && d.pos <= extent;let pos = (d.pos * 1000.0).round() / 1000.0;let _ = match (d.index, inside) {(None, true) => app.run("view.newGuide", json!({"orientation": orientation, "position": pos})),- (Some(i), true) => app.run("view.moveGuide", json!({"orientation": orientation, "index": i, "position": pos})),+ (Some(i), true) => app+ .run("view.moveGuide", json!({"orientation": orientation, "index": i, "position": pos}))+ .inspect(|_| crate::guide_select::select(app, d.vertical, i)),(Some(i), false) => app.run("view.deleteGuide", json!({"orientation": orientation, "index": i})),(None, false) => Ok(serde_json::Value::Null),};@@ -408,7 +434,7 @@ pub fn draw_rulers(app: &mut PhotocraftApp, ui: &mut egui::Ui, full: Rect, xf: &let d = xf.to_doc(pos);let along = if vertical { d[0] } else { d[1] };let pos = if ui.input(|i| i.modifiers.shift) { snap_to_tick(app, xf, vertical, along) } else { crate::snap_ui::snap_guide(app, vertical, along) };- app.guide_drag = Some(GuideDrag { vertical, index: None, pos });+ app.guide_drag = Some(GuideDrag { vertical, index: None, pos, press: pos });}if resp.drag_stopped()&& let Some(d) = app.guide_drag.take()@@ -763,14 +789,14 @@ mod tests {let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());app.session.execute("file.new", json!({"width": 200, "height": 100})).unwrap();app.sync_views();- finish_drag(&mut app, GuideDrag { vertical: true, index: None, pos: 50.0 });- finish_drag(&mut app, GuideDrag { vertical: false, index: None, pos: 500.0 }); // off canvas: ignored+ finish_drag(&mut app, GuideDrag { vertical: true, index: None, pos: 50.0, press: 50.0 });+ finish_drag(&mut app, GuideDrag { vertical: false, index: None, pos: 500.0, press: 500.0 }); // off canvas: ignoredassert_eq!(app.session.active().unwrap().doc.guides.vertical, vec![50.0]);assert!(app.session.active().unwrap().doc.guides.horizontal.is_empty());assert_eq!(guide_at(&app, 51.0, 10.0), Some((true, 0)));- finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: 120.0 });+ finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: 120.0, press: 50.0 });assert_eq!(app.session.active().unwrap().doc.guides.vertical, vec![120.0]);- finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: -30.0 });+ finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: -30.0, press: 120.0 });assert!(app.session.active().unwrap().doc.guides.vertical.is_empty());app.ui.extras.lock_guides = true;assert_eq!(guide_at(&app, 0.0, 0.0), None);diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rsindex f709b057f..a2f3f17c1 100644--- a/crates/ui-egui/src/shortcuts.rs+++ b/crates/ui-egui/src/shortcuts.rs@@ -500,6 +500,10 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) {return;}}+ // A selected guide: ⌫/Delete removes it (`guide_select`), never Edit › Clear's pixels.+ if crate::guide_select::keys(app, ctx) {+ return;+ }// Space+F (⇧Space+F backwards) cycles the pasteboard colour, as in Photoshop: F while the// Hand key is held, before F's own Cycle Screen Mode.if !matches!(focus, Focus::Text) && app.ui.text_edit.is_none() && crate::hold_keys::reposition_held(app, ctx) {diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex 693b3c75c..aeefb3ecb 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -1134,6 +1134,9 @@ pub struct UiState {/// Selection-tool context menu opened by a plain canvas right-click.#[serde(default)]pub canvas_tool_menu: Option<crate::canvas_tool_menu::CanvasToolMenu>,+ /// The guide a Move-tool click selected (`guide_select`): drawn blue, Delete removes it.+ #[serde(default)]+ pub selected_guide: Option<crate::guide_select::SelectedGuide>,/// The brush is a per-tool option (the Brush, the Eraser and every retouching tool each keep/// their own size, hardness, tip and dynamics, as in Photoshop): the tool whose brush the/// session brush holds, and the other tools' saved brushes.@@ -1316,6 +1319,7 @@ impl Default for UiState {brush_picker_size: None,layer_menu: None,canvas_tool_menu: None,+ selected_guide: None,brush_tool: Tool::Brush,tool_brushes: Vec::new(),clone_source: None,diff --git a/crates/ui-egui/src/transform_type_tests.rs b/crates/ui-egui/src/transform_type_tests.rsindex dcbbb70b3..0ed51de66 100644--- a/crates/ui-egui/src/transform_type_tests.rs+++ b/crates/ui-egui/src/transform_type_tests.rs@@ -52,6 +52,7 @@ fn type_layers_offer_free_transform_but_not_distort_or_perspective() {pasteboard: false,anchor: None,text: false,+ guide: false,spelling: None,};assert!(crate::canvas_tool_menu::available(&app, &menu, "edit.freeTransform"));diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 686dc9040..7fbe8932c 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 (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 (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 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,@@ -192,6 +192,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme| Layer and selection keys: ⌘, toggles visibility, ⌘\ targets the mask, / locks transparency, ⌘⌥2 loads luminosity, ⌘⌥⌫ fills from history, Tab / ⇧Tab rename the next layer, ⌥-click a thumbnail fits the layer | done (2026-10-11) | || Tool keys: ← / → turn the brush tip (1°, ⇧ 15°), ⇧-click with Type starts new text over old, Space+F / ⇧Space+F cycle the pasteboard colour | done (2026-10-11) | || Type formatting keys while editing text | done: ⇧⌘K, U, B, I and / toggle All Caps, Underline, Faux Bold, Faux Italic, Strikethrough (off when every selected character has it, else on); ⌥↑/↓ leading ∓2 pt, ⇧⌥↑/↓ baseline shift ±2 pt (10 with ⌘); ⌥←/→ tracking ±20 over a selection (100 with ⌘; a collapsed caret still kerns); ⌥⇧⌘H toggles Hyphenate for the touched paragraphs. One `type.setStyle` step per press (new `leadingBy`/`baselineShiftBy`/`trackingBy`; auto leading starts from its laid-out value); the global ⇧⌘K/U/B/I never fire while typing. Differs: a collapsed caret in non-empty text changes nothing, since the model can't hold a pending style for the next characters typed (empty text takes it as its typing style) (`type_tool.rs`, `input_tests.rs` `type_tool_format_keys_*`) | |+| Guides: click selects, Delete deletes, right-click menu, ⌥-click turns a guide, double-click opens Guides, Grid & Slices | done (2026-10-12) | |## Panels and workspace@@ -245,6 +246,7 @@ Paragraph; the rest open as in-app floating windows.| 2026-10-12 | minor | Free Transform options bar: H and V skew fields; a sheared box reads as skew instead of a taller H || 2026-10-12 | minor | Crop tool Fill › Content-Aware Fill done (#3823); Delete Cropped Pixels off split into its own row, still partial || 2026-10-12 | minor | Layers panel: Clip Thumbnails to Layer Bounds frames each layer's pixels instead of the canvas (#4281) |+| 2026-10-12 | minor | Guides: ⌥-click turns a guide through the click; double-click opens Preferences › Guides, Grid & Slices || 2026-10-13 | minor | Smart filter rows can be dragged up or down their stack to reorder the filters || 2026-10-13 | minor | On-canvas corner radius widgets on live rectangles (TOOL-214-12) || 2026-10-13 | minor | Curvature Pen edits the active path: drag anchors, click a segment to add, double-click smooth/corner, cursor badges |