changed internal lifelines structure

This commit is contained in:
2025-07-18 17:30:00 +02:00
parent 22254211f3
commit ff8ec72a42
4 changed files with 35 additions and 40 deletions

View File

@@ -318,59 +318,54 @@
let rects = ()
let destructions = ()
let lines = ()
let stack = ()
// Compute lifeline rectangles + destruction positions
for line in ctx.lifelines.at(p.i).lines {
let event = line.first()
if event == "create" {
for event in ctx.lifelines.at(p.i).events {
if event.type == "create" {
last-y = line.at(1)
} else if event == "enable" {
if lines.len() == 0 {
} else if event.type == "enable" {
if stack.len() == 0 {
draw.line(
(x, last-y),
(x, line.at(1)),
(x, event.y),
stroke: p.line-stroke
)
}
lines.push(line)
stack.push(event)
} else if event == "disable" or event == "destroy" {
} else if event.type == "disable" or event.type == "destroy" {
let lvl = 0
if lines.len() != 0 {
let l = lines.pop()
lvl = lines.len()
if stack.len() != 0 {
let e = stack.pop()
lvl = stack.len()
rects.push((
x + lvl * LIFELINE-W / 2,
l.at(1),
line.at(1),
l.at(2)
e.y,
event.y,
e.style
))
last-y = line.at(1)
last-y = event.y
}
if event == "destroy" {
destructions.push((x + lvl * LIFELINE-W / 2, line.at(1)))
if event.type == "destroy" {
destructions.push((x + lvl * LIFELINE-W / 2, event.y))
}
} else if event == "delay-start" {
} else if event.type == "delay-start" {
draw.line(
(x, last-y),
(x, line.at(1)),
(x, event.y),
stroke: p.line-stroke
)
last-y = line.at(1)
} else if event == "delay-end" {
last-y = event.y
} else if event.type == "delay-end" {
draw.line(
(x, last-y),
(x, line.at(1)),
stroke: (
dash: "loosely-dotted",
paint: gray.darken(40%),
thickness: .8pt
)
(x, event.y),
stroke: event.stroke
)
last-y = line.at(1)
last-y = event.y
}
}