fix icon padding

This commit is contained in:
Alexander Wang 2023-02-23 11:15:24 -08:00
parent 92b8404d99
commit 6fe8989d30
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE

View file

@ -87,6 +87,16 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) {
x2 = go2.Max(x2, targetShape.Pos.X+MULTIPLE_OFFSET+targetShape.Width+targetShape.StrokeWidth)
}
if targetShape.Icon != nil && label.Position(targetShape.IconPosition).IsOutside() {
contentBox := geo.NewBox(geo.NewPoint(0, 0), float64(targetShape.Width), float64(targetShape.Height))
s := shape.NewShape(targetShape.Type, contentBox)
size := GetIconSize(s.GetInnerBox(), targetShape.IconPosition)
y1 = go2.Min(y1, targetShape.Pos.Y-label.PADDING-size)
x1 = go2.Min(x1, targetShape.Pos.X-label.PADDING-size)
y2 = go2.Max(y2, targetShape.Pos.Y+label.PADDING+size)
x2 = go2.Max(x2, targetShape.Pos.X+label.PADDING+size)
}
if targetShape.Label != "" {
labelPosition := label.Position(targetShape.LabelPosition)
if !labelPosition.IsOutside() {