Skip to content

Commit

Permalink
Merge pull request #1679 from gavin-ts/glob-dimensions
Browse files Browse the repository at this point in the history
fix elk: growing shapes with width/height set
  • Loading branch information
gavin-ts authored Oct 21, 2023
2 parents 4cba5d2 + 40e8cc8 commit 0a7e6c8
Show file tree
Hide file tree
Showing 8 changed files with 2,068 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- Grid layout now accounts for labels wider or taller than the shape and fixes default label positions for image grid cells. [#1670](https://github.com/terrastruct/d2/pull/1670)
- Fixes a panic with a spread substitution in a glob map [#1643](https://github.com/terrastruct/d2/pull/1643)
- Fixes use of `null` in `sql_table` constraints (ty @landmaj) [#1660](https://github.com/terrastruct/d2/pull/1660)
- Fixes elk growing shapes with width/height set [#1679](https://github.com/terrastruct/d2/pull/1679)
8 changes: 6 additions & 2 deletions d2layouts/d2elklayout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,13 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
if incoming >= 2 || outgoing >= 2 {
switch g.Root.Direction.Value {
case "right", "left":
obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing)
if obj.Attributes.HeightAttr == nil {
obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing)
}
default:
obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing)
if obj.Attributes.WidthAttr == nil {
obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions e2etests/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ cf many required: {
loadFromFile(t, "disclaimer"),
loadFromFile(t, "grid_rows_gap_bug"),
loadFromFile(t, "grid_image_label_position"),
loadFromFile(t, "glob_dimensions"),
}

runa(t, tcs)
Expand Down
48 changes: 48 additions & 0 deletions e2etests/testdata/files/glob_dimensions.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
**: {
style.border-radius: 16
}

**: {
&label: end
label:
shape: circle
height: 10
width: 10
}

**: {
&label: start
label:
label.near: center-center
style.fill: black
shape: circle
height: 10
width: 10
}

**: {
&shape: diamond
label: ""
height: 20
width: 20
}

start -> Check PIN

Check PIN: {
direction: right

start -> Enter PIN
choice.shape: diamond

Enter PIN -> choice: "/check PIN"
choice -> Enter PIN: "[pin invalid]"
choice -> end: "[pin OK]"
}

Check PIN -> Search Network: "[pin OK]"
Search Network -> Ready: network found

Check PIN -> Off: power off
Search Network -> Off: power off
Ready -> Off: power off
Loading

0 comments on commit 0a7e6c8

Please sign in to comment.