PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Crop tool: arrow keys nudge, X swaps orientation, W × H readout (#1958)
David Mannb8fe7dd5ee10
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 0d56cf0a0..7e2e6969c 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -3225,6 +3225,9 @@ fn draw_tool_state(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform,// The frame's angle beside the pointer while it turns (#1792).if let (Some(a), Some(h)) = (crate::crop_ui::turning(app), hover) {draw_readout(painter.ctx(), "crop-angle-readout", h, ["Angle:"], [format!("{a:.1}°")]);+ } else if let (Some([w, h]), Some(at)) = (crate::crop_ui::sizing(app), hover) {+ // Its W × H while it is drawn or resized (#1919), like the marquee's.+ draw_marquee_readout(painter.ctx(), at, marquee_readout([0.0, 0.0, w, h]));}}}diff --git a/crates/ui-egui/src/crop_ui.rs b/crates/ui-egui/src/crop_ui.rsindex 9a7846e3b..cafa27f97 100644--- a/crates/ui-egui/src/crop_ui.rs+++ b/crates/ui-egui/src/crop_ui.rs@@ -10,7 +10,14 @@//! holds;//! - outside the frame (off its handles) the pointer is the rotate cursor and a drag turns the//! frame about its centre, ⇧ in 15° steps, with the angle beside the pointer (#1792). As in-//! Photoshop, a new frame is drawn after the pending one is committed or cancelled.+//! Photoshop, a new frame is drawn after the pending one is committed or cancelled;+//! - while a frame is drawn or resized, its W × H (in px, as ↵ would crop it) shows beside the+//! pointer, like the marquee's readout ([`sizing`]);+//! - with a pending frame and no gesture, the arrow keys nudge it 1 document px (⇧ 10 px) instead+//! of the selection or layer, and X swaps it between portrait and landscape about its centre+//! (keeping its angle, and swapping an options-bar ratio with it) instead of the colours+//! ([`keys`], #1919). These are Photoshop's Classic Mode keys: in its default mode the arrows+//! move the image under the box.//!//! ↵ commits (`image.crop`, see `canvas::commit_crop`, with the turn as its `angle`: the document//! is rotated so the frame is upright, then cropped to it) and Esc cancels. The pending frame lives@@ -406,6 +413,96 @@ pub fn turning(app: &PhotocraftApp) -> Option<f64> {matches!(app.crop.drag, Some(CropDrag::Rotate { .. })).then(|| angle(app))}+/// The size ↵ would crop frame `r` to: its own width and height (before any turn) in whole+/// document px, at least 1; `None` when they aren't finite.+pub fn frame_size(r: [f64; 4]) -> Option<[f64; 2]> {+ let (w, h) = (r[2] - r[0], r[3] - r[1]);+ (w.is_finite() && h.is_finite()).then(|| [w.round().max(1.0), h.round().max(1.0)])+}++/// The frame is being drawn or resized: its W × H, for the readout beside the pointer (as the+/// marquee's, in px).+pub fn sizing(app: &PhotocraftApp) -> Option<[f64; 2]> {+ match app.crop.drag {+ // Until the pointer moves, the frame shown is still the previous one.+ Some(CropDrag::Draw { anchor, cur, .. }) if anchor != cur => {}+ Some(CropDrag::Resize { .. }) => {}+ _ => return None,+ }+ frame_size(app.ui.crop_rect?)+}++/// The Crop tool owns the arrow keys and X: a pending frame and no gesture in progress.+pub fn takes_keys(app: &PhotocraftApp) -> bool {+ app.ui.tool == Tool::Crop && app.crop.drag.is_none() && app.ui.transform.is_none() && app.ui.crop_rect.is_some_and(|r| r.iter().all(|v| v.is_finite()))+}++/// The frame now set by the keys: a real frame (no longer the default), being edited.+fn keyed(app: &mut PhotocraftApp, r: [f64; 4]) {+ if r.iter().all(|v| v.is_finite()) {+ app.ui.crop_rect = Some(r);+ app.crop.default_frame = false;+ app.crop.editing = true;+ }+}++/// Moves the pending frame by (`dx`, `dy`) document px (a turned frame moves on the page, keeping+/// its angle). Returns false when the Crop tool doesn't take the keys ([`takes_keys`]).+pub fn nudge(app: &mut PhotocraftApp, dx: f64, dy: f64) -> bool {+ let Some(r) = app.ui.crop_rect.filter(|_| takes_keys(app)) else { return false };+ if dx.is_finite() && dy.is_finite() {+ keyed(app, [r[0] + dx, r[1] + dy, r[2] + dx, r[3] + dy]);+ }+ true+}++/// Frame `r` with its width and height swapped about its centre.+pub fn swapped(r: [f64; 4]) -> [f64; 4] {+ let c = center(r);+ let (hw, hh) = ((r[2] - r[0]) / 2.0, (r[3] - r[1]) / 2.0);+ [c[0] - hh, c[1] - hw, c[0] + hh, c[1] + hw]+}++/// The options-bar ratio `key` with its sides swapped (what the bar's ⇄ button does), `None` when+/// no ratio is set; "original" becomes the document's size turned on its side.+pub fn swapped_ratio(key: &str, doc_w: f64, doc_h: f64) -> Option<String> {+ let (w, h) = crate::chrome_ui::crop_ratio(key, doc_w, doc_h).filter(|(w, h)| w.is_finite() && h.is_finite() && *w > 0.0 && *h > 0.0)?;+ Some(format!("{}:{}", crate::widgets::fmt_num(h), crate::widgets::fmt_num(w)))+}++/// X: swaps the pending frame between portrait and landscape about its centre, keeping its angle,+/// and swaps the options-bar ratio with it, as in Photoshop. Returns false when the Crop tool+/// doesn't take the keys ([`takes_keys`]), so X swaps the colours as usual.+pub fn swap_orientation(app: &mut PhotocraftApp) -> bool {+ let Some(r) = app.ui.crop_rect.filter(|_| takes_keys(app)) else { return false };+ let size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height)));+ if let Some(k) = swapped_ratio(&app.ui.tool_options.crop_ratio, size.0, size.1) {+ app.ui.tool_options.crop_ratio = k;+ }+ keyed(app, swapped(r));+ true+}++/// Crop tool keys with a pending frame: arrows nudge it 1 px (⇧ 10 px) instead of the selection+/// or layer, and X swaps its orientation instead of the colours. Returns true when a key was used.+pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {+ if !takes_keys(app) {+ return false;+ }+ use egui::Key;+ let arrows = [(Key::ArrowLeft, -1.0, 0.0), (Key::ArrowRight, 1.0, 0.0), (Key::ArrowUp, 0.0, -1.0), (Key::ArrowDown, 0.0, 1.0)];+ for (key, ux, uy) in arrows {+ // ⇧ first: `consume_key` ignores an extra ⇧.+ for mods in [Modifiers::SHIFT, Modifiers::NONE] {+ if ctx.input_mut(|i| i.consume_key(mods, key)) {+ let k = if mods.shift { 10.0 } else { 1.0 };+ return nudge(app, ux * k, uy * k);+ }+ }+ }+ ctx.input_mut(|i| i.consume_key(Modifiers::NONE, Key::X)) && swap_orientation(app)+}+/// Pointer input for the Crop tool. Returns true when the event was its.pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: Modifiers) -> bool {if app.ui.tool != Tool::Crop {@@ -1264,4 +1361,169 @@ mod tests {app.ui.tool = Tool::Brush;assert_eq!(cursor(&app, [60.0, 40.0]), None);}++ /// One key press through the app's keyboard handling (`shortcuts::handle`).+ fn key(app: &mut PhotocraftApp, key: egui::Key, modifiers: Modifiers) {+ let ctx = egui::Context::default();+ let raw = egui::RawInput {+ events: vec![egui::Event::ModifiersChanged(modifiers), egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }],+ ..Default::default()+ };+ let mut out = ctx.run_ui(raw, |ui| crate::shortcuts::handle(app, ui.ctx()));+ out.textures_delta.clear();+ }++ fn layer_offset(app: &PhotocraftApp) -> (i32, i32) {+ let st = app.session.active().unwrap();+ let l = st.doc.layer(st.active_layer.unwrap()).unwrap();+ l.surface().map_or((0, 0), |s| (s.content_bounds().x0, s.content_bounds().y0))+ }++ /// #1919: with a pending frame the arrow keys nudge it 1 px (⇧ 10 px), turned or not, and+ /// never the selection or layer; without one they keep their usual job.+ #[test]+ fn arrow_keys_nudge_the_pending_frame() {+ use egui::Key;+ let mut app = app(SampleType::U8);+ app.run("select.rect", json!({"x": 10, "y": 10, "width": 30, "height": 20})).unwrap();+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ let steps = app.session.active().unwrap().history.past_len();+ key(&mut app, Key::ArrowRight, NONE);+ assert_eq!(app.ui.crop_rect, Some([21.0, 20.0, 101.0, 60.0]));+ key(&mut app, Key::ArrowDown, SHIFT);+ assert_eq!(app.ui.crop_rect, Some([21.0, 30.0, 101.0, 70.0]));+ key(&mut app, Key::ArrowLeft, SHIFT);+ key(&mut app, Key::ArrowUp, NONE);+ assert_eq!(app.ui.crop_rect, Some([11.0, 29.0, 91.0, 69.0]));+ assert!(app.crop.editing && !app.crop.default_frame);+ assert_eq!(app.session.active().unwrap().history.past_len(), steps, "nothing in the document moved");+ assert_eq!(app_selection_bounds(&app), Some((10, 10, 40, 30)));+ assert_eq!(layer_offset(&app), (0, 0));+ // A turned frame moves on the page and keeps its angle and shape.+ app.ui.crop_angle = 30.0;+ let before = corners(app.ui.crop_rect.unwrap(), 30.0);+ key(&mut app, Key::ArrowRight, SHIFT);+ let after = corners(app.ui.crop_rect.unwrap(), angle(&app));+ for (a, b) in before.iter().zip(after) {+ assert!((b[0] - a[0] - 10.0).abs() < 1e-9 && (b[1] - a[1]).abs() < 1e-9);+ }+ assert_eq!(app.ui.crop_angle, 30.0);+ // The untouched default frame becomes a real one.+ app.ui.crop_rect = None;+ app.ui.crop_angle = 0.0;+ app.run("select.deselect", json!({})).unwrap();+ ensure_frame(&mut app);+ assert!(app.crop.default_frame);+ assert!(nudge(&mut app, 1.0, 0.0));+ assert_eq!(app.ui.crop_rect, Some([1.0, 0.0, 201.0, 100.0]));+ assert!(!app.crop.default_frame);+ // No frame: not the Crop tool's key. With a selection tool the arrows nudge the selection.+ app.ui.crop_rect = None;+ assert!(!nudge(&mut app, 1.0, 0.0));+ app.ui.tool = Tool::RectMarquee;+ app.run("select.rect", json!({"x": 10, "y": 10, "width": 30, "height": 20})).unwrap();+ key(&mut app, Key::ArrowRight, NONE);+ assert_eq!(app_selection_bounds(&app), Some((11, 10, 41, 30)));+ // Not mid-gesture, nor with another tool, nor for a non-finite frame or step.+ app.ui.tool = Tool::Crop;+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ app.crop.drag = Some(CropDrag::Move { start: [0.0, 0.0], rect: [20.0, 20.0, 100.0, 60.0] });+ assert!(!nudge(&mut app, 1.0, 0.0));+ app.crop.drag = None;+ assert!(nudge(&mut app, f64::NAN, f64::INFINITY), "the key is the Crop tool's");+ assert_eq!(app.ui.crop_rect, Some([20.0, 20.0, 100.0, 60.0]), "but the frame stays put");+ app.ui.crop_rect = Some([f64::MAX, 0.0, f64::MAX, 1.0]);+ assert!(nudge(&mut app, f64::MAX, 0.0));+ assert_eq!(app.ui.crop_rect, Some([f64::MAX, 0.0, f64::MAX, 1.0]), "an overflow leaves it");+ app.ui.crop_rect = Some([f64::NAN, 0.0, 1.0, 1.0]);+ assert!(!nudge(&mut app, 1.0, 0.0));+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ app.ui.tool = Tool::Brush;+ assert!(!nudge(&mut app, 1.0, 0.0));+ }++ fn app_selection_bounds(app: &PhotocraftApp) -> Option<(i32, i32, i32, i32)> {+ let b = app.session.active()?.doc.selection.as_ref()?.content_bounds();+ Some((b.x0, b.y0, b.x1, b.y1))+ }++ /// #1919: X swaps the pending frame between portrait and landscape about its centre (keeping+ /// its angle and swapping a ratio preset); without a frame X still swaps the colours.+ #[test]+ fn x_swaps_the_frame_orientation_not_the_colours() {+ use egui::Key;+ let mut app = app(SampleType::U16);+ app.run("tools.setColors", json!({"foreground": "#ff0000", "background": "#0000ff"})).unwrap();+ let fg = |app: &PhotocraftApp| app.session.tools.foreground;+ let red = fg(&app);+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ app.ui.crop_angle = 25.0;+ key(&mut app, Key::X, NONE);+ assert_eq!(app.ui.crop_rect, Some([40.0, 0.0, 80.0, 80.0]), "40 x 80 about the centre (60, 40)");+ assert_eq!(app.ui.crop_angle, 25.0);+ assert_eq!(fg(&app), red, "the colours stay");+ key(&mut app, Key::X, NONE);+ assert_eq!(app.ui.crop_rect, Some([20.0, 20.0, 100.0, 60.0]), "and back");+ // A ratio preset swaps with the frame, as the options bar's ⇄ does.+ app.ui.tool_options.crop_ratio = "16:9".into();+ assert!(swap_orientation(&mut app));+ assert_eq!(app.ui.tool_options.crop_ratio, "9:16");+ app.ui.tool_options.crop_ratio = "original".into();+ assert!(swap_orientation(&mut app));+ assert_eq!(app.ui.tool_options.crop_ratio, "100:200", "the document's size on its side");+ app.ui.tool_options.crop_ratio = String::new();+ assert!(swap_orientation(&mut app));+ assert_eq!(app.ui.tool_options.crop_ratio, "", "no ratio stays none");+ assert_eq!(swapped_ratio("0:5", 1.0, 1.0), None);+ assert_eq!(swapped_ratio("nonsense", 1.0, 1.0), None);+ // No frame, or another tool: X is Switch Foreground and Background Colors.+ app.ui.crop_rect = None;+ key(&mut app, Key::X, NONE);+ assert_ne!(fg(&app), red, "swapped");+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ app.ui.tool = Tool::Brush;+ key(&mut app, Key::X, NONE);+ assert_eq!(fg(&app), red, "swapped back");+ assert_eq!(app.ui.crop_rect, Some([20.0, 20.0, 100.0, 60.0]));+ // Huge or broken frames never panic and are never made non-finite.+ app.ui.tool = Tool::Crop;+ app.ui.crop_rect = Some([-f64::MAX, 0.0, f64::MAX, 1.0]);+ assert!(swap_orientation(&mut app));+ assert_eq!(app.ui.crop_rect, Some([-f64::MAX, 0.0, f64::MAX, 1.0]));+ app.ui.crop_rect = Some([f64::NAN, 0.0, 1.0, 1.0]);+ assert!(!swap_orientation(&mut app));+ }++ /// #1919: W × H beside the pointer while the frame is drawn or resized (its own size when+ /// turned), not while it moves or turns or between gestures.+ #[test]+ fn readout_shows_the_frame_size_while_drawing_or_resizing() {+ let mut app = app(SampleType::U8);+ let ev = |app: &mut PhotocraftApp, e: ToolEvent| tool_event(app, e, NONE);+ ev(&mut app, ToolEvent::Down { x: 10.0, y: 10.0, pressure: 1.0 });+ assert_eq!(sizing(&app), None, "nothing drawn yet");+ ev(&mut app, ToolEvent::Move { x: 70.4, y: 50.6, pressure: 1.0 });+ assert_eq!(sizing(&app), Some([60.0, 41.0]), "rounded as ↵ crops it");+ ev(&mut app, ToolEvent::Up { x: 70.4, y: 50.6 });+ assert_eq!(sizing(&app), None);+ // Resizing a turned frame by its right edge: the frame's own width grows.+ app.ui.crop_rect = Some([20.0, 20.0, 100.0, 60.0]);+ app.ui.crop_angle = 30.0;+ let grab = turn([100.0, 40.0], [60.0, 40.0], 30.0);+ let to = [grab[0] + 10.0 * 30f64.to_radians().cos(), grab[1] + 10.0 * 30f64.to_radians().sin()];+ ev(&mut app, ToolEvent::Down { x: grab[0], y: grab[1], pressure: 1.0 });+ ev(&mut app, ToolEvent::Move { x: to[0], y: to[1], pressure: 1.0 });+ assert!(matches!(app.crop.drag, Some(CropDrag::Resize { .. })));+ assert_eq!(sizing(&app), Some([90.0, 40.0]));+ ev(&mut app, ToolEvent::Up { x: to[0], y: to[1] });+ // Moving shows no size.+ ev(&mut app, ToolEvent::Down { x: 60.0, y: 40.0, pressure: 1.0 });+ ev(&mut app, ToolEvent::Move { x: 62.0, y: 40.0, pressure: 1.0 });+ assert!(matches!(app.crop.drag, Some(CropDrag::Move { .. })));+ assert_eq!(sizing(&app), None);+ ev(&mut app, ToolEvent::Up { x: 62.0, y: 40.0 });+ assert_eq!(frame_size([0.0, 0.0, 0.2, 0.4]), Some([1.0, 1.0]));+ assert_eq!(frame_size([f64::NAN, 0.0, 1.0, 1.0]), None);+ assert_eq!(frame_size([-f64::MAX, 0.0, f64::MAX, 1.0]), None);+ }}diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex dd622b1ed..f0e398d53 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -2080,7 +2080,7 @@Pixel PixelAdjustment AnpassungDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Ziehen (Lasso) oder Punkte klicken (polygonal) · {add} hinzufügen · {sub} abziehen- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Freistellrahmen ziehen · innen ziehen verschiebt · Kanten skalieren ({ratio} Verhältnis, {centre} zentriert) · Leertaste verschiebt beim Zeichnen · {commit} übernimmt · Esc bricht ab+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Freistellrahmen ziehen · innen ziehen verschiebt · Kanten skalieren ({ratio} Verhältnis, {centre} zentriert) · Leertaste verschiebt beim Zeichnen · Pfeiltasten verschieben · X tauscht Ausrichtung · {commit} übernimmt · Esc bricht ab{mode} Color · {bits} bit {mode}-Farbe · {bits} BitScrubby Zoom SchleppzoomAuto Erase Automatisch löschendiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex d90cd42ef..87cc5003a 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -2203,7 +2203,7 @@Dots ΚουκκίδεςDown ΚάτωDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Σύρετε για λάσο ή κάντε κλικ για πολυγωνική επιλογή · {add} προσθήκη · {sub} αφαίρεση- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Σύρετε για περιοχή περικοπής · σύρετε στο εσωτερικό για μετακίνηση · από τα άκρα αλλάζει μέγεθος ({ratio} αναλογία, {centre} κέντρο) · Space για μετακίνηση κατά τη σχεδίαση · {commit} εφαρμογή · Esc ακύρωση+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Σύρετε για περιοχή περικοπής · σύρετε στο εσωτερικό για μετακίνηση · από τα άκρα αλλάζει μέγεθος ({ratio} αναλογία, {centre} κέντρο) · Space για μετακίνηση κατά τη σχεδίαση · βέλη για μετακίνηση · X εναλλαγή προσανατολισμού · {commit} εφαρμογή · Esc ακύρωσηDrag around the centre to rotate the view · Shift constrains to 15° Σύρετε γύρω από το κέντρο για να περιστρέψετε την προβολή · Shift περιορίζει στις 15°Drag on the image to add a constraint; Shift for horizontal/vertical; right-click to delete. Σύρετε πάνω στην εικόνα για προσθήκη περιορισμού· Shift για οριζόντιο/κατακόρυφο· δεξί κλικ για διαγραφή.Drag or click polygon points · hold Alt during lasso for straight segments · {add} add · {sub} before drawing subtracts Σύρετε ή κάντε κλικ για πολυγωνικά σημεία · κρατήστε Alt κατά το λάσο για ευθείες · {add} προσθήκη · {sub} αφαίρεση πριν από τη σχεδίασηdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex e566ad4e1..b7ea6a985 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -2098,7 +2098,7 @@Pixel PíxelAdjustment AjusteDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Arrastre (lazo) o haga clic en los puntos (poligonal) · {add} añadir · {sub} restar- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Arrastre un marco de recorte · arrastre dentro para mover · los bordes cambian el tamaño ({ratio} proporción, {centre} centro) · Espacio mueve mientras dibuja · {commit} aplica · Esc cancela+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Arrastre un marco de recorte · arrastre dentro para mover · los bordes cambian el tamaño ({ratio} proporción, {centre} centro) · Espacio mueve mientras dibuja · flechas desplazan · X cambia orientación · {commit} aplica · Esc cancela{mode} Color · {bits} bit Color {mode} · {bits} bitsScrubby Zoom Zoom por arrastreAuto Erase Borrado automáticodiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex a6a7f6183..c556da626 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2360,7 +2360,7 @@Pixel PixelAdjustment AjustementDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Faites glisser (lasso) ou cliquez des points (polygonal) · {add} ajouter · {sub} soustraire- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Tracez un cadre de recadrage · faites glisser à l'intérieur pour le déplacer · les bords le redimensionnent ({ratio} proportions, {centre} centre) · Espace le déplace pendant le tracé · {commit} valide · Échap annule+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Tracez un cadre de recadrage · faites glisser à l'intérieur pour le déplacer · les bords le redimensionnent ({ratio} proportions, {centre} centre) · Espace le déplace pendant le tracé · flèches le décalent · X permute l'orientation · {commit} valide · Échap annule{mode} Color · {bits} bit Couleurs {mode} · {bits} bitsDrag to move the layer Faites glisser pour déplacer le calqueScrubby Zoom Zoom par glissementdiff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 0fba8ab46..7137a8b24 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2351,7 +2351,7 @@Pixel PikselAdjustment PenyesuaianDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Seret (lasso) atau klik titik (polygonal) · {add} tambah · {sub} kurangi- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Seret kotak crop · seret di dalam untuk memindah · tepi mengubah ukuran (rasio {ratio}, tengah {centre}) · Space memindah saat menggambar · {commit} menerapkan · Esc batal+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Seret kotak crop · seret di dalam untuk memindah · tepi mengubah ukuran (rasio {ratio}, tengah {centre}) · Space memindah saat menggambar · panah menggeser · X menukar orientasi · {commit} menerapkan · Esc batal{mode} Color · {bits} bit Warna {mode} · {bits} bitDrag to move the layer Seret untuk memindah layerScrubby Zoom Zoom Scrubbydiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex 96a261b4c..3b90d4f3f 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -2097,7 +2097,7 @@Pixel PixelAdjustment RegolazioneDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Trascina (lazo) o clic su punti (poligonale) · {add} aggiungi · {sub} sottrai- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Trascina un riquadro ritaglio · trascina dentro per spostare · bordi ridimensionano ({ratio} proporzione, {centre} centro) · Spazio sposta durante disegno · {commit} conferma · Esc annulla+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Trascina un riquadro ritaglio · trascina dentro per spostare · bordi ridimensionano ({ratio} proporzione, {centre} centro) · Spazio sposta durante disegno · frecce spostano · X scambia orientamento · {commit} conferma · Esc annulla{mode} Color · {bits} bit Colore {mode} · {bits} bitScrubby Zoom Zoom scrubbyAuto Erase Cancellazione automaticadiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex fef8cf56c..0fbd3f5d7 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -3100,7 +3100,7 @@ fontWeight Italic 斜体Document Size ドキュメントサイズDodge/Burn 覆い焼き/焼き込みDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract ドラッグ (投げ縄) またはクリックでポイント指定 (多角形) · {add} 追加 · {sub} 除外- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels 切り抜きボックスをドラッグ · 内側をドラッグで移動 · 縁でサイズ変更 ({ratio} で比率、{centre} で中心) · 描画中は Space で移動 · {commit} で確定 · Esc で取り消し+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels 切り抜きボックスをドラッグ · 内側をドラッグで移動 · 縁でサイズ変更 ({ratio} で比率、{centre} で中心) · 描画中は Space で移動 · 矢印キーで微調整 · X で縦横を切り替え · {commit} で確定 · Esc で取り消しDrag to move the layer ドラッグしてレイヤーを移動Duplicated selection name 複製した選択範囲の名前Dynamics ダイナミクスdiff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex e0d62ac0d..e992b479e 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -2070,7 +2070,7 @@Pixel PixelAdjustment AanpassingDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Slepen (lasso) of punten klikken (veelhoek) · {add} toevoegen · {sub} aftrekken- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Sleep een bijsnijkader · sleep binnenin om te verplaatsen · randen wijzigen formaat ({ratio} verhouding, {centre} midden) · Spatie verplaatst tijdens tekenen · {commit} past toe · Esc annuleert+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Sleep een bijsnijkader · sleep binnenin om te verplaatsen · randen wijzigen formaat ({ratio} verhouding, {centre} midden) · Spatie verplaatst tijdens tekenen · pijltjes verschuiven · X wisselt oriëntatie · {commit} past toe · Esc annuleert{mode} Color · {bits} bit {mode}-kleur · {bits} bitScrubby Zoom SleepzoomAuto Erase Automatisch gummendiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 7a09d748b..387c0e4e9 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -2390,7 +2390,7 @@Pixel PikselAdjustment KorektaDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Przeciągaj (lasso) lub klikaj punkty (wielokątne) · {add} dodaj · {sub} odejmij- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Przeciągnij ramkę przycinania · przeciągnij wewnątrz, aby przesunąć · krawędzie zmieniają rozmiar ({ratio} proporcje, {centre} od środka) · Spacja przesuwa podczas rysowania · {commit} zatwierdza · Esc anuluje+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Przeciągnij ramkę przycinania · przeciągnij wewnątrz, aby przesunąć · krawędzie zmieniają rozmiar ({ratio} proporcje, {centre} od środka) · Spacja przesuwa podczas rysowania · strzałki przesuwają · X zamienia orientację · {commit} zatwierdza · Esc anuluje{mode} Color · {bits} bit Kolor {mode} · {bits} bitówDrag to move the layer Przeciągnij, aby przesunąć warstwęScrubby Zoom Powiększanie przeciąganiemdiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 6c57db9b4..a0052dc7c 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2359,7 +2359,7 @@Pixel PixelAdjustment AjusteDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Arraste (laço) ou clique nos pontos (poligonal) · {add} adicionar · {sub} subtrair- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Arraste uma caixa de corte · arraste dentro para mover · as bordas redimensionam ({ratio} proporção, {centre} centro) · Espaço move durante o desenho · {commit} confirma · Esc cancela+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Arraste uma caixa de corte · arraste dentro para mover · as bordas redimensionam ({ratio} proporção, {centre} centro) · Espaço move durante o desenho · setas deslocam · X troca a orientação · {commit} confirma · Esc cancela{mode} Color · {bits} bit Cor {mode} · {bits} bitsDrag to move the layer Arraste para mover a camadaScrubby Zoom Zoom por arrastediff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 92f4d56be..6c312893c 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -1531,7 +1531,7 @@Click to fill similar colours Щёлкните, чтобы залить похожие цветаClick to add text Щёлкните, чтобы добавить текстDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Перетащите (лассо) или щёлкайте точки (многоугольное) · {add} добавить · {sub} вычесть- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Выделите рамку кадрирования · перетащите внутри для перемещения · края меняют размер ({ratio} пропорции, {centre} центр) · Space двигает при рисовании · {commit} применить · Esc отмена+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Выделите рамку кадрирования · перетащите внутри для перемещения · края меняют размер ({ratio} пропорции, {centre} центр) · Space двигает при рисовании · стрелки сдвигают · X меняет ориентацию · {commit} применить · Esc отмена{mode} Color · {bits} bit {mode}, {bits} битDrag to move the layer Перетащите, чтобы переместить слойFit Screen По размеру экранаdiff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex 0741f5090..dbfdcb549 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -1523,7 +1523,7 @@Click to fill similar colours Клацніть, щоб залити подібні кольориClick to add text Клацніть, щоб додати текстDrag (lasso) or click points (polygonal) · {add} add · {sub} subtract Перетягування (ласо) або клацання точок (багатокутне) · {add} додати · {sub} відняти- Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels Намалюйте рамку кадрування · перетягування всередині переміщує · краї змінюють розмір ({ratio} пропорції, {centre} центр) · пробіл переміщує під час малювання · {commit} підтверджує · Esc скасовує+ Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels Намалюйте рамку кадрування · перетягування всередині переміщує · краї змінюють розмір ({ratio} пропорції, {centre} центр) · пробіл переміщує під час малювання · стрілки зсувають · X змінює орієнтацію · {commit} підтверджує · Esc скасовує{mode} Color · {bits} bit Колір {mode} · {bits} бітDrag to move the layer Перетягніть, щоб перемістити шарFit Screen Умістити на екраніdiff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 589e09350..328cc6d79 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -1142,7 +1142,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {Tool::Crop => hint(ui,&crate::i18n::fmt(- tl!("Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · {commit} commits · Esc cancels"),+ tl!("Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels"),&[("ratio", &crate::shortcuts::pretty("Shift")),("centre", &crate::shortcuts::pretty("Alt")),diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rsindex e6b018b2e..c3462947e 100644--- a/crates/ui-egui/src/shortcuts.rs+++ b/crates/ui-egui/src/shortcuts.rs@@ -295,6 +295,11 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) {return;}}+ // Crop tool with a pending frame: arrows nudge it (⇧ ×10) and X swaps its orientation, before+ // the selection / layer nudge and the X colour swap (#1919).+ if focus == Focus::None && crate::crop_ui::keys(app, ctx) {+ return;+ }// Move tool / Free Transform: arrows nudge (⇧ ×10, ⌥ duplicates first).if focus == Focus::None && crate::move_mods::arrow_keys(app, ctx) {return;diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 6cc09b30d..e5a22bebb 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js|---|---:|---:|---:|---|| [Performance](#performance) | 3 | 22 | 14 | 48 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 7 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |-| [Tools](#tools) | 13 | 14 | 8 | |+| [Tools](#tools) | 14 | 14 | 8 | || [Workspace and UI](#workspace-and-ui) | 5 | 6 | 12 | settings that do nothing: 51 of 141 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) |@@ -157,6 +157,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t| TOOL-214-17 | Rotate View tool: drag to turn the view, Reset View, Match Rotation copies the angle | done | [#214](https://github.com/storytold/photocraft/issues/214) | Tool::RotateView in the Hand flyout; view.rotateView / view.resetView; Match Rotation copies views[].rotation; enhanced_controls.rotate_view_with_trackpad is read || TOOL-1649-1 | Eyedropper Sample Size (Point, 3×3 … 101×101 Average), Sample layers, Show Sampling Ring | done | [#1649](https://github.com/storytold/photocraft/issues/1649) | document.sampleColor (sample_cmds.rs): average of the square clipped to the canvas, in the document's model and depth; eyedropper_ui.rs options bar; shared with Alt-click, dialog eyedroppers and the Info panel; ui.set eyedropperSampleSize/eyedropperSample/eyedropperRing. Color Sampler tool still missing || TOOL-214-18 | Crop: drag outside the frame to rotate it (Shift 15 deg steps, angle readout); Enter rotates and crops in one step | done | [#1792](https://github.com/storytold/photocraft/issues/1792) | image.crop angle param (image_cmds.rs: Image Rotation > Arbitrary + crop, one undo step); crop_ui.rs turns, moves and resizes the frame along its axes (Classic Mode visuals); UiState.crop_angle |+| TOOL-214-19 | Crop: arrow keys nudge the crop box (Shift 10 px), X swaps portrait/landscape, W x H readout while drawing or resizing | done | [#1919](https://github.com/storytold/photocraft/issues/1919) | crop_ui.rs keys/nudge/swap_orientation (ahead of the selection nudge and tools.swapColors in shortcuts.rs; X also swaps the options-bar ratio) and sizing (canvas.rs draws it with the marquee readout); turned frames included |## Workspace and UIdiff --git a/scorecard/tools.toml b/scorecard/tools.tomlindex 0e43cb37a..b258e6ce6 100644--- a/scorecard/tools.toml+++ b/scorecard/tools.toml@@ -249,3 +249,10 @@ target = "Crop: drag outside the frame to rotate it (Shift 15 deg steps, angle rstatus = "done"issue = 1792note = "image.crop angle param (image_cmds.rs: Image Rotation > Arbitrary + crop, one undo step); crop_ui.rs turns, moves and resizes the frame along its axes (Classic Mode visuals); UiState.crop_angle"++[[item]]+id = "TOOL-214-19"+target = "Crop: arrow keys nudge the crop box (Shift 10 px), X swaps portrait/landscape, W x H readout while drawing or resizing"+status = "done"+issue = 1919+note = "crop_ui.rs keys/nudge/swap_orientation (ahead of the selection nudge and tools.swapColors in shortcuts.rs; X also swaps the options-bar ratio) and sizing (canvas.rs draws it with the marquee readout); turned frames included"