From e21b50cf75826710919472a1100feaf67a98f424 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Tue, 13 Oct 2026 12:33:14 +0300 Subject: [PATCH] Layouts: a new layout has no viewports until it first opens Co-Authored-By: Claude Opus 5.5 --- src/scene/layout.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/scene/layout.rs b/src/scene/layout.rs index 9036499ec..80e4a6d01 100644 --- a/src/scene/layout.rs +++ b/src/scene/layout.rs @@ -24,6 +24,15 @@ impl Scene { /// cached layout-name list is invalidated on insert. pub fn add_layout(&mut self, name: &str) -> codec::Result { let handle = self.document.add_layout(name)?; + // The layout has no viewports until it first opens (the sheet the + // document makes for it is placed at the origin, not on its page); + // opening it makes the sheet and, with LAYOUTCREATEVIEWPORT, its + // first viewport. + let block = match self.document.objects.get(&handle) { + Some(ObjectType::Layout(layout)) => layout.block_record, + _ => codec::Handle::NULL, + }; + crate::scene::drop_layout_viewports(&mut self.document, block); self.unopened_layouts.insert(name.to_string()); self.bump_layout_epoch(); Ok(handle)