adapted control shape rendering

This commit is contained in:
2025-07-19 18:04:16 +02:00
parent 02fd3282f7
commit b34702485f

View File

@ -1,18 +1,19 @@
#import "/src/cetz.typ": draw #import "/src/cetz.typ": draw
#import "/src/core/utils.typ": normalize-measure #import "/src/core/utils.typ": normalize-measure, normalize-units
#import "/src/consts.typ": *
#let name = "control" #let name = "control"
#let render(x, y, p, bottom) = { #let render(x, y, p, bottom) = {
let m = measure(p.display-name) let m = normalize-measure(p.display-name)
let style = p.resolved-style let style = p.resolved-style
let r = CONTROL-HEIGHT / 2 let size = normalize-units(style.size)
let spacing = normalize-units(style.spacing)
let r = size / 2
let y0 = if bottom { let y0 = if bottom {
y - m.height / 1pt - SYM-GAP y - m.height - spacing
} else { } else {
y + m.height / 1pt + CONTROL-HEIGHT + SYM-GAP y + m.height + size + spacing
} }
draw.circle( draw.circle(
@ -22,7 +23,12 @@
stroke: style.stroke stroke: style.stroke
) )
let s = stroke(style.stroke) let s = stroke(style.stroke)
draw.mark((x, y0), (x - r / 2, y0), symbol: "stealth", fill: s.paint) draw.mark(
(x, y0), (x - r / 2, y0),
symbol: "stealth",
fill: s.paint,
stroke: s.paint
)
draw.content( draw.content(
(x, y), (x, y),
p.display-name, p.display-name,
@ -33,12 +39,16 @@
#let get-size(par) = { #let get-size(par) = {
let m = normalize-measure(par.display-name) let m = normalize-measure(par.display-name)
// CONTROL-HEIGHT * 1pt let size = normalize-units(par.resolved-style.size)
// CONTROL-HEIGHT * 1pt + SYM-GAP * 1pt + h let spacing = normalize-units(par.resolved-style.spacing)
return m return (
width: calc.max(m.width, size),
height: size + spacing + m.height
)
} }
#let default-style = ( #let default-style = (
: size: 20pt,
spacing: 5pt
) )