group nesting padding
This commit is contained in:
parent
b8f00f32f1
commit
de3c0518f5
6 changed files with 39 additions and 14 deletions
|
|
@ -12,6 +12,8 @@ const MIN_ACTOR_WIDTH = 150.
|
||||||
|
|
||||||
const SELF_MESSAGE_HORIZONTAL_TRAVEL = 100.
|
const SELF_MESSAGE_HORIZONTAL_TRAVEL = 100.
|
||||||
|
|
||||||
|
const GROUP_CONTAINER_PADDING = 24.
|
||||||
|
|
||||||
// min vertical distance between messages
|
// min vertical distance between messages
|
||||||
const MIN_MESSAGE_DISTANCE = 80.
|
const MIN_MESSAGE_DISTANCE = 80.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,9 @@ func (sd *sequenceDiagram) layout() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sd *sequenceDiagram) placeGroups() {
|
func (sd *sequenceDiagram) placeGroups() {
|
||||||
|
sort.SliceStable(sd.groups, func(i, j int) bool {
|
||||||
|
return sd.groups[i].Level() > sd.groups[j].Level()
|
||||||
|
})
|
||||||
for _, group := range sd.groups {
|
for _, group := range sd.groups {
|
||||||
group.ZIndex = GROUP_Z_INDEX
|
group.ZIndex = GROUP_Z_INDEX
|
||||||
sd.placeGroup(group)
|
sd.placeGroup(group)
|
||||||
|
|
@ -217,13 +220,33 @@ func (sd *sequenceDiagram) placeGroup(group *d2graph.Object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasNested := false
|
||||||
|
for _, ch := range group.ChildrenArray {
|
||||||
|
for _, g := range sd.groups {
|
||||||
|
if ch == g {
|
||||||
|
hasNested = true
|
||||||
|
minX = math.Min(minX, ch.TopLeft.X-GROUP_CONTAINER_PADDING)
|
||||||
|
minY = math.Min(minY, ch.TopLeft.Y-GROUP_CONTAINER_PADDING)
|
||||||
|
maxX = math.Max(maxX, ch.TopLeft.X+ch.Width+GROUP_CONTAINER_PADDING)
|
||||||
|
maxY = math.Max(maxY, ch.TopLeft.Y+ch.Height+GROUP_CONTAINER_PADDING)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasNested {
|
||||||
|
minX -= HORIZONTAL_PAD
|
||||||
|
minY -= MIN_MESSAGE_DISTANCE / 2.
|
||||||
|
maxX += HORIZONTAL_PAD
|
||||||
|
maxY += MIN_MESSAGE_DISTANCE / 2.
|
||||||
|
}
|
||||||
|
|
||||||
group.Box = geo.NewBox(
|
group.Box = geo.NewBox(
|
||||||
geo.NewPoint(
|
geo.NewPoint(
|
||||||
minX-HORIZONTAL_PAD,
|
minX,
|
||||||
minY-(MIN_MESSAGE_DISTANCE/2.),
|
minY,
|
||||||
),
|
),
|
||||||
maxX-minX+HORIZONTAL_PAD*2,
|
maxX-minX,
|
||||||
maxY-minY+MIN_MESSAGE_DISTANCE,
|
maxY-minY,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
8
e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json
generated
vendored
8
e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json
generated
vendored
|
|
@ -199,11 +199,11 @@
|
||||||
"id": "group 1",
|
"id": "group 1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"pos": {
|
"pos": {
|
||||||
"x": 245,
|
"x": 221,
|
||||||
"y": 526
|
"y": 566
|
||||||
},
|
},
|
||||||
"width": 320,
|
"width": 368,
|
||||||
"height": 730,
|
"height": 650,
|
||||||
"opacity": 1,
|
"opacity": 1,
|
||||||
"strokeDash": 0,
|
"strokeDash": 0,
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
8
e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json
generated
vendored
8
e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json
generated
vendored
|
|
@ -199,11 +199,11 @@
|
||||||
"id": "group 1",
|
"id": "group 1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"pos": {
|
"pos": {
|
||||||
"x": 245,
|
"x": 221,
|
||||||
"y": 526
|
"y": 566
|
||||||
},
|
},
|
||||||
"width": 320,
|
"width": 368,
|
||||||
"height": 730,
|
"height": 650,
|
||||||
"opacity": 1,
|
"opacity": 1,
|
||||||
"strokeDash": 0,
|
"strokeDash": 0,
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
Loading…
Reference in a new issue