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:
parent
ac4126072c
commit
ef855b56c5
1 changed files with 6 additions and 0 deletions
|
|
@ -4208,6 +4208,12 @@ impl OpenCADStudio {
|
||||||
Message::LayoutSwitch(name) => {
|
Message::LayoutSwitch(name) => {
|
||||||
let i = self.active_tab;
|
let i = self.active_tab;
|
||||||
let going_to_paper = name != "Model";
|
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.
|
// Cancel any pending rename/context-menu and active viewport when switching.
|
||||||
self.layout_rename_state = None;
|
self.layout_rename_state = None;
|
||||||
self.layout_context_menu = None;
|
self.layout_context_menu = None;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue