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 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 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 text)
110 #(define-markup-command (livretDidasP layout props text) (markup?)
113 (markup #:force-line-width-ratio 1/20 #:null
114 #:fontsize 0 #:force-line-width-ratio 9/10
115 #:fill-line (#:null #:italic text))))
117 #(define-markup-command (livretPers layout props text next) (markup? markup?)
121 (#:fill-line (#:fontsize 1 #:line-width-ratio 7/10
125 #(define livret-verse-aux
126 (let ((gauge-string "Qu entends-je ? il va périr ! quelle fureur m")
128 (define (make-verse verse)
129 (markup #:hspace gap #:fontsize 1 verse))
130 (lambda (layout props verse is-short)
132 (let ((line-width (chain-assoc-get 'line-width props 0))
133 (gauge (interpret-markup
135 (markup #:fontsize 1 gauge-string))))
136 (set! gap (/ (- line-width
137 (interval-length (ly:stencil-extent gauge X)))
141 (markup #:hspace (+ gap (if is-short 4 0))
142 #:fontsize 0 verse)))))
144 #(define-markup-command (livretVer layout props args) (markup-list?)
145 (livret-verse-aux layout props (make-line-markup args) #f))
147 #(define-markup-command (livretVerC layout props args) (markup-list?)
148 (livret-verse-aux layout props (make-line-markup args) #t))
150 #(define-markup-command (livretRef layout props ref next)
155 #:with-link ref #:line ("[Page" #:page-refIII ref "]")
158 #(define-markup-command (invisible layout props arg) (markup?)
159 (interpret-markup layout props (make-with-color-markup white arg)))
161 #(define-markup-command (sep layout props) ()
162 (interpret-markup layout props
163 (markup #:pad-around 1 #:fill-line (#:draw-line '(50 . 0)))))