Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-ts committed Dec 13, 2023
1 parent 9f63c30 commit 55d43f4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions d2layouts/d2elklayout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,9 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
}
}

if obj.HasLabel() && obj.HasIcon() && obj.IconPosition != nil {
if !label.FromString(*obj.IconPosition).IsOutside() {
// this gives shapes extra height for their label if they also have an icon
obj.Height += float64(obj.LabelDimensions.Height + label.PADDING)
}
if obj.HasLabel() && obj.HasIcon() {
// this gives shapes extra height for their label if they also have an icon
obj.Height += float64(obj.LabelDimensions.Height + label.PADDING)
}

margin, _ := obj.SpacingOpt(2*label.PADDING, 0, false)
Expand Down Expand Up @@ -570,7 +568,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
}
}
obj.TopLeft.X += margin.Left
obj.ShiftDescendants(margin.Left, 0)
obj.ShiftDescendants(margin.Left/2, 0)
obj.Width -= margin.Left
}
if margin.Right > 0 {
Expand All @@ -583,8 +581,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
e.Route[l-1].X -= margin.Right
}
}
// TODO is this right?
obj.ShiftDescendants(-margin.Right, 0)
obj.ShiftDescendants(-margin.Right/2, 0)
obj.Width -= margin.Right
}
if margin.Top > 0 {
Expand All @@ -598,7 +595,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
}
}
obj.TopLeft.Y += margin.Top
obj.ShiftDescendants(0, margin.Top)
obj.ShiftDescendants(0, margin.Top/2)
obj.Height -= margin.Top
}
if margin.Bottom > 0 {
Expand All @@ -611,7 +608,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
e.Route[l-1].Y -= margin.Bottom
}
}
obj.ShiftDescendants(0, -margin.Bottom)
obj.ShiftDescendants(0, -margin.Bottom/2)
obj.Height -= margin.Bottom
}
}
Expand Down

0 comments on commit 55d43f4

Please sign in to comment.