Compare commits

..

No commits in common. "ff6a7e52bc305b6b831805fff5e17e62741d2b94" and "3b25d68f1eb922c04e41595fc18659168e179d01" have entirely different histories.

7 changed files with 23 additions and 131 deletions

Binary file not shown.

View File

@ -48,63 +48,4 @@
_seq("Alice", "]", comment: [->\]\ from actor1 *to end*]) _seq("Alice", "]", comment: [->\]\ from actor1 *to end*])
_seq("Alice", "?", comment: [->?\ *short* from actor1]) _seq("Alice", "?", comment: [->?\ *short* from actor1])
_seq("Alice", "Bob", comment: [->\ from actor1 to actor2]) _seq("Alice", "Bob", comment: [->\ from actor1 to actor2])
})
#chronos.diagram({
import chronos: *
_par("alice", display-name: "Alice")
_par("bob", display-name: "Bob")
_par("craig", display-name: "Craig")
_seq("bob", "alice")
_seq("bob", "craig")
_gap()
_sync({
_seq("bob", "alice")
_seq("bob", "craig")
})
_gap()
_seq("alice", "bob")
_seq("craig", "bob")
_gap()
_sync({
_seq("alice", "bob")
_seq("craig", "bob")
})
_gap()
_sync({
_seq("alice", "bob", enable-dst: true)
_seq("craig", "bob")
})
_gap()
_evt("bob", "disable")
})
#chronos.diagram({
import chronos: *
_par("alice", display-name: "Alice")
_par("bob", display-name: "Bob")
_par("craig", display-name: "Craig")
_seq("alice", "bob")
_seq("bob", "craig", slant: auto)
_seq("alice", "craig", slant: 20)
_sync({
_seq("alice", "bob", slant: 10)
_seq("craig", "bob", slant: 20)
})
_sync({
_seq("alice", "bob", slant: auto)
_seq("bob", "alice", slant: auto)
})
_gap()
_evt("bob", "disable")
}) })

View File

@ -3,7 +3,6 @@
#let COMMENT-PAD = 8 #let COMMENT-PAD = 8
#let LIFELINE-W = 10 #let LIFELINE-W = 10
#let CREATE-OFFSET = 15 #let CREATE-OFFSET = 15
#let DEFAULT-SLANT = 10
#let SYM-GAP = 5 #let SYM-GAP = 5
#let PAR-PAD = (5pt, 3pt) #let PAR-PAD = (5pt, 3pt)

View File

@ -4,5 +4,4 @@
#import "group.typ": _grp #import "group.typ": _grp
#import "participant.typ": _par #import "participant.typ": _par
#import "separator.typ": _sep #import "separator.typ": _sep
#import "note.typ": _note #import "note.typ": _note
#import "sync.typ": _sync

View File

@ -5,7 +5,6 @@
#import participant: PAR-SPECIALS #import participant: PAR-SPECIALS
#import "sequence.typ" #import "sequence.typ"
#import "separator.typ" #import "separator.typ"
#import "sync.typ"
#import "consts.typ": * #import "consts.typ": *
#import "note.typ" as note: get-note-box #import "note.typ" as note: get-note-box
@ -204,7 +203,6 @@
let draw-sep = separator.render.with(x-pos) let draw-sep = separator.render.with(x-pos)
let draw-par = participant.render.with(x-pos) let draw-par = participant.render.with(x-pos)
let draw-note = note.render.with(pars-i, x-pos) let draw-note = note.render.with(pars-i, x-pos)
let draw-sync = sync.render.with(pars-i, x-pos, participants)
// Draw participants (start) // Draw participants (start)
for p in participants { for p in participants {
@ -297,12 +295,6 @@
(y, shps) = draw-note(elmt, y, lifelines) (y, shps) = draw-note(elmt, y, lifelines)
shapes += shps shapes += shps
} }
// Synched sequences
} else if elmt.type == "sync" {
let shps
(y, lifelines, shps) = draw-sync(elmt, y, lifelines)
shapes += shps
} }
} }

View File

@ -35,8 +35,7 @@
destroy-dst: false, destroy-dst: false,
disable-src: false, disable-src: false,
destroy-src: false, destroy-src: false,
lifeline-style: auto, lifeline-style: auto
slant: none
) = { ) = {
return (( return ((
type: "seq", type: "seq",
@ -55,7 +54,6 @@
disable-src: disable-src, disable-src: disable-src,
destroy-src: destroy-src, destroy-src: destroy-src,
lifeline-style: lifeline-style, lifeline-style: lifeline-style,
slant: slant
),) ),)
} }
@ -89,38 +87,27 @@
y: y, y: y,
ll-lvl: lifelines.at(i2).level * LIFELINE-W / 2 ll-lvl: lifelines.at(i2).level * LIFELINE-W / 2
) )
let slant = if elmt.slant == auto {
DEFAULT-SLANT
} else if elmt.slant != none {
elmt.slant
} else {
0
}
end-info.y -= slant
if elmt.p1 == elmt.p2 {
end-info.y -= 10
}
if elmt.disable-src { if elmt.disable-src {
let src-line = lifelines.at(i1) let src-line = lifelines.at(i1)
src-line.level -= 1 src-line.level -= 1
src-line.lines.push(("disable", start-info.y)) src-line.lines.push(("disable", y))
lifelines.at(i1) = src-line lifelines.at(i1) = src-line
} }
if elmt.destroy-src { if elmt.destroy-src {
let src-line = lifelines.at(i1) let src-line = lifelines.at(i1)
src-line.lines.push(("destroy", start-info.y)) src-line.lines.push(("destroy", y))
lifelines.at(i1) = src-line lifelines.at(i1) = src-line
} }
if elmt.disable-dst { if elmt.disable-dst {
let dst-line = lifelines.at(i2) let dst-line = lifelines.at(i2)
dst-line.level -= 1 dst-line.level -= 1
dst-line.lines.push(("disable", end-info.y)) dst-line.lines.push(("disable", y))
lifelines.at(i2) = dst-line lifelines.at(i2) = dst-line
} }
if elmt.destroy-dst { if elmt.destroy-dst {
let dst-line = lifelines.at(i2) let dst-line = lifelines.at(i2)
dst-line.lines.push(("destroy", end-info.y)) dst-line.lines.push(("destroy", y))
lifelines.at(i2) = dst-line lifelines.at(i2) = dst-line
} }
if elmt.enable-dst { if elmt.enable-dst {
@ -133,7 +120,7 @@
let m = measure(box(par.display-name)) let m = measure(box(par.display-name))
let f = if i1 > i2 {-1} else {1} let f = if i1 > i2 {-1} else {1}
end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f
shapes += participant.render(x-pos, par, y: end-info.y - CREATE-OFFSET) shapes += participant.render(x-pos, par, y: y - CREATE-OFFSET)
} }
end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2 end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2
@ -169,9 +156,9 @@
) )
) )
let y0 = start-info.y let y0 = y
if "linked-note" in elmt { if "linked-note" in elmt {
let shps = note.render(pars-i, x-pos, elmt.linked-note, start-info.y, lifelines).last() let shps = note.render(pars-i, x-pos, elmt.linked-note, y, lifelines).last()
shapes += shps shapes += shps
} }
@ -190,7 +177,7 @@
if elmt.comment != none { if elmt.comment != none {
shapes += draw.content( shapes += draw.content(
(x1, start-info.y), (x1, y),
elmt.comment, elmt.comment,
anchor: if elmt.flip {"south-east"} else {"south-west"}, anchor: if elmt.flip {"south-east"} else {"south-west"},
padding: 3pt padding: 3pt
@ -198,12 +185,13 @@
} }
shapes += draw.line( shapes += draw.line(
(x1, start-info.y), (x1, y),
(x-mid, start-info.y), (x-mid, y),
(x-mid, end-info.y), (x-mid, y - 10),
(x2, end-info.y), (x2, y - 10),
..style ..style
) )
y -= 10
} else { } else {
if elmt.comment != none { if elmt.comment != none {
@ -212,7 +200,7 @@
x += COMMENT-PAD x += COMMENT-PAD
} }
shapes += draw.content( shapes += draw.content(
(x, start-info.y), (x, y),
elmt.comment, elmt.comment,
anchor: "south-west", anchor: "south-west",
padding: 3pt padding: 3pt
@ -220,28 +208,28 @@
} }
shapes += draw.line( shapes += draw.line(
(x1, start-info.y), (x1, y),
(x2, end-info.y), (x2, y),
..style ..style
) )
} }
if elmt.enable-dst { if elmt.enable-dst {
let dst-line = lifelines.at(i2) let dst-line = lifelines.at(i2)
dst-line.lines.push(("enable", end-info.y, elmt.lifeline-style)) dst-line.lines.push(("enable", y, elmt.lifeline-style))
lifelines.at(i2) = dst-line lifelines.at(i2) = dst-line
} }
if elmt.create-dst { if elmt.create-dst {
end-info.y -= CREATE-OFFSET y -= CREATE-OFFSET
let dst-line = lifelines.at(i2) let dst-line = lifelines.at(i2)
dst-line.lines.push(("create", end-info.y)) dst-line.lines.push(("create", y))
lifelines.at(i2) = dst-line lifelines.at(i2) = dst-line
} }
if "linked-note" in elmt { if "linked-note" in elmt {
let m = note.get-size(elmt.linked-note) let m = note.get-size(elmt.linked-note)
end-info.y = calc.min(end-info.y, y0 - m.height / 2) y = calc.min(y, y0 - m.height / 2)
} }
let r = (end-info.y, lifelines, shapes) let r = (y, lifelines, shapes)
return r return r
} }

View File

@ -1,27 +0,0 @@
#import "sequence.typ"
#let _sync(elmts) = {
return ((
type: "sync",
elmts: elmts
),)
}
#let render(pars-i, x-pos, participants, elmt, y, lifelines) = {
let draw-seq = sequence.render.with(pars-i, x-pos, participants)
let shapes = ()
let end-y = y
for e in elmt.elmts {
let yi
let shps
(yi, lifelines, shps) = draw-seq(e, y, lifelines)
shapes += shps
end-y = calc.min(end-y, yi)
}
let r = (end-y, lifelines, shapes)
return r
}