From 8deb26441d83ed217ef728fd631efda4644cef7b Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 19 Jun 2024 00:39:55 +0200 Subject: [PATCH] improved seq arrow positioning --- gallery/example1.pdf | Bin 31493 -> 31493 bytes gallery/example2.pdf | Bin 19565 -> 19551 bytes src/sequence.typ | 48 +++++++++++++++++++++++++++---------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/gallery/example1.pdf b/gallery/example1.pdf index 9b37aef8466ea4aeea3622a1e6c4e4ab341a8f34..a1d2b157f646e7a4bc769ba7b0971d1eac1294b4 100644 GIT binary patch delta 181 zcmZqu#@PCeaYIwFvXQZck!6%7mx6-6Z+?nPVo9okhKrSvfsu)UnW2RdNP6?qVt*z! zBP(MIE2GK3O7&q({jxP;*+Kf5L6H_EM!DwtNm*GrrT#8uf#s7wmZ{^A+N@XJ$!v&S Qo2{*;f(CY}$uFv80aoWbM*si- delta 181 zcmZqu#@PCeaYIwFvVn<(p=FdNmx6-6Z+?nPVo9okhKrSvfsu)UnW2RdNP6?qVt*z! z11l2?E5pgZO7&q({jxP;0qKdR#qMDN2F@u-7TGD40r|O}$&QmhmZ{^A+N@XJ$!v&S Qo2{*;f(CY}$uFv80YgEGiGzE$Yr_aaw6r{*j%z~7Pizb2n5|_qP^!t=+p4%wg+Lw%MRfEH6PTrM;dhek{uhZxg zTH)sk4Os}tLZdUz&W;t@EiXJEu@qsM6|KZwj<|j_F_iH>kG};xaB@<_7e9j8{YWz3ViLwrDGDuxa$Zdze%G1lc(~MeYnenpbn$(Dp^9xxF9BSC>Xx< zh;sxzwpqTADzj%5rLalMQ#p$1!UZQe0){f2(zKG3oY@0>iJ}q#y9tZ;s&h*8Rw-FZ zKi7U@G;_S{wni6k>!LHibQ~eiJEvn8z{?en{9Zw?BWwEANs)RQTLGXtnc48xFM5L_ z>S{^uj*XNI@S#zTCR-zSNCQ&6&==5o=aT-hp}Vy5-}OM19rbC&fJ;qdp|z47(4Jpk z9E(cuhXki?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-lvl: lifelines.at(i2).level * LIFELINE-W / 2 ) - let ll-lvl1 = lifelines.at(i1).level * LIFELINE-W / 2 - - let x1 = x-pos.at(i1) - let x2 = x-pos.at(i2) - if elmt.disable-src { let src-line = lifelines.at(i1) src-line.level -= 1 @@ -96,20 +91,29 @@ if elmt.create-dst { let par = participants.at(i2) let m = measure(box(par.display-name)) - x2 -= (m.width + PAR-PAD.last() * 2) / 2pt + let f = if i1 > i2 {-1} else {1} + end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f shapes += participant.render(x-pos, par, y: y) } end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2 - let ll-lvl2 = lifelines.at(i2).level * LIFELINE-W / 2 - let f = if elmt.flip {-1} else {1} - if i1 <= i2 { - x1 += ll-lvl1 * f - x2 -= ll-lvl2 * f - } else { - x1 -= ll-lvl1 * f - x2 += ll-lvl2 * f + // Compute left/right position at start/end + start-info.insert("lx", start-info.x) + if start-info.ll-lvl != 0 { start-info.lx -= LIFELINE-W / 2 } + end-info.insert("lx", end-info.x) + if end-info.ll-lvl != 0 { end-info.lx -= LIFELINE-W / 2 } + + start-info.insert("rx", start-info.x + start-info.ll-lvl) + end-info.insert("rx", end-info.x + end-info.ll-lvl) + + // Choose correct points to link + let x1 = start-info.rx + let x2 = end-info.lx + + if (start-info.i > end-info.i) { + x1 = start-info.lx + x2 = end-info.rx } let style = ( @@ -121,9 +125,17 @@ ) if elmt.p1 == elmt.p2 { - let x3 = x1 - ll-lvl1 + ll-lvl2 + if elmt.flip { + x1 = start-info.lx + } else { + x2 = end-info.rx + } - x2 = if elmt.flip {x1 - 20} else {x1 + 20} + let x-mid = if elmt.flip { + calc.min(x1, x2) - 20 + } else { + calc.max(x1, x2) + 20 + } if elmt.comment != none { shapes += draw.content( @@ -136,9 +148,9 @@ shapes += draw.line( (x1, y), - (x2, y), + (x-mid, y), + (x-mid, y - 10), (x2, y - 10), - (x3, y - 10), ..style ) y -= 10