added comment wrapping if width is restricted
This commit is contained in:
parent
1f155063a8
commit
ab1386e721
@ -100,19 +100,27 @@
|
||||
|
||||
y -= Y-SPACE
|
||||
|
||||
let i1 = pars-i.at(elmt.p1)
|
||||
let i2 = pars-i.at(elmt.p2)
|
||||
let width = calc.abs(x-pos.at(i1) - x-pos.at(i2))
|
||||
|
||||
let h = 0
|
||||
let comment = if elmt.comment == none {none} else {
|
||||
let w = calc.min(width * 1pt, measure(elmt.comment).width)
|
||||
box(
|
||||
width: if i1 == i2 {auto} else {w},
|
||||
elmt.comment
|
||||
)
|
||||
}
|
||||
// Reserve space for comment
|
||||
if elmt.comment != none {
|
||||
h = calc.max(h, measure(box(elmt.comment)).height / 1pt + 6)
|
||||
if comment != none {
|
||||
h = calc.max(h, measure(comment).height / 1pt + 6)
|
||||
}
|
||||
if "linked-note" in elmt {
|
||||
h = calc.max(h, note.get-size(elmt.linked-note).height / 2)
|
||||
}
|
||||
y -= h
|
||||
|
||||
let i1 = pars-i.at(elmt.p1)
|
||||
let i2 = pars-i.at(elmt.p2)
|
||||
|
||||
let start-info = (
|
||||
i: i1,
|
||||
x: x-pos.at(i1),
|
||||
@ -244,7 +252,7 @@
|
||||
(x2, end-info.y)
|
||||
)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
comment-anchor = (
|
||||
start: if x-mid < x1 {"south-east"} else {"south-west"},
|
||||
end: if x-mid < x1 {"south-west"} else {"south-east"},
|
||||
@ -268,7 +276,7 @@
|
||||
(x2, end-info.y)
|
||||
)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
let start-pt = pts.first()
|
||||
let end-pt = pts.last()
|
||||
if elmt.start-tip != "" {
|
||||
@ -348,10 +356,10 @@
|
||||
|
||||
shapes += draw.line(..pts, ..style)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
shapes += draw.content(
|
||||
comment-pt,
|
||||
elmt.comment,
|
||||
comment,
|
||||
anchor: comment-anchor,
|
||||
angle: comment-angle,
|
||||
padding: 3pt
|
||||
|
Loading…
Reference in New Issue
Block a user