2 (define-public (stack-molecules axis dir padding mols)
3 "Stack molecules MOLS in direction AXIS,DIR, using PADDING."
7 (ly:molecule-combine-at-edge (car mols) axis dir
8 (stack-molecules axis dir padding (cdr mols))
15 (define-public (stack-lines dir padding baseline mols)
16 "Stack vertically with a baseline-skip."
19 (if (null? (cdr mols))
21 (ly:molecule-combine-at-edge (car mols) Y dir
22 (stack-lines dir padding baseline (cdr mols))
27 (define-public (fontify-text font-metric text)
28 "Set TEXT with font FONT-METRIC, returning a molecule."
29 (let* ((b (ly:text-dimension font-metric text)))
31 (ly:fontify-atom font-metric `(text ,text)) (car b) (cdr b))
34 (define-public (bracketify-molecule mol axis thick protusion padding)
35 "Add brackets around MOL, producing a new molecule."
37 (let* ((ext (ly:molecule-get-extent mol axis))
38 (lb (ly:bracket axis ext thick (- protusion)))
39 (rb (ly:bracket axis ext thick protusion)))
40 (set! mol (ly:molecule-combine-at-edge mol (other-axis axis) 1 lb padding))
41 (set! mol (ly:molecule-combine-at-edge mol (other-axis axis) -1 rb padding))
45 (define-public (make-filled-box-molecule xext yext)
49 (list 'filledbox (- (car xext)) (cdr xext)
50 (- (car yext)) (cdr yext))
55 (define-public (box-grob-molecule grob)
56 "Make a box of exactly the extents of the grob. The box precisely
57 encloses the contents.
59 (let* ((xext (ly:get-extent grob grob 0))
60 (yext (ly:get-extent grob grob 1))
63 (ly:molecule-add (make-filled-box-molecule xext (cons (- (car yext) thick) (car yext) ))
64 (make-filled-box-molecule xext (cons (cdr yext) (+ (cdr yext) thick) ))
65 (make-filled-box-molecule (cons (cdr xext) (+ (cdr xext) thick)) yext)
66 (make-filled-box-molecule (cons (- (car xext) thick) (car xext)) yext))))
69 ;; TODO merge this and prev function.
70 (define-public (box-molecule mol thick padding)
71 "Add a box around MOL, producing a new molecule."
73 (x-ext (interval-widen (ly:molecule-get-extent mol 0) padding))
74 (y-ext (interval-widen (ly:molecule-get-extent mol 1) padding))
75 (x-rule (make-filled-box-molecule (interval-widen x-ext thick)
77 (y-rule (make-filled-box-molecule (cons 0 thick) y-ext)))
79 (set! mol (ly:molecule-combine-at-edge mol 0 1 y-rule (* 0.5 padding)))
80 (set! mol (ly:molecule-combine-at-edge mol 0 -1 y-rule (* 0.5 padding)))
81 (set! mol (ly:molecule-combine-at-edge mol 1 1 x-rule 0.0))
82 (set! mol (ly:molecule-combine-at-edge mol 1 -1 x-rule 0.0))