From ef855b56c5a57bbe8d20de371809ef3bdca70afc Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 2 Jun 2026 23:51:17 +0300 Subject: [PATCH] fix(layout): persist camera before switching layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switching between Model and a paper layout reset the camera to the last saved state. The current camera was only written to the document on a periodic tick, which may not have run since the last pan/zoom — so the camera of the layout being left was lost. Sync it explicitly before set_current_layout so returning restores where the user left off. Co-Authored-By: Claude Opus 4.8 --- src/app/update.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/update.rs b/src/app/update.rs index 09da24f9c..28ed6a15e 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -4208,6 +4208,12 @@ impl OpenCADStudio { Message::LayoutSwitch(name) => { let i = self.active_tab; let going_to_paper = name != "Model"; + // Persist the camera of the layout we're leaving BEFORE switching + // so returning to it restores where the user left off (the + // periodic sync only fires on a tick, which may not have run + // since the last pan/zoom). + self.tabs[i].scene.sync_camera_to_document(); + self.tabs[i].last_synced_camera_gen = self.tabs[i].scene.camera_generation; // Cancel any pending rename/context-menu and active viewport when switching. self.layout_rename_state = None; self.layout_context_menu = None;