From 097848ddb59cec2e0571e6dca3f40e30eaa8dee2 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 14 Oct 2026 15:50:36 -0400 Subject: [PATCH] =?UTF-8?q?Move=20tool:=20=CE=94X/=CE=94Y=20readout=20besi?= =?UTF-8?q?de=20the=20pointer=20while=20dragging=20(#5727)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only Free Transform drew a readout of how far the layer moved (its Hit::Inside offset), so a Move-tool drag inside the transform controls, or without them, showed nothing. Photoshop shows ΔX/ΔY for a Move drag. The drag preview now draws the offset the release will commit (move_ui::drag_offset, whole pixels), for a layer drag and a drag of selected pixels, once the pointer has moved. It goes through draw_value_readout, so Preferences > Tools > Show Transformation Values hides it like the other readouts. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas.rs | 5 +++++ crates/ui-egui/src/move_ui.rs | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 7a9592b692..498e0528f7 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -4695,6 +4695,11 @@ fn draw_drag_preview(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &View app.trail = None; return; }; + // The Move tool's ΔX/ΔY beside the pointer, for layers and selected pixels alike (#5727). + if let Some(values) = crate::move_ui::offset_readout(app) { + let at = d.points.last().map_or(d.start, |p| [p[0], p[1]]); + draw_value_readout(app, painter.ctx(), "move-readout", xf.to_screen(at[0] as f32, at[1] as f32), ["ΔX:", "ΔY:"], values); + } // Dragging the selection: its own ants follow the pointer (`selection_shown_offset`). if d.sel_move.is_some() { return; diff --git a/crates/ui-egui/src/move_ui.rs b/crates/ui-egui/src/move_ui.rs index fb49b02474..22c43d41f2 100644 --- a/crates/ui-egui/src/move_ui.rs +++ b/crates/ui-egui/src/move_ui.rs @@ -96,6 +96,15 @@ fn drag_offset(app: &PhotocraftApp) -> Option<(i32, i32)> { Some((dx, dy)) } +/// The ΔX/ΔY values shown beside the pointer while the Move tool drags layers or selected pixels, +/// as in Photoshop (#5727): the whole pixels the release will move them. Free Transform shows its +/// own (`transform_tool::live_readout`). `None` until the pointer moves. +pub(crate) fn offset_readout(app: &PhotocraftApp) -> Option<[String; 2]> { + app.drag.as_ref().filter(|d| d.points.len() > 1)?; + let (dx, dy) = drag_offset(app)?; + Some([dx, dy].map(|v| format!("{v} px"))) +} + /// The document to show while a Move drag is under way on document `idx`: the moving layers at /// the pointer. `None` without a drag (or when the layers can't move: locked, say; the drag then /// shows its arrow and the release reports why). @@ -309,6 +318,33 @@ mod tests { assert_eq!(r, Rect::new(0, 0, 64, 64)); } + /// The Move tool shows how far it has moved the layer, ΔX/ΔY in whole pixels, as Photoshop + /// and Free Transform do (#5727): once the pointer moves, until the release. + #[test] + fn a_move_drag_reads_out_the_offset_it_will_commit() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 64, "height": 64})).unwrap(); + app.sync_views(); + app.session.execute("layer.new.layer", json!({})).unwrap(); + app.session + .edit("paint", |doc, a| { + doc.layer_mut(a.unwrap()).unwrap().surface_mut().unwrap().fill_rect(Rect::new(16, 16, 32, 32), &[1.0, 0.0, 0.0, 1.0]); + Ok(()) + }) + .unwrap(); + app.ui.tool = Tool::Move; + app.ui.extras.snap = false; + app.ui.view.show.smart_guides = false; + let m = egui::Modifiers::NONE; + assert_eq!(super::offset_readout(&app), None, "no drag"); + crate::canvas::tool_event(&mut app, ToolEvent::Down { x: 32.0, y: 32.0, pressure: 1.0 }, m); + assert_eq!(super::offset_readout(&app), None, "pressed, not moved yet"); + crate::canvas::tool_event(&mut app, ToolEvent::Move { x: 42.4, y: 28.8, pressure: 1.0 }, m); + assert_eq!(super::offset_readout(&app), Some(["10 px".to_string(), "-3 px".to_string()])); + crate::canvas::tool_event(&mut app, ToolEvent::Up { x: 42.4, y: 28.8 }, m); + assert_eq!(super::offset_readout(&app), None, "released"); + } + /// A shape reaching past the canvas edge renders cut at the canvas, but its path goes on: a /// drag frame must redraw where the rest of it was, or the cut edge stays behind (#3946). #[test]