added id to notes

This commit is contained in:
2025-07-28 18:48:28 +02:00
parent 1a0f47beb3
commit 1db922d44d
3 changed files with 13 additions and 13 deletions

View File

@@ -382,7 +382,7 @@
}
})
#let render(participants, elements) = context canvas(length: 1pt, {
#let render(participants, elements, notes) = context canvas(length: 1pt, {
setup-ctx(participants, elements)
// Draw participants (start)

View File

@@ -126,6 +126,7 @@
"linked",
note.pos == none and note.side != "across"
)
note.insert("id", ctx.notes.len())
let names = ctx.participants.map(p => p.name)
if note.pos == none and note.side != "across" {
let i1 = names.position(n => n == ctx.last-seq.p1)
@@ -186,6 +187,8 @@
}
}
ctx.notes.push(note)
ctx.elmts.at(ctx.i) = note
ctx.last-note = (
@@ -226,6 +229,7 @@
linked: (),
last-seq: none,
last-note: none,
notes: (),
participants: (),
elmts: elmts,
i: 0
@@ -290,10 +294,10 @@
).first())
}
return (ctx.elmts, participants)
return (ctx.elmts, participants, ctx.notes)
}
#let finalize-setup(elmts, participants) = {
#let finalize-setup(elmts, participants, notes) = {
for (i, p) in participants.enumerate() {
p.insert("i", i)
participants.at(i) = p
@@ -323,14 +327,11 @@
elmts.at(i).insert("max-i", max-i)
}
return (elmts, participants)
return (elmts, participants, notes)
}
#let setup(elements) = {
let (elmts, activation-history) = unwrap-containers(elements)
let participants
(elmts, participants) = prepare-participants(elmts)
return finalize-setup(elmts, participants)
let (elmts, participants, notes) = prepare-participants(elmts)
return finalize-setup(elmts, participants, notes)
}

View File

@@ -1,16 +1,15 @@
#import "core/draw/event.typ": render as evt-render
#import "core/renderer.typ": render
#import "core/setup.typ": setup
#import "core/utils.typ": fit-canvas, set-ctx
#import "core/utils.typ": fit-canvas
#let diagram(elements, width: auto) = {
if elements == none {
return
}
let (elmts, participants) = setup(elements)
let (elmts, participants, notes) = setup(elements)
let canvas = render(participants, elmts)
let canvas = render(participants, elmts, notes)
fit-canvas(canvas, width: width)
}