4 Commits

Author SHA1 Message Date
aca2d858fe changed participant name alignment to base
All checks were successful
CI / tests (push) Successful in 20s
2025-07-16 19:13:54 +02:00
6c97bb807f Merge pull request 'Fix notes width not taken into account' (#16) from fix/issue-13-note-in-group into dev
All checks were successful
CI / tests (push) Successful in 1m1s
Reviewed-on: #16
2025-07-16 16:53:08 +00:00
f812ac93c2 fixed missing import
All checks were successful
CI / tests (pull_request) Successful in 26s
2025-07-16 18:45:37 +02:00
caad9ed823 fixed group width containing notes 2025-07-16 18:45:10 +02:00
6 changed files with 44 additions and 15 deletions

View File

@ -1,7 +1,7 @@
#import "/src/cetz.typ": draw #import "/src/cetz.typ": draw
#import "/src/consts.typ": * #import "/src/consts.typ": *
#import "/src/core/utils.typ": get-ctx, set-ctx #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
@ -18,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 => {
@ -87,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)
@ -104,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

View File

@ -1,7 +1,7 @@
#import "/src/cetz.typ": draw #import "/src/cetz.typ": draw
#import "/src/consts.typ": * #import "/src/consts.typ": *
#import "/src/core/utils.typ": get-ctx, set-ctx #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}
@ -159,5 +159,7 @@
return c return c
}) })
} }
expand-parent-group(x0, x2)
}) })
} }

View File

@ -81,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"}
) )
} }
@ -109,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"}
) )
} }
@ -127,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"}
) )
} }
@ -150,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"}
) )
} }
@ -183,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"}
) )
} }
@ -287,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"}
) )
} }

View File

@ -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
}) })

View File

@ -1,4 +1,5 @@
#import "core/draw/delay.typ" #import "core/draw/delay.typ"
#import "core/draw/event.typ": render as evt-render
#import "core/draw/separator.typ" #import "core/draw/separator.typ"
#import "core/draw/sync.typ" #import "core/draw/sync.typ"
#import "core/utils.typ": set-ctx #import "core/utils.typ": set-ctx

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB