Compare commits
12 Commits
ef2541f267
...
dev
Author | SHA1 | Date | |
---|---|---|---|
aca2d858fe
|
|||
6c97bb807f | |||
f812ac93c2
|
|||
caad9ed823
|
|||
0b401df67d
|
|||
8ee14167de
|
|||
1f24ba8efe
|
|||
03138269f9 | |||
90d97a9ae5
|
|||
7106cc3e22
|
|||
d51a08830d
|
|||
08f7eea0e4
|
@ -5,13 +5,15 @@
|
|||||||
/// - color (color): The note's color
|
/// - color (color): The note's color
|
||||||
/// - shape (str): The note's shape (see @@SHAPES for accepted values)
|
/// - shape (str): The note's shape (see @@SHAPES for accepted values)
|
||||||
/// - aligned (bool): True if the note is aligned with another note, in which case `side` must be `"over"`, false otherwise
|
/// - aligned (bool): True if the note is aligned with another note, in which case `side` must be `"over"`, false otherwise
|
||||||
|
/// - allow-overlap (bool): If set to `false`, the note will try to reserve space in the column to avoid overlapping with neighboring participants. If set to `true`, the not will overlap other participants
|
||||||
#let _note(
|
#let _note(
|
||||||
side,
|
side,
|
||||||
content,
|
content,
|
||||||
pos: none,
|
pos: none,
|
||||||
color: rgb("#FEFFDD"),
|
color: rgb("#FEFFDD"),
|
||||||
shape: "default",
|
shape: "default",
|
||||||
aligned: false
|
aligned: false,
|
||||||
|
allow-overlap: true
|
||||||
) = {}
|
) = {}
|
||||||
|
|
||||||
/// Accepted values for `shape` argument of @@_note()
|
/// Accepted values for `shape` argument of @@_note()
|
||||||
|
BIN
manual.pdf
@ -1 +1 @@
|
|||||||
#import "@preview/cetz:0.3.4": *
|
#import "@preview/cetz:0.4.0": *
|
@ -1,5 +1,6 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx
|
#import "/src/cetz.typ": draw
|
||||||
#import "../../cetz.typ": draw
|
|
||||||
|
#import "/src/core/utils.typ": get-ctx, set-ctx
|
||||||
|
|
||||||
#let render(delay) = get-ctx(ctx => {
|
#let render(delay) = get-ctx(ctx => {
|
||||||
let y0 = ctx.y
|
let y0 = ctx.y
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx
|
#import "/src/consts.typ": *
|
||||||
#import "../../consts.typ": *
|
#import "/src/core/utils.typ": get-ctx, set-ctx
|
||||||
|
|
||||||
#let render(evt) = get-ctx(ctx => {
|
#let render(evt) = get-ctx(ctx => {
|
||||||
let par-name = evt.participant
|
let par-name = evt.participant
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx
|
#import "/src/cetz.typ": draw
|
||||||
#import "../../consts.typ": *
|
|
||||||
#import "../../cetz.typ": draw
|
#import "/src/consts.typ": *
|
||||||
|
#import "/src/core/utils.typ": get-ctx, set-ctx, expand-parent-group
|
||||||
|
|
||||||
#let render-start(grp) = get-ctx(ctx => {
|
#let render-start(grp) = get-ctx(ctx => {
|
||||||
let grp = grp
|
let grp = grp
|
||||||
@ -17,14 +18,21 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
ctx.groups = ctx.groups.map(g => {
|
ctx.groups = ctx.groups.map(g => {
|
||||||
if g.at(1).min-i == grp.min-i { g.at(2) += 1 }
|
if g.group.min-i == grp.min-i { g.start-lvl += 1 }
|
||||||
if g.at(1).max-i == grp.max-i { g.at(3) += 1 }
|
if g.group.max-i == grp.max-i { g.end-lvl += 1 }
|
||||||
g
|
g
|
||||||
})
|
})
|
||||||
if grp.grp-type == "alt" {
|
if grp.grp-type == "alt" {
|
||||||
grp.insert("elses", ())
|
grp.insert("elses", ())
|
||||||
}
|
}
|
||||||
ctx.groups.push((ctx.y, grp, 0, 0))
|
ctx.groups.push((
|
||||||
|
start-y: ctx.y,
|
||||||
|
group: grp,
|
||||||
|
start-lvl: 0,
|
||||||
|
end-lvl: 0,
|
||||||
|
min-x: ctx.x-pos.at(grp.min-i) - 10,
|
||||||
|
max-x: ctx.x-pos.at(grp.max-i) + 10
|
||||||
|
))
|
||||||
ctx.y -= m.height / 1pt
|
ctx.y -= m.height / 1pt
|
||||||
|
|
||||||
set-ctx(c => {
|
set-ctx(c => {
|
||||||
@ -44,18 +52,14 @@
|
|||||||
(x0, y0),
|
(x0, y0),
|
||||||
(x1, y1)
|
(x1, y1)
|
||||||
)
|
)
|
||||||
draw.merge-path(
|
draw.line(
|
||||||
|
(x0, y0),
|
||||||
|
(x0 + w, y0),
|
||||||
|
(x0 + w, y0 - h / 2),
|
||||||
|
(x0 + w - 5, y0 - h),
|
||||||
|
(x0, y0 - h),
|
||||||
fill: COL-GRP-NAME,
|
fill: COL-GRP-NAME,
|
||||||
close: true,
|
close: true
|
||||||
{
|
|
||||||
draw.line(
|
|
||||||
(x0, y0),
|
|
||||||
(x0 + w, y0),
|
|
||||||
(x0 + w, y0 - h / 2),
|
|
||||||
(x0 + w - 5, y0 - h),
|
|
||||||
(x0, y0 - h)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
draw.content(
|
draw.content(
|
||||||
(x0, y0),
|
(x0, y0),
|
||||||
@ -90,9 +94,16 @@
|
|||||||
|
|
||||||
#let render-end(group) = get-ctx(ctx => {
|
#let render-end(group) = get-ctx(ctx => {
|
||||||
ctx.y -= Y-SPACE
|
ctx.y -= Y-SPACE
|
||||||
let (start-y, group, start-lvl, end-lvl) = ctx.groups.pop()
|
let (
|
||||||
let x0 = ctx.x-pos.at(group.min-i) - start-lvl * 10 - 20
|
start-y,
|
||||||
let x1 = ctx.x-pos.at(group.max-i) + end-lvl * 10 + 20
|
group,
|
||||||
|
start-lvl,
|
||||||
|
end-lvl,
|
||||||
|
min-x,
|
||||||
|
max-x
|
||||||
|
) = ctx.groups.pop()
|
||||||
|
let x0 = min-x - 10
|
||||||
|
let x1 = max-x + 10
|
||||||
|
|
||||||
draw-group(x0, x1, start-y, ctx.y, group)
|
draw-group(x0, x1, start-y, ctx.y, group)
|
||||||
|
|
||||||
@ -107,12 +118,14 @@
|
|||||||
c.groups = ctx.groups
|
c.groups = ctx.groups
|
||||||
return c
|
return c
|
||||||
})
|
})
|
||||||
|
|
||||||
|
expand-parent-group(x0, x1)
|
||||||
})
|
})
|
||||||
|
|
||||||
#let render-else(else_) = set-ctx(ctx => {
|
#let render-else(else_) = set-ctx(ctx => {
|
||||||
ctx.y -= Y-SPACE
|
ctx.y -= Y-SPACE
|
||||||
let m = measure(text([\[#else_.desc\]], weight: "bold", size: .8em))
|
let m = measure(text([\[#else_.desc\]], weight: "bold", size: .8em))
|
||||||
ctx.groups.last().at(1).elses.push((
|
ctx.groups.last().group.elses.push((
|
||||||
ctx.y, else_
|
ctx.y, else_
|
||||||
))
|
))
|
||||||
ctx.y -= m.height / 1pt
|
ctx.y -= m.height / 1pt
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#import "../../consts.typ": *
|
#import "/src/cetz.typ": draw
|
||||||
#import "../utils.typ": get-ctx, set-ctx
|
|
||||||
#import "../../cetz.typ": draw
|
#import "/src/consts.typ": *
|
||||||
|
#import "/src/core/utils.typ": get-ctx, set-ctx, expand-parent-group
|
||||||
|
|
||||||
#let get-size(note) = {
|
#let get-size(note) = {
|
||||||
let PAD = if note.shape == "hex" {NOTE-HEX-PAD} else {NOTE-PAD}
|
let PAD = if note.shape == "hex" {NOTE-HEX-PAD} else {NOTE-PAD}
|
||||||
@ -48,10 +49,6 @@
|
|||||||
return box(note.content, inset: inset)
|
return box(note.content, inset: inset)
|
||||||
}
|
}
|
||||||
|
|
||||||
#let pre-render(note) = {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#let render(note, y: auto, forced: false) = {
|
#let render(note, y: auto, forced: false) = {
|
||||||
if not note.linked {
|
if not note.linked {
|
||||||
if not note.aligned {
|
if not note.aligned {
|
||||||
@ -110,21 +107,22 @@
|
|||||||
let y1 = y0 - h
|
let y1 = y0 - h
|
||||||
|
|
||||||
if note.shape == "default" {
|
if note.shape == "default" {
|
||||||
draw.merge-path(
|
draw.line(
|
||||||
|
(x0, y0),
|
||||||
|
(x1, y0),
|
||||||
|
(x2, y0 - NOTE-CORNER-SIZE),
|
||||||
|
(x2, y1),
|
||||||
|
(x0, y1),
|
||||||
stroke: black + .5pt,
|
stroke: black + .5pt,
|
||||||
fill: note.color,
|
fill: note.color,
|
||||||
close: true,
|
close: true
|
||||||
{
|
)
|
||||||
draw.line(
|
draw.line(
|
||||||
(x0, y0),
|
(x1, y0),
|
||||||
(x1, y0),
|
(x1, y0 - NOTE-CORNER-SIZE),
|
||||||
(x2, y0 - NOTE-CORNER-SIZE),
|
(x2, y0 - NOTE-CORNER-SIZE),
|
||||||
(x2, y1),
|
stroke: black + .5pt
|
||||||
(x0, y1)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
draw.line((x1, y0), (x1, y0 - NOTE-CORNER-SIZE), (x2, y0 - NOTE-CORNER-SIZE), stroke: black + .5pt)
|
|
||||||
} else if note.shape == "rect" {
|
} else if note.shape == "rect" {
|
||||||
draw.rect(
|
draw.rect(
|
||||||
(x0, y0),
|
(x0, y0),
|
||||||
@ -136,20 +134,16 @@
|
|||||||
let lx = x0 + PAD.last()
|
let lx = x0 + PAD.last()
|
||||||
let rx = x2 - PAD.last()
|
let rx = x2 - PAD.last()
|
||||||
let my = (y0 + y1) / 2
|
let my = (y0 + y1) / 2
|
||||||
draw.merge-path(
|
draw.line(
|
||||||
|
(lx, y0),
|
||||||
|
(rx, y0),
|
||||||
|
(x2, my),
|
||||||
|
(rx, y1),
|
||||||
|
(lx, y1),
|
||||||
|
(x0, my),
|
||||||
stroke: black + .5pt,
|
stroke: black + .5pt,
|
||||||
fill: note.color,
|
fill: note.color,
|
||||||
close: true,
|
close: true
|
||||||
{
|
|
||||||
draw.line(
|
|
||||||
(lx, y0),
|
|
||||||
(rx, y0),
|
|
||||||
(x2, my),
|
|
||||||
(rx, y1),
|
|
||||||
(lx, y1),
|
|
||||||
(x0, my),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,5 +159,7 @@
|
|||||||
return c
|
return c
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expand-parent-group(x0, x2)
|
||||||
})
|
})
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
#import "../../consts.typ": *
|
#import "/src/cetz.typ": draw
|
||||||
#import "../../cetz.typ": draw
|
|
||||||
#import "../utils.typ": get-ctx, set-ctx, get-style
|
#import "/src/consts.typ": *
|
||||||
|
#import "/src/core/utils.typ": get-ctx, get-style, set-ctx
|
||||||
|
|
||||||
#let get-size(par) = {
|
#let get-size(par) = {
|
||||||
if par.invisible {
|
if par.invisible {
|
||||||
@ -80,7 +81,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +109,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +127,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +150,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +183,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +287,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
(x, y),
|
(x, y),
|
||||||
p.display-name,
|
p.display-name,
|
||||||
anchor: if bottom {"north"} else {"south"}
|
anchor: if bottom {"north"} else {"base"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx
|
#import "/src/cetz.typ": draw
|
||||||
#import "../../consts.typ": *
|
|
||||||
#import "../../cetz.typ": draw
|
#import "/src/consts.typ": *
|
||||||
|
#import "/src/core/utils.typ": get-ctx, set-ctx
|
||||||
|
|
||||||
#let render(sep) = get-ctx(ctx => {
|
#let render(sep) = get-ctx(ctx => {
|
||||||
ctx.y -= Y-SPACE
|
ctx.y -= Y-SPACE
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx
|
#import "/src/cetz.typ": draw, vector
|
||||||
#import "../../consts.typ": *
|
|
||||||
#import "../../cetz.typ": draw, vector
|
|
||||||
#import "note.typ"
|
|
||||||
|
|
||||||
|
#import "note.typ"
|
||||||
|
#import "/src/consts.typ": *
|
||||||
|
#import "/src/core/utils.typ": get-ctx, set-ctx
|
||||||
|
|
||||||
#let get-arrow-marks(sym, color) = {
|
#let get-arrow-marks(sym, color) = {
|
||||||
if sym == none {
|
if sym == none {
|
||||||
@ -15,10 +15,10 @@
|
|||||||
"": none,
|
"": none,
|
||||||
">": (symbol: ">", fill: color),
|
">": (symbol: ">", fill: color),
|
||||||
">>": (symbol: "straight"),
|
">>": (symbol: "straight"),
|
||||||
"\\": (symbol: ">", fill: color, harpoon: true, flip: true),
|
"\\": (symbol: ">", fill: color, harpoon: true),
|
||||||
"\\\\": (symbol: "straight", harpoon: true, flip: true),
|
"\\\\": (symbol: "straight", harpoon: true),
|
||||||
"/": (symbol: ">", fill: color, harpoon: true),
|
"/": (symbol: ">", fill: color, harpoon: true, flip: true),
|
||||||
"//": (symbol: "straight", harpoon: true),
|
"//": (symbol: "straight", harpoon: true, flip: true),
|
||||||
"x": none,
|
"x": none,
|
||||||
"o": none,
|
"o": none,
|
||||||
).at(sym)
|
).at(sym)
|
||||||
@ -67,9 +67,12 @@
|
|||||||
if comment != none {
|
if comment != none {
|
||||||
h = calc.max(h, measure(comment).height / 1pt + 6)
|
h = calc.max(h, measure(comment).height / 1pt + 6)
|
||||||
}
|
}
|
||||||
if "linked-note" in seq {
|
h = calc.max(
|
||||||
h = calc.max(h, note.get-size(seq.linked-note).height / 2)
|
h,
|
||||||
}
|
..seq.linked-notes.map(n => {
|
||||||
|
note.get-size(n).height / 2
|
||||||
|
})
|
||||||
|
)
|
||||||
ctx.y -= h
|
ctx.y -= h
|
||||||
|
|
||||||
let start-info = (
|
let start-info = (
|
||||||
@ -165,9 +168,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
let y0 = start-info.y
|
let y0 = start-info.y
|
||||||
if "linked-note" in seq {
|
for n in seq.linked-notes {
|
||||||
// TODO: adapt note.render
|
(n.draw)(n, y: start-info.y, forced: true)
|
||||||
(seq.linked-note.draw)(seq.linked-note, y: start-info.y, forced: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let flip-mark = end-info.i <= start-info.i
|
let flip-mark = end-info.i <= start-info.i
|
||||||
@ -348,9 +350,14 @@
|
|||||||
ctx.lifelines.at(i2) = dst-line
|
ctx.lifelines.at(i2) = dst-line
|
||||||
}
|
}
|
||||||
|
|
||||||
if "linked-note" in seq {
|
if seq.linked-notes.len() != 0 {
|
||||||
let m = note.get-size(seq.linked-note)
|
end-info.y = calc.min(
|
||||||
end-info.y = calc.min(end-info.y, y0 - m.height / 2)
|
end-info.y,
|
||||||
|
y0 - calc.max(..seq.linked-notes.map(n => {
|
||||||
|
let m = note.get-size(n)
|
||||||
|
return m.height / 2
|
||||||
|
}))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
set-ctx(c => {
|
set-ctx(c => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#import "../utils.typ": get-ctx, set-ctx, is-elmt
|
#import "/src/core/utils.typ": get-ctx, is-elmt, set-ctx
|
||||||
|
|
||||||
#let render(sync) = get-ctx(ctx => {
|
#let render(sync) = get-ctx(ctx => {
|
||||||
set-ctx(c => {
|
set-ctx(c => {
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
#import "/src/cetz.typ" as cetz: canvas, draw
|
#import "/src/cetz.typ": canvas, draw
|
||||||
#import "utils.typ": *
|
|
||||||
#import "../group.typ"
|
|
||||||
//#import "../participant.typ"
|
|
||||||
//#import participant: PAR-SPECIALS
|
|
||||||
#import "draw/participant.typ"
|
|
||||||
#import "../sequence.typ"
|
|
||||||
#import "../separator.typ"
|
|
||||||
#import "../sync.typ"
|
|
||||||
#import "../consts.typ": *
|
|
||||||
#import "draw/note.typ": get-box as get-note-box, get-size as get-note-size
|
#import "draw/note.typ": get-box as get-note-box, get-size as get-note-size
|
||||||
|
#import "draw/participant.typ"
|
||||||
|
#import "utils.typ": *
|
||||||
|
#import "/src/consts.typ": *
|
||||||
|
|
||||||
#let DEBUG-INVISIBLE = false
|
#let DEBUG-INVISIBLE = false
|
||||||
|
|
||||||
@ -87,12 +82,12 @@
|
|||||||
let (p1, p2) = (none, none)
|
let (p1, p2) = (none, none)
|
||||||
let cell = none
|
let cell = none
|
||||||
if note.side == "left" {
|
if note.side == "left" {
|
||||||
p1 = "["
|
p1 = note.pos2
|
||||||
p2 = note.pos
|
p2 = note.pos
|
||||||
cell = get-note-box(note)
|
cell = get-note-box(note)
|
||||||
} else if note.side == "right" {
|
} else if note.side == "right" {
|
||||||
p1 = note.pos
|
p1 = note.pos
|
||||||
p2 = "]"
|
p2 = note.pos2
|
||||||
cell = get-note-box(note)
|
cell = get-note-box(note)
|
||||||
} else if note.side == "over" and note.aligned-with != none {
|
} else if note.side == "over" and note.aligned-with != none {
|
||||||
let box1 = get-note-box(note)
|
let box1 = get-note-box(note)
|
||||||
@ -225,7 +220,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Compute remaining widths for longer sequences (spanning multiple columns)
|
/// Compute remaining widths for longer sequences (spanning multiple columns)
|
||||||
#let long-seq-min-col-widths(cells, widths) = {
|
#let long-seq-min-col-widths(participants, cells, widths) = {
|
||||||
let widths = widths
|
let widths = widths
|
||||||
let multicol-cells = cells.filter(c => c.i2 - c.i1 > 1)
|
let multicol-cells = cells.filter(c => c.i2 - c.i1 > 1)
|
||||||
multicol-cells = multicol-cells.sorted(key: c => {
|
multicol-cells = multicol-cells.sorted(key: c => {
|
||||||
@ -233,13 +228,23 @@
|
|||||||
})
|
})
|
||||||
for cell in multicol-cells {
|
for cell in multicol-cells {
|
||||||
let m = measure(cell.cell)
|
let m = measure(cell.cell)
|
||||||
|
|
||||||
|
let i1 = cell.i1
|
||||||
|
let i2 = cell.i2 - 1
|
||||||
|
let i = i2
|
||||||
|
if cell.i1 == 0 and participants.at(0).name == "[" {
|
||||||
|
i = 0
|
||||||
|
i1 += 1
|
||||||
|
i2 += 1
|
||||||
|
}
|
||||||
let width = (
|
let width = (
|
||||||
m.width / 1pt +
|
m.width / 1pt +
|
||||||
COMMENT-PAD -
|
COMMENT-PAD -
|
||||||
widths.slice(cell.i1, cell.i2 - 1).sum()
|
widths.slice(i1, i2).sum()
|
||||||
)
|
)
|
||||||
widths.at(cell.i2 - 1) = calc.max(
|
|
||||||
widths.at(cell.i2 - 1), width
|
widths.at(i) = calc.max(
|
||||||
|
widths.at(i), width
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return widths
|
return widths
|
||||||
@ -312,7 +317,7 @@
|
|||||||
widths = notes-min-col-widths(elements, widths, pars-i)
|
widths = notes-min-col-widths(elements, widths, pars-i)
|
||||||
widths = simple-seq-min-col-widths(cells, widths)
|
widths = simple-seq-min-col-widths(cells, widths)
|
||||||
widths = self-seq-min-col-widths(cells, widths)
|
widths = self-seq-min-col-widths(cells, widths)
|
||||||
widths = long-seq-min-col-widths(cells, widths)
|
widths = long-seq-min-col-widths(participants, cells, widths)
|
||||||
widths = col-widths-add-lifelines(participants, widths)
|
widths = col-widths-add-lifelines(participants, widths)
|
||||||
widths = process-col-elements(elements, widths, pars-i)
|
widths = process-col-elements(elements, widths, pars-i)
|
||||||
return widths
|
return widths
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#import "utils.typ": is-elmt, get-group-span
|
|
||||||
#import "../participant.typ": _exists as par-exists, _par
|
|
||||||
#import "draw/group.typ": render-end as grp-render-end
|
#import "draw/group.typ": render-end as grp-render-end
|
||||||
|
#import "utils.typ": get-group-span, is-elmt
|
||||||
|
#import "/src/participant.typ": _exists as par-exists, _par
|
||||||
|
#import "/src/sequence.typ": _seq
|
||||||
|
|
||||||
#let flatten-group(elmts, i) = {
|
#let flatten-group(elmts, i) = {
|
||||||
let group = elmts.at(i)
|
let group = elmts.at(i)
|
||||||
@ -125,8 +126,8 @@
|
|||||||
"linked",
|
"linked",
|
||||||
note.pos == none and note.side != "across"
|
note.pos == none and note.side != "across"
|
||||||
)
|
)
|
||||||
|
let names = ctx.participants.map(p => p.name)
|
||||||
if note.pos == none and note.side != "across" {
|
if note.pos == none and note.side != "across" {
|
||||||
let names = ctx.participants.map(p => p.name)
|
|
||||||
let i1 = names.position(n => n == ctx.last-seq.p1)
|
let i1 = names.position(n => n == ctx.last-seq.p1)
|
||||||
let i2 = names.position(n => n == ctx.last-seq.p2)
|
let i2 = names.position(n => n == ctx.last-seq.p2)
|
||||||
let pars = (
|
let pars = (
|
||||||
@ -140,8 +141,8 @@
|
|||||||
note.pos = pars.last().last()
|
note.pos = pars.last().last()
|
||||||
}
|
}
|
||||||
|
|
||||||
let seq = ctx.last-seq.seq
|
let seq = ctx.elmts.at(ctx.last-seq.i)
|
||||||
seq.insert("linked-note", note)
|
seq.linked-notes.push(note)
|
||||||
ctx.elmts.at(ctx.last-seq.i) = seq
|
ctx.elmts.at(ctx.last-seq.i) = seq
|
||||||
}
|
}
|
||||||
if note.aligned {
|
if note.aligned {
|
||||||
@ -149,10 +150,26 @@
|
|||||||
n.aligned-with = note
|
n.aligned-with = note
|
||||||
ctx.elmts.at(ctx.last-note.i) = n
|
ctx.elmts.at(ctx.last-note.i) = n
|
||||||
}
|
}
|
||||||
if note.side == "left" {
|
|
||||||
ctx.linked.push("[")
|
if note.side in ("left", "right") {
|
||||||
} else if note.side == "right" {
|
let i = names.position(n => n == note.pos)
|
||||||
ctx.linked.push("]")
|
let pos2 = note.pos
|
||||||
|
if note.side == "left" {
|
||||||
|
if i <= 0 or note.allow-overlap {
|
||||||
|
ctx.linked.push("[")
|
||||||
|
pos2 = "["
|
||||||
|
} else {
|
||||||
|
pos2 = names.at(i - 1)
|
||||||
|
}
|
||||||
|
} else if note.side == "right" {
|
||||||
|
if i >= names.len() - 1 or note.allow-overlap {
|
||||||
|
ctx.linked.push("]")
|
||||||
|
pos2 = "]"
|
||||||
|
} else {
|
||||||
|
pos2 = names.at(i + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
note.insert("pos2", pos2)
|
||||||
}
|
}
|
||||||
|
|
||||||
let pars = none
|
let pars = none
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#import "../cetz.typ": draw
|
#import "/src/cetz.typ": draw
|
||||||
|
|
||||||
#let is-elmt(elmt) = {
|
#let is-elmt(elmt) = {
|
||||||
if type(elmt) != dictionary {
|
if type(elmt) != dictionary {
|
||||||
@ -104,4 +104,14 @@
|
|||||||
#let get-ctx(func) = draw.get-ctx(c => {
|
#let get-ctx(func) = draw.get-ctx(c => {
|
||||||
let ctx = c.shared-state.chronos
|
let ctx = c.shared-state.chronos
|
||||||
func(ctx)
|
func(ctx)
|
||||||
|
})
|
||||||
|
|
||||||
|
#let expand-parent-group(x0, x1) = set-ctx(ctx => {
|
||||||
|
if ctx.groups.len() != 0 {
|
||||||
|
let group = ctx.groups.last()
|
||||||
|
group.min-x = calc.min(group.min-x, x0)
|
||||||
|
group.max-x = calc.max(group.max-x, x1)
|
||||||
|
ctx.groups.last() = group
|
||||||
|
}
|
||||||
|
return ctx
|
||||||
})
|
})
|
@ -1,44 +1,7 @@
|
|||||||
#import "core/utils.typ": fit-canvas, set-ctx
|
|
||||||
#import "core/renderer.typ": render
|
|
||||||
#import "participant.typ" as participant: _par, PAR-SPECIALS
|
|
||||||
#import "sequence.typ": _seq
|
|
||||||
#import "core/draw/event.typ": render as evt-render
|
#import "core/draw/event.typ": render as evt-render
|
||||||
|
#import "core/renderer.typ": render
|
||||||
#import "core/setup.typ": setup
|
#import "core/setup.typ": setup
|
||||||
|
#import "core/utils.typ": fit-canvas, set-ctx
|
||||||
#let gap-render(gap) = set-ctx(ctx => {
|
|
||||||
ctx.y -= gap.size
|
|
||||||
return ctx
|
|
||||||
})
|
|
||||||
|
|
||||||
#let _gap(size: 20) = {
|
|
||||||
return ((
|
|
||||||
type: "gap",
|
|
||||||
draw: gap-render,
|
|
||||||
size: size
|
|
||||||
),)
|
|
||||||
}
|
|
||||||
|
|
||||||
#let _evt(participant, event) = {
|
|
||||||
return ((
|
|
||||||
type: "evt",
|
|
||||||
draw: evt-render,
|
|
||||||
participant: participant,
|
|
||||||
event: event,
|
|
||||||
lifeline-style: auto
|
|
||||||
),)
|
|
||||||
}
|
|
||||||
|
|
||||||
#let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = {
|
|
||||||
return ((
|
|
||||||
type: "col",
|
|
||||||
p1: p1,
|
|
||||||
p2: p2,
|
|
||||||
width: width,
|
|
||||||
margin: margin,
|
|
||||||
min-width: min-width,
|
|
||||||
max-width: max-width
|
|
||||||
),)
|
|
||||||
}
|
|
||||||
|
|
||||||
#let diagram(elements, width: auto) = {
|
#let diagram(elements, width: auto) = {
|
||||||
if elements == none {
|
if elements == none {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#import "/src/cetz.typ": draw
|
|
||||||
#import "consts.typ": *
|
|
||||||
#import "core/draw/group.typ"
|
#import "core/draw/group.typ"
|
||||||
|
|
||||||
#let _grp(name, desc: none, type: "default", elmts) = {
|
#let _grp(name, desc: none, type: "default", elmts) = {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#let version = version(0, 2, 2)
|
#let version = version(0, 2, 2)
|
||||||
#import "diagram.typ": diagram, from-plantuml, _gap, _evt, _col
|
#import "diagram.typ": diagram, from-plantuml
|
||||||
|
|
||||||
#import "sequence.typ": _seq, _ret
|
#import "sequence.typ": _seq, _ret
|
||||||
#import "group.typ": _grp, _loop, _alt, _opt, _break
|
#import "group.typ": _grp, _loop, _alt, _opt, _break
|
||||||
#import "participant.typ": _par
|
#import "participant.typ": _par
|
||||||
#import "separator.typ": _sep, _delay
|
#import "misc.typ": _sep, _delay, _sync, _gap, _evt, _col
|
||||||
#import "note.typ": _note
|
#import "note.typ": _note
|
||||||
#import "sync.typ": _sync
|
|
65
src/misc.typ
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#import "core/draw/delay.typ"
|
||||||
|
#import "core/draw/event.typ": render as evt-render
|
||||||
|
#import "core/draw/separator.typ"
|
||||||
|
#import "core/draw/sync.typ"
|
||||||
|
#import "core/utils.typ": set-ctx
|
||||||
|
|
||||||
|
#let _sep(name) = {
|
||||||
|
return ((
|
||||||
|
type: "sep",
|
||||||
|
draw: separator.render,
|
||||||
|
name: name
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let _delay(name: none, size: 30) = {
|
||||||
|
return ((
|
||||||
|
type: "delay",
|
||||||
|
draw: delay.render,
|
||||||
|
name: name,
|
||||||
|
size: size
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let _sync(elmts) = {
|
||||||
|
return ((
|
||||||
|
type: "sync",
|
||||||
|
draw: sync.render,
|
||||||
|
elmts: elmts
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let gap-render(gap) = set-ctx(ctx => {
|
||||||
|
ctx.y -= gap.size
|
||||||
|
return ctx
|
||||||
|
})
|
||||||
|
|
||||||
|
#let _gap(size: 20) = {
|
||||||
|
return ((
|
||||||
|
type: "gap",
|
||||||
|
draw: gap-render,
|
||||||
|
size: size
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let _evt(participant, event) = {
|
||||||
|
return ((
|
||||||
|
type: "evt",
|
||||||
|
draw: evt-render,
|
||||||
|
participant: participant,
|
||||||
|
event: event,
|
||||||
|
lifeline-style: auto
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = {
|
||||||
|
return ((
|
||||||
|
type: "col",
|
||||||
|
p1: p1,
|
||||||
|
p2: p2,
|
||||||
|
width: width,
|
||||||
|
margin: margin,
|
||||||
|
min-width: min-width,
|
||||||
|
max-width: max-width
|
||||||
|
),)
|
||||||
|
}
|
14
src/note.typ
@ -1,4 +1,3 @@
|
|||||||
#import "/src/cetz.typ": draw
|
|
||||||
#import "consts.typ": *
|
#import "consts.typ": *
|
||||||
#import "core/draw/note.typ"
|
#import "core/draw/note.typ"
|
||||||
|
|
||||||
@ -15,7 +14,15 @@
|
|||||||
"hex"
|
"hex"
|
||||||
)
|
)
|
||||||
|
|
||||||
#let _note(side, content, pos: none, color: COL-NOTE, shape: "default", aligned: false) = {
|
#let _note(
|
||||||
|
side,
|
||||||
|
content,
|
||||||
|
pos: none,
|
||||||
|
color: COL-NOTE,
|
||||||
|
shape: "default",
|
||||||
|
aligned: false,
|
||||||
|
allow-overlap: true
|
||||||
|
) = {
|
||||||
if side == "over" {
|
if side == "over" {
|
||||||
if pos == none {
|
if pos == none {
|
||||||
panic("Pos cannot be none with side 'over'")
|
panic("Pos cannot be none with side 'over'")
|
||||||
@ -38,6 +45,7 @@
|
|||||||
color: color,
|
color: color,
|
||||||
shape: shape,
|
shape: shape,
|
||||||
aligned: aligned,
|
aligned: aligned,
|
||||||
aligned-with: none
|
aligned-with: none,
|
||||||
|
allow-overlap: allow-overlap
|
||||||
),)
|
),)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#import "/src/cetz.typ": draw
|
#import "core/draw/participant.typ"
|
||||||
#import "consts.typ": *
|
|
||||||
#import "core/draw/participant.typ": render as par-render
|
|
||||||
|
|
||||||
#let PAR-SPECIALS = "?[]"
|
#let PAR-SPECIALS = ("?", "[", "]")
|
||||||
#let SHAPES = (
|
#let SHAPES = (
|
||||||
"participant",
|
"participant",
|
||||||
"actor",
|
"actor",
|
||||||
@ -37,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
return ((
|
return ((
|
||||||
type: "par",
|
type: "par",
|
||||||
draw: par-render,
|
draw: participant.render,
|
||||||
name: name,
|
name: name,
|
||||||
display-name: if display-name == auto {name} else {display-name},
|
display-name: if display-name == auto {name} else {display-name},
|
||||||
from-start: from-start,
|
from-start: from-start,
|
||||||
@ -52,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#let _exists(participants, name) = {
|
#let _exists(participants, name) = {
|
||||||
if name == "?" or name == "[" or name == "]" {
|
if name in PAR-SPECIALS {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#import "/src/cetz.typ": draw
|
|
||||||
#import "consts.typ": *
|
|
||||||
#import "core/draw/separator.typ"
|
|
||||||
#import "core/draw/delay.typ"
|
|
||||||
|
|
||||||
#let _sep(name) = {
|
|
||||||
return ((
|
|
||||||
type: "sep",
|
|
||||||
draw: separator.render,
|
|
||||||
name: name
|
|
||||||
),)
|
|
||||||
}
|
|
||||||
|
|
||||||
#let _delay(name: none, size: 30) = {
|
|
||||||
return ((
|
|
||||||
type: "delay",
|
|
||||||
draw: delay.render,
|
|
||||||
name: name,
|
|
||||||
size: size
|
|
||||||
),)
|
|
||||||
}
|
|
@ -1,7 +1,3 @@
|
|||||||
#import "/src/cetz.typ": draw, vector
|
|
||||||
#import "consts.typ": *
|
|
||||||
#import "participant.typ"
|
|
||||||
#import "note.typ"
|
|
||||||
#import "core/draw/sequence.typ"
|
#import "core/draw/sequence.typ"
|
||||||
|
|
||||||
#let _seq(
|
#let _seq(
|
||||||
@ -42,7 +38,8 @@
|
|||||||
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
|
slant: slant,
|
||||||
|
linked-notes: ()
|
||||||
),)
|
),)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/sync.typ
@ -1,10 +0,0 @@
|
|||||||
#import "sequence.typ"
|
|
||||||
#import "core/draw/sync.typ"
|
|
||||||
|
|
||||||
#let _sync(elmts) = {
|
|
||||||
return ((
|
|
||||||
type: "sync",
|
|
||||||
draw: sync.render,
|
|
||||||
elmts: elmts
|
|
||||||
),)
|
|
||||||
}
|
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |