diff --git a/src/renderer.typ b/src/renderer.typ index b4d6605..bd78e8b 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -86,6 +86,21 @@ ) } + // Compute minimum width for self sequences + for cell in cells.filter(c => c.i1 == c.i2) { + let m = measure(cell.cell) + let i = cell.i1 + if cell.elmt.flip { + i -= 1 + } + if 0 <= i and i < widths.len() { + widths.at(i) = calc.max( + widths.at(i), + m.width / 1pt + COMMENT-PAD + ) + } + } + // Compute remaining widths for longer sequences (spanning multiple columns) let multicol-cells = cells.filter(c => c.i2 - c.i1 > 1) multicol-cells = multicol-cells.sorted(key: c => { @@ -136,7 +151,7 @@ } } - let y = -Y-SPACE + let y = 0 let groups = () let lifelines = participants.map(_ => ( level: 0, @@ -153,6 +168,7 @@ // Groups (start) -> reserve space for labels + store position } else if elmt.type == "grp" { + y -= Y-SPACE let m = measure( box( elmt.name, @@ -165,17 +181,16 @@ g }) groups.push((y, elmt, 0, 0)) - y -= m.height / 1pt + Y-SPACE + y -= m.height / 1pt // Groups (end) -> actual drawing } else if elmt.type == "grp-end" { + y -= Y-SPACE let (start-y, group, start-lvl, end-lvl) = groups.pop() let x0 = x-pos.at(group.min-i) - start-lvl * 10 - 20 let x1 = x-pos.at(group.max-i) + end-lvl * 10 + 20 shapes += draw-group(x0, x1, start-y, y, group) - y -= Y-SPACE - // Separator } else if elmt.type == "sep" { let shps @@ -211,6 +226,8 @@ } } + y -= Y-SPACE + // Draw vertical lines + lifelines + end participants shapes += draw.on-layer(-1, { if DEBUG-INVISIBLE { diff --git a/src/separator.typ b/src/separator.typ index 9669cad..a203bc8 100644 --- a/src/separator.typ +++ b/src/separator.typ @@ -10,6 +10,7 @@ #let render(x-pos, elmt, y) = { let shapes = () + y -= Y-SPACE let x0 = x-pos.first() - 20 let x1 = x-pos.last() + 20 @@ -48,7 +49,6 @@ fill: COL-SEP-NAME ) y -= h / 2 - y -= Y-SPACE let r = (y, shapes) return r diff --git a/src/sequence.typ b/src/sequence.typ index f8cd8ff..b5809fb 100644 --- a/src/sequence.typ +++ b/src/sequence.typ @@ -40,6 +40,8 @@ #let render(pars-i, x-pos, participants, elmt, y, lifelines) = { let shapes = () + y -= Y-SPACE + // Reserve space for comment if elmt.comment != none { y -= measure(box(elmt.comment)).height / 1pt + 6 @@ -185,7 +187,6 @@ dst-line.lines.push(("create", y)) lifelines.at(i2) = dst-line } - y -= Y-SPACE let r = (y, lifelines, shapes) return r