forked from 1b-agent/opencadstudio-upstream
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 <[email protected]>
This commit is contained in:
1 parent
ac4126072c
commit
ef855b56c5
1 file changed
+6
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user