cleanup
This commit is contained in:
parent
1550f3a93b
commit
90e2fcf4e2
2 changed files with 22 additions and 25 deletions
|
|
@ -236,8 +236,17 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.Width = math.Ceil(dn.Width)
|
obj.Width = math.Ceil(dn.Width)
|
||||||
obj.Height = math.Ceil(dn.Height)
|
obj.Height = math.Ceil(dn.Height)
|
||||||
|
|
||||||
hasLabelPosition := obj.LabelPosition != nil
|
if obj.Icon != nil && obj.IconPosition == nil {
|
||||||
if obj.HasLabel() && !hasLabelPosition {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.OutsideTopLeft))
|
||||||
|
if obj.LabelPosition == nil {
|
||||||
|
obj.LabelPosition = go2.Pointer(string(label.OutsideTopRight))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if obj.HasLabel() && obj.LabelPosition == nil {
|
||||||
if len(obj.ChildrenArray) > 0 {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
obj.LabelPosition = go2.Pointer(string(label.OutsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.OutsideTopCenter))
|
||||||
} else if obj.HasOutsideBottomLabel() {
|
} else if obj.HasOutsideBottomLabel() {
|
||||||
|
|
@ -250,17 +259,6 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if obj.Icon != nil && obj.IconPosition == nil {
|
|
||||||
if len(obj.ChildrenArray) > 0 {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.OutsideTopLeft))
|
|
||||||
if !hasLabelPosition {
|
|
||||||
// overwrite LabelPosition if we just set it above
|
|
||||||
obj.LabelPosition = go2.Pointer(string(label.OutsideTopRight))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, edge := range g.Edges {
|
for i, edge := range g.Edges {
|
||||||
|
|
|
||||||
|
|
@ -407,8 +407,17 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.Width = math.Ceil(n.Width)
|
obj.Width = math.Ceil(n.Width)
|
||||||
obj.Height = math.Ceil(n.Height)
|
obj.Height = math.Ceil(n.Height)
|
||||||
|
|
||||||
hasLabelPosition := obj.LabelPosition != nil
|
if obj.Icon != nil && obj.IconPosition == nil {
|
||||||
if obj.HasLabel() && !hasLabelPosition {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideTopLeft))
|
||||||
|
if obj.LabelPosition == nil {
|
||||||
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopRight))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if obj.HasLabel() && obj.LabelPosition == nil {
|
||||||
if len(obj.ChildrenArray) > 0 {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
} else if obj.HasOutsideBottomLabel() {
|
} else if obj.HasOutsideBottomLabel() {
|
||||||
|
|
@ -420,16 +429,6 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if obj.Icon != nil && obj.IconPosition == nil {
|
|
||||||
if len(obj.ChildrenArray) > 0 {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideTopLeft))
|
|
||||||
if !hasLabelPosition {
|
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopRight))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byID[obj.AbsID()] = obj
|
byID[obj.AbsID()] = obj
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue