Layouts: a new layout has no viewports until it first opens

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-13 12:33:14 +03:00
1 parent 518d058043
commit e21b50cf75
1 file changed
+9
+9
View File
@@ -24,6 +24,15 @@ impl Scene {
/// cached layout-name list is invalidated on insert.
pub fn add_layout(&mut self, name: &str) -> codec::Result<Handle> {
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)