This commit is contained in:
Gavin Nishizawa 2023-09-25 15:38:22 -07:00
parent 2d00cb4bef
commit 86de2cd414
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -101,12 +101,27 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co
// if we are in a grid diagram, and our children have descendants // if we are in a grid diagram, and our children have descendants
// we need to run layout on them first, even if they are not special diagram types // we need to run layout on them first, even if they are not special diagram types
nestedGraph := ExtractSubgraph(curr, true) nestedGraph := ExtractSubgraph(curr, true)
id := curr.AbsID()
err := LayoutNested(ctx, nestedGraph, GraphInfo{}, coreLayout) err := LayoutNested(ctx, nestedGraph, GraphInfo{}, coreLayout)
if err != nil { if err != nil {
return err return err
} }
InjectNested(g.Root, nestedGraph, false) InjectNested(g.Root, nestedGraph, false)
restoreOrder() restoreOrder()
// need to update curr *Object incase layout changed it
var obj *d2graph.Object
for _, o := range g.Objects {
if o.AbsID() == id {
obj = o
break
}
}
if obj == nil {
return fmt.Errorf("could not find object %#v after layout", id)
}
curr = obj
dx := -curr.TopLeft.X dx := -curr.TopLeft.X
dy := -curr.TopLeft.Y dy := -curr.TopLeft.Y
for _, o := range nestedGraph.Objects { for _, o := range nestedGraph.Objects {