added short/start/end arrows
This commit is contained in:
@ -2,10 +2,12 @@
|
||||
#import "utils.typ": get-participants-i, get-style
|
||||
#import "group.typ"
|
||||
#import "participant.typ"
|
||||
#import participant: PAR-SPECIALS
|
||||
#import "sequence.typ"
|
||||
#import "separator.typ"
|
||||
#import "consts.typ": *
|
||||
|
||||
#let DEBUG-INVISIBLE = false
|
||||
|
||||
#let get-columns-width(participants, elements) = {
|
||||
participants = participants.map(p => {
|
||||
@ -56,8 +58,10 @@
|
||||
for i in range(participants.len() - 1) {
|
||||
let p1 = participants.at(i)
|
||||
let p2 = participants.at(i + 1)
|
||||
let w1 = measure(box(p1.display-name)).width + PAR-PAD.last() * 2
|
||||
let w2 = measure(box(p2.display-name)).width + PAR-PAD.last() * 2
|
||||
let w1 = if p1.invisible {0pt} else {measure(box(p1.display-name)).width}
|
||||
let w2 = if p2.invisible {0pt} else {measure(box(p2.display-name)).width}
|
||||
w1 += PAR-PAD.last() * 2
|
||||
w2 += PAR-PAD.last() * 2
|
||||
widths.push(w1 / 2pt + w2 / 2pt + PAR-SPACE)
|
||||
}
|
||||
|
||||
@ -79,7 +83,7 @@
|
||||
let m = measure(cell.cell)
|
||||
widths.at(cell.i2 - 1) = calc.max(
|
||||
widths.at(cell.i2 - 1),
|
||||
m.width / 1pt - widths.slice(0, cell.i2 - 1).sum()
|
||||
m.width / 1pt - widths.slice(cell.i1, cell.i2 - 1).sum()
|
||||
)
|
||||
}
|
||||
|
||||
@ -115,7 +119,7 @@
|
||||
|
||||
// Draw participants (start)
|
||||
for p in participants {
|
||||
if p.from-start {
|
||||
if p.from-start and not p.invisible {
|
||||
shapes += draw-par(p)
|
||||
}
|
||||
}
|
||||
@ -174,8 +178,26 @@
|
||||
|
||||
// Draw vertical lines + lifelines + end participants
|
||||
shapes += draw.on-layer(-1, {
|
||||
for (i, p) in participants.enumerate() {
|
||||
let x = x-pos.at(i)
|
||||
if DEBUG-INVISIBLE {
|
||||
for p in participants.filter(p => p.invisible) {
|
||||
let color = if p.name.starts-with("?") {green} else if p.name.ends-with("?") {red} else {blue}
|
||||
let x = x-pos.at(p.i)
|
||||
draw.line(
|
||||
(x, 0),
|
||||
(x, y),
|
||||
stroke: (paint: color, dash: "dotted")
|
||||
)
|
||||
draw.content(
|
||||
(x, 0),
|
||||
p.display-name,
|
||||
anchor: "west",
|
||||
angle: 90deg
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
for p in participants.filter(p => not p.invisible) {
|
||||
let x = x-pos.at(p.i)
|
||||
|
||||
// Draw vertical line
|
||||
let last-y = 0
|
||||
@ -185,7 +207,7 @@
|
||||
let lines = ()
|
||||
|
||||
// Compute lifeline rectangles + destruction positions
|
||||
for line in lifelines.at(i).lines {
|
||||
for line in lifelines.at(p.i).lines {
|
||||
let event = line.first()
|
||||
if event == "create" {
|
||||
last-y = line.at(1)
|
||||
|
Reference in New Issue
Block a user