diff --git a/d2layouts/d2sequence/constants.go b/d2layouts/d2sequence/constants.go index 9f2dc2e5b..0dfb3f2a7 100644 --- a/d2layouts/d2sequence/constants.go +++ b/d2layouts/d2sequence/constants.go @@ -15,7 +15,7 @@ const MIN_EDGE_DISTANCE = 100. const ACTIVATION_BOX_WIDTH = 20. // small pad so that edges don't touch lifelines and activation boxes -const ACTIVATION_BOX_EDGE_PAD = 2. +const ACTIVATION_BOX_EDGE_PAD = 5. // as the activation boxes start getting nested, their size grows const ACTIVATION_BOX_DEPTH_GROW_FACTOR = 10. diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index 2eca23f95..99ba69d63 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -203,10 +203,14 @@ func (sd *sequenceDiagram) placeActivationBoxes() { minY := math.Min(minEdgeY, minChildY) if minY == minChildY { minY -= ACTIVATION_BOX_DEPTH_GROW_FACTOR + } else { + minY -= ACTIVATION_BOX_EDGE_PAD } maxY := math.Max(maxEdgeY, maxChildY) if maxY == maxChildY { maxY += ACTIVATION_BOX_DEPTH_GROW_FACTOR + } else { + maxY += ACTIVATION_BOX_EDGE_PAD } height := math.Max(maxY-minY, DEFAULT_ACTIVATION_BOX_HEIGHT) diff --git a/d2layouts/d2sequence/layout_test.go b/d2layouts/d2sequence/layout_test.go index fcdd12352..90320a464 100644 --- a/d2layouts/d2sequence/layout_test.go +++ b/d2layouts/d2sequence/layout_test.go @@ -209,7 +209,7 @@ func TestActivationBoxesSequenceDiagram(t *testing.T) { } // Y diff of the 2 first edges - expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + (2 * ACTIVATION_BOX_EDGE_PAD) if a_t1.Height != expectedHeight { t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height) } @@ -231,7 +231,7 @@ func TestActivationBoxesSequenceDiagram(t *testing.T) { if a_t1.TopLeft.Y != b_t1.TopLeft.Y { t.Fatal("expected a.t1 and b.t1 to be placed at the same Y") } - if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y { + if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y-ACTIVATION_BOX_EDGE_PAD { t.Fatal("expected a.t1 to be placed at the same Y of the first edge") }