fix(layout): persist camera before switching layouts

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 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-02 23:51:17 +03:00
1 parent ac4126072c
commit ef855b56c5
1 file changed
+6
+6
View File
@@ -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;