changed internal lifelines structure
This commit is contained in:
@ -6,23 +6,23 @@
|
|||||||
let i = ctx.pars-i.at(par-name)
|
let i = ctx.pars-i.at(par-name)
|
||||||
let par = ctx.participants.at(i)
|
let par = ctx.participants.at(i)
|
||||||
let line = ctx.lifelines.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" {
|
if evt.event == "disable" {
|
||||||
line.level -= 1
|
line.level -= 1
|
||||||
} else if evt.event == "enable" {
|
} else if evt.event == "enable" {
|
||||||
line.level += 1
|
line.level += 1
|
||||||
entry.push(evt.lifeline-style)
|
entry.insert("style", evt.lifeline-style)
|
||||||
} else if evt.event == "create" {
|
} else if evt.event == "create" {
|
||||||
ctx.y -= CREATE-OFFSET
|
ctx.y -= CREATE-OFFSET
|
||||||
entry.at(1) = ctx.y
|
entry.y = ctx.y
|
||||||
(par.draw)(par, y: ctx.y)
|
(par.draw)(par, y: ctx.y)
|
||||||
} else if evt.event == "destroy" {
|
} else if evt.event == "destroy" {
|
||||||
} else {
|
} else {
|
||||||
panic("Unknown event '" + evt.event + "'")
|
panic("Unknown event '" + evt.event + "'")
|
||||||
}
|
}
|
||||||
|
|
||||||
line.lines.push(entry)
|
line.events.push(entry)
|
||||||
set-ctx(c => {
|
set-ctx(c => {
|
||||||
c.lifelines.at(i) = line
|
c.lifelines.at(i) = line
|
||||||
c.y = ctx.y
|
c.y = ctx.y
|
||||||
|
@ -318,59 +318,54 @@
|
|||||||
|
|
||||||
let rects = ()
|
let rects = ()
|
||||||
let destructions = ()
|
let destructions = ()
|
||||||
let lines = ()
|
let stack = ()
|
||||||
|
|
||||||
// Compute lifeline rectangles + destruction positions
|
// Compute lifeline rectangles + destruction positions
|
||||||
for line in ctx.lifelines.at(p.i).lines {
|
for event in ctx.lifelines.at(p.i).events {
|
||||||
let event = line.first()
|
if event.type == "create" {
|
||||||
if event == "create" {
|
|
||||||
last-y = line.at(1)
|
last-y = line.at(1)
|
||||||
|
|
||||||
} else if event == "enable" {
|
} else if event.type == "enable" {
|
||||||
if lines.len() == 0 {
|
if stack.len() == 0 {
|
||||||
draw.line(
|
draw.line(
|
||||||
(x, last-y),
|
(x, last-y),
|
||||||
(x, line.at(1)),
|
(x, event.y),
|
||||||
stroke: p.line-stroke
|
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
|
let lvl = 0
|
||||||
if lines.len() != 0 {
|
if stack.len() != 0 {
|
||||||
let l = lines.pop()
|
let e = stack.pop()
|
||||||
lvl = lines.len()
|
lvl = stack.len()
|
||||||
rects.push((
|
rects.push((
|
||||||
x + lvl * LIFELINE-W / 2,
|
x + lvl * LIFELINE-W / 2,
|
||||||
l.at(1),
|
e.y,
|
||||||
line.at(1),
|
event.y,
|
||||||
l.at(2)
|
e.style
|
||||||
))
|
))
|
||||||
last-y = line.at(1)
|
last-y = event.y
|
||||||
}
|
}
|
||||||
|
|
||||||
if event == "destroy" {
|
if event.type == "destroy" {
|
||||||
destructions.push((x + lvl * LIFELINE-W / 2, line.at(1)))
|
destructions.push((x + lvl * LIFELINE-W / 2, event.y))
|
||||||
}
|
}
|
||||||
} else if event == "delay-start" {
|
} else if event.type == "delay-start" {
|
||||||
draw.line(
|
draw.line(
|
||||||
(x, last-y),
|
(x, last-y),
|
||||||
(x, line.at(1)),
|
(x, event.y),
|
||||||
stroke: p.line-stroke
|
stroke: p.line-stroke
|
||||||
)
|
)
|
||||||
last-y = line.at(1)
|
last-y = event.y
|
||||||
} else if event == "delay-end" {
|
} else if event.type == "delay-end" {
|
||||||
draw.line(
|
draw.line(
|
||||||
(x, last-y),
|
(x, last-y),
|
||||||
(x, line.at(1)),
|
(x, event.y),
|
||||||
stroke: (
|
stroke: event.stroke
|
||||||
dash: "loosely-dotted",
|
|
||||||
paint: gray.darken(40%),
|
|
||||||
thickness: .8pt
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
last-y = line.at(1)
|
last-y = event.y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,23 +102,23 @@
|
|||||||
if seq.disable-src {
|
if seq.disable-src {
|
||||||
let src-line = ctx.lifelines.at(i1)
|
let src-line = ctx.lifelines.at(i1)
|
||||||
src-line.level -= 1
|
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
|
ctx.lifelines.at(i1) = src-line
|
||||||
}
|
}
|
||||||
if seq.destroy-src {
|
if seq.destroy-src {
|
||||||
let src-line = ctx.lifelines.at(i1)
|
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
|
ctx.lifelines.at(i1) = src-line
|
||||||
}
|
}
|
||||||
if seq.disable-dst {
|
if seq.disable-dst {
|
||||||
let dst-line = ctx.lifelines.at(i2)
|
let dst-line = ctx.lifelines.at(i2)
|
||||||
dst-line.level -= 1
|
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
|
ctx.lifelines.at(i2) = dst-line
|
||||||
}
|
}
|
||||||
if seq.destroy-dst {
|
if seq.destroy-dst {
|
||||||
let dst-line = ctx.lifelines.at(i2)
|
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
|
ctx.lifelines.at(i2) = dst-line
|
||||||
}
|
}
|
||||||
if seq.enable-dst {
|
if seq.enable-dst {
|
||||||
@ -341,12 +341,12 @@
|
|||||||
|
|
||||||
if seq.create-dst {
|
if seq.create-dst {
|
||||||
let dst-line = ctx.lifelines.at(i2)
|
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
|
ctx.lifelines.at(i2) = dst-line
|
||||||
}
|
}
|
||||||
if seq.enable-dst {
|
if seq.enable-dst {
|
||||||
let dst-line = ctx.lifelines.at(i2)
|
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
|
ctx.lifelines.at(i2) = dst-line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@
|
|||||||
groups: (),
|
groups: (),
|
||||||
lifelines: participants.map(_ => (
|
lifelines: participants.map(_ => (
|
||||||
level: 0,
|
level: 0,
|
||||||
lines: ()
|
events: ()
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
chronos-ctx.insert(
|
chronos-ctx.insert(
|
||||||
|
Reference in New Issue
Block a user