2 %%% TODO: merge with livret.ily
3 %%% (adding customization properties for sizes)
6 #(define-markup-command (n-columns layout props lines) (markup-list?)
7 #:properties ((column-number 2)
10 (inter-column-padding 6))
11 (let* ((line-width (or line-width (ly:output-def-lookup layout 'line-width)))
12 (column-width (/ (- line-width
13 (* (- column-number 1) inter-column-padding))
21 (cons `((line-width . ,column-width)) props)
25 (reduce + 0 (map (lambda (stencil)
26 (interval-length (ly:stencil-extent stencil Y)))
28 (average-height (/ total-height column-number)))
29 (let fill-columns ((lines line-stencils)
30 (current-column-index 1)
31 (current-column-height 0)
32 (current-column-lines '())
33 (previous-columns '()))
35 ;; the end result: a single markup with all columns
38 (reverse! (if current-column-lines
41 (reverse! current-column-lines))
44 ;; go on collecting lines into columns
45 (let* ((line (car lines))
46 (height (interval-length (ly:stencil-extent line Y))))
47 (if (and (> current-column-height 0)
48 (< current-column-index column-number)
49 (>= (+ current-column-height height) average-height))
50 ;; this line ends filling this column
51 ;; => start a new column after it
52 (fill-columns (cdr lines)
53 (1+ current-column-index)
56 (cons (ly:make-stencil
57 "" (cons 0 inter-column-padding) '(0 . 0))
60 (reverse! (cons line current-column-lines)))
62 ;; there is still room in the current column
63 ;; => go on filling it
64 (fill-columns (cdr lines)
66 (+ current-column-height height)
67 (cons line current-column-lines)
68 previous-columns))))))))
70 #(define-markup-command (livretAct layout props text next) (markup? markup?)
73 (markup #:column (#:fill-line (#:fontsize 4 #:pad-around 3 text)
76 #(define-markup-command (livretScene layout props text next)
79 (list (ly:make-stencil "" '(0 . 0) '(0 . 1))
82 (markup #:column (#:fill-line (#:fontsize 2 #:pad-around 2 text)
85 #(define-markup-command (livretDesc layout props text) (markup?)
88 (markup #:force-line-width-ratio 1/20 #:null
89 #:fontsize 1 #:line-width-ratio 9/10 #:pad-around 2 #:italic text)))
91 #(define-markup-command (livretDescPage layout props text) (markup?)
92 #:properties ((line-width)
98 #:override `(line-width . ,(- line-width gap word-space 2))
99 #:fontsize 1 #:pad-around 2 #:italic text)))
101 #(define-markup-command (livretDescAtt layout props text next)
106 (#:line (#:force-line-width-ratio 1/20 #:null
107 #:fontsize 1 #:line-width-ratio 9/10 #:pad-around 2
111 #(define-markup-command (livretDidasP layout props text) (markup?)
114 (markup #:force-line-width-ratio 1/20 #:null
115 #:fontsize 0 #:force-line-width-ratio 9/10
116 #:fill-line (#:null #:italic text))))
118 #(define-markup-command (livretPers layout props text next) (markup? markup?)
122 (#:fill-line (#:fontsize 1 #:line-width-ratio 7/10
126 #(define livret-verse-aux
128 "Qu’en chantant vos feux nous chantions d’autres flâmes ;")
130 (lambda (layout props verse margin)
132 (let ((line-width (chain-assoc-get 'line-width props 0))
133 (gauge (interpret-markup
135 (markup #:fontsize 0 gauge-string))))
136 (set! gap (/ (- line-width
137 (interval-length (ly:stencil-extent gauge X)))
141 (markup #:hspace (+ gap margin)
142 #:fontsize 0 verse)))))
144 #(define-markup-command (livretVerse layout props metric args) (number? markup-list?)
145 (let ((margin (* 2 (- 12 (min 12 metric)))))
146 (livret-verse-aux layout props (make-line-markup args) margin)))
148 #(define-markup-command (livretVer layout props args) (markup-list?)
149 (livret-verse-aux layout props (make-line-markup args) 0))
151 #(define-markup-command (livretVerC layout props args) (markup-list?)
152 (livret-verse-aux layout props (make-line-markup args) 2))
154 #(define-markup-command (livretRef layout props ref next)
159 #:with-link ref #:line ("[Page" #:page-refIII ref "]")
162 #(define-markup-command (invisible layout props arg) (markup?)
163 (interpret-markup layout props (make-with-color-markup white arg)))
165 #(define-markup-command (sep layout props) ()
166 (interpret-markup layout props
167 (markup #:pad-around 1 #:fill-line (#:draw-line '(50 . 0)))))