Skip to content

Commit

Permalink
elk label height
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Dec 12, 2023
1 parent da3fa94 commit 43626a9
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 301 deletions.
13 changes: 10 additions & 3 deletions d2layouts/d2elklayout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,18 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
if hasTop || hasBottom {
padding := parsePadding(elkNodes[obj].LayoutOptions.Padding)
if hasTop {
// TODO I think this fails to account for a potential inner label of container
padding.top = go2.Max(padding.top, d2target.MAX_ICON_SIZE+2*label.PADDING)
ownLabelHeight := 0
if obj.LabelPosition != nil && strings.HasPrefix(*obj.LabelPosition, "INSIDE_TOP") {
ownLabelHeight = obj.LabelDimensions.Height + label.PADDING
}
padding.top = go2.Max(padding.top, d2target.MAX_ICON_SIZE+2*label.PADDING+ownLabelHeight)
}
if hasBottom {
padding.bottom = go2.Max(padding.bottom, d2target.MAX_ICON_SIZE+2*label.PADDING)
ownLabelHeight := 0
if obj.LabelPosition != nil && strings.HasPrefix(*obj.LabelPosition, "INSIDE_BOTTOM") {
ownLabelHeight = obj.LabelDimensions.Height + label.PADDING
}
padding.bottom = go2.Max(padding.bottom, d2target.MAX_ICON_SIZE+2*label.PADDING+ownLabelHeight)
}
elkNodes[obj].LayoutOptions.Padding = padding.String()
}
Expand Down
18 changes: 9 additions & 9 deletions e2etests/testdata/txtar/sql-icon/elk/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 43626a9

Please sign in to comment.