added events
This commit is contained in:
parent
fd5b147e86
commit
9c83f810bb
@ -9,6 +9,15 @@
|
||||
),)
|
||||
}
|
||||
|
||||
#let _evt(participant, event) = {
|
||||
return ((
|
||||
type: "evt",
|
||||
participant: participant,
|
||||
event: event,
|
||||
lifeline-style: auto
|
||||
),)
|
||||
}
|
||||
|
||||
#let diagram(elements) = {
|
||||
if elements == none {
|
||||
return
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "diagram.typ": diagram, from-plantuml, _gap
|
||||
#import "diagram.typ": diagram, from-plantuml, _gap, _evt
|
||||
|
||||
#import "sequence.typ": _seq
|
||||
#import "group.typ": _grp
|
||||
|
@ -49,6 +49,18 @@
|
||||
p.max-lifelines = calc.max(p.max-lifelines, p.lifeline-lvl)
|
||||
participants.at(i2) = p
|
||||
}
|
||||
} else if elmt.type == "evt" {
|
||||
let par-name = elmt.participant
|
||||
let i = pars-i.at(par-name)
|
||||
let par = participants.at(i)
|
||||
if elmt.event == "disable" or elmt.event == "destroy" {
|
||||
par.lifeline-lvl -= 1
|
||||
|
||||
} else if elmt.event == "enable" {
|
||||
par.lifeline-lvl += 1
|
||||
par.max-lifelines = calc.max(par.max-lifelines, par.lifeline-lvl)
|
||||
}
|
||||
participants.at(i) = par
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +185,29 @@
|
||||
// Gap
|
||||
} else if elmt.type == "gap" {
|
||||
y -= elmt.size
|
||||
|
||||
// Event
|
||||
} else if elmt.type == "evt" {
|
||||
let par-name = elmt.participant
|
||||
let i = pars-i.at(par-name)
|
||||
let par = participants.at(i)
|
||||
let line = lifelines.at(i)
|
||||
if elmt.event == "disable" {
|
||||
line.level -= 1
|
||||
line.lines.push(("disable", y))
|
||||
|
||||
} else if elmt.event == "destroy" {
|
||||
line.lines.push(("destroy", y))
|
||||
|
||||
} else if elmt.event == "enable" {
|
||||
line.level += 1
|
||||
line.lines.push(("enable", y, elmt.lifeline-style))
|
||||
|
||||
} else if elmt.event == "create" {
|
||||
shapes += participant.render(x-pos, par, y: y)
|
||||
line.lines.push(("create", y))
|
||||
}
|
||||
lifelines.at(i) = line
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user