changed internal lifelines structure
This commit is contained in:
@ -6,23 +6,23 @@
|
||||
let i = ctx.pars-i.at(par-name)
|
||||
let par = ctx.participants.at(i)
|
||||
let line = ctx.lifelines.at(i)
|
||||
let entry = (evt.event, ctx.y)
|
||||
let entry = (type: evt.event, y: ctx.y)
|
||||
|
||||
if evt.event == "disable" {
|
||||
line.level -= 1
|
||||
} else if evt.event == "enable" {
|
||||
line.level += 1
|
||||
entry.push(evt.lifeline-style)
|
||||
entry.insert("style", evt.lifeline-style)
|
||||
} else if evt.event == "create" {
|
||||
ctx.y -= CREATE-OFFSET
|
||||
entry.at(1) = ctx.y
|
||||
entry.y = ctx.y
|
||||
(par.draw)(par, y: ctx.y)
|
||||
} else if evt.event == "destroy" {
|
||||
} else {
|
||||
panic("Unknown event '" + evt.event + "'")
|
||||
}
|
||||
|
||||
line.lines.push(entry)
|
||||
line.events.push(entry)
|
||||
set-ctx(c => {
|
||||
c.lifelines.at(i) = line
|
||||
c.y = ctx.y
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,23 +102,23 @@
|
||||
if seq.disable-src {
|
||||
let src-line = ctx.lifelines.at(i1)
|
||||
src-line.level -= 1
|
||||
src-line.lines.push(("disable", start-info.y))
|
||||
src-line.events.push((type: "disable", y: start-info.y))
|
||||
ctx.lifelines.at(i1) = src-line
|
||||
}
|
||||
if seq.destroy-src {
|
||||
let src-line = ctx.lifelines.at(i1)
|
||||
src-line.lines.push(("destroy", start-info.y))
|
||||
src-line.events.push((type: "destroy", y: start-info.y))
|
||||
ctx.lifelines.at(i1) = src-line
|
||||
}
|
||||
if seq.disable-dst {
|
||||
let dst-line = ctx.lifelines.at(i2)
|
||||
dst-line.level -= 1
|
||||
dst-line.lines.push(("disable", end-info.y))
|
||||
dst-line.events.push((type: "disable", y: end-info.y))
|
||||
ctx.lifelines.at(i2) = dst-line
|
||||
}
|
||||
if seq.destroy-dst {
|
||||
let dst-line = ctx.lifelines.at(i2)
|
||||
dst-line.lines.push(("destroy", end-info.y))
|
||||
dst-line.events.push((type: "destroy", y: end-info.y))
|
||||
ctx.lifelines.at(i2) = dst-line
|
||||
}
|
||||
if seq.enable-dst {
|
||||
@ -341,12 +341,12 @@
|
||||
|
||||
if seq.create-dst {
|
||||
let dst-line = ctx.lifelines.at(i2)
|
||||
dst-line.lines.push(("create", end-info.y))
|
||||
dst-line.events.push((type: "create", y: end-info.y))
|
||||
ctx.lifelines.at(i2) = dst-line
|
||||
}
|
||||
if seq.enable-dst {
|
||||
let dst-line = ctx.lifelines.at(i2)
|
||||
dst-line.lines.push(("enable", end-info.y, seq.lifeline-style))
|
||||
dst-line.events.push((type: "enable", y: end-info.y, style: seq.lifeline-style))
|
||||
ctx.lifelines.at(i2) = dst-line
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@
|
||||
groups: (),
|
||||
lifelines: participants.map(_ => (
|
||||
level: 0,
|
||||
lines: ()
|
||||
events: ()
|
||||
))
|
||||
)
|
||||
chronos-ctx.insert(
|
||||
|
Reference in New Issue
Block a user