From fda46b391df63c06fc327dc6417686897c48fe56 Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 29 Oct 2026 17:36:55 +0100 Subject: [PATCH] Address CodeRabbit review: Match Zoom and Match Location report the camera's rotation They copy no rotation, so the crop's turn isn't left out of their result; only Match Rotation and Match All report the crop-adjusted value they copy. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/menus/view_cmds/arrange.rs | 3 ++- crates/ui-egui/src/tools/crop_mode/tests.rs | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus/view_cmds/arrange.rs b/crates/ui-egui/src/menus/view_cmds/arrange.rs index 3749baeb3ca..59920198478 100644 --- a/crates/ui-egui/src/menus/view_cmds/arrange.rs +++ b/crates/ui-egui/src/menus/view_cmds/arrange.rs @@ -119,7 +119,8 @@ pub(super) fn arrange(app: &mut PhotocraftApp, k: &str, p: &Value) -> Result Err(format!("unknown arrangement {k}")), } diff --git a/crates/ui-egui/src/tools/crop_mode/tests.rs b/crates/ui-egui/src/tools/crop_mode/tests.rs index 92e70bbe270..0c14d30a7a5 100644 --- a/crates/ui-egui/src/tools/crop_mode/tests.rs +++ b/crates/ui-egui/src/tools/crop_mode/tests.rs @@ -489,6 +489,30 @@ fn match_rotation_leaves_a_pending_crops_turn_out() { } } +/// Match Zoom and Match Location copy no rotation, so with a crop turning the active view they +/// report its camera's turn as it is and leave every view's rotation alone (#9308). +#[test] +fn match_zoom_and_location_report_the_turned_camera() { + let ctx = egui::Context::default(); + for id in ["window.arrange.matchZoom", "window.arrange.matchLocation"] { + let mut app = app(); + app.run("file.new", json!({"width": 300, "height": 150})).unwrap(); + app.sync_views(); + assert!(app.session.set_active(0)); + app.sync_views(); + let v = &mut app.ui.views[0]; + (v.zoom, v.center, v.fit_pending, v.rotation) = (1.0, [100.0, 50.0], false, 0.0); + app.ui.views[1].rotation = 15.0; + with_frame(&mut app); + screen_drag(&mut app, &[pos2(450.0, 300.0), pos2(440.0, 320.0), pos2(370.0, 380.0)], NONE); + let turned = view_rotation(&app); + assert!((turned - 90.0).abs() < 0.01, "{id}: the view turned with the frame"); + let r = crate::menus::invoke(&mut app, &ctx, id, json!({})).unwrap(); + assert!((r["rotation"].as_f64().unwrap() - f64::from(turned)).abs() < 0.01, "{id}: {r}"); + assert_eq!(app.ui.views[1].rotation, 15.0, "{id}: the other view keeps its rotation"); + } +} + #[test] fn picking_the_crop_tool_turns_a_rotated_view_upright() { let mut app = app();