Les Horaces : suggestion nuances 2-4
[nenuvar.git] / common / livret-columns.ily
blobb53ed65a8f5f822525779f1c849c9024d18c5a0d
1 %%%
2 %%% TODO: merge with livret.ily
3 %%% (adding customization properties for sizes)
4 %%% DEPRECATED
6 #(define-markup-command (n-columns layout props lines) (markup-list?)
7    #:properties ((column-number 2)
8                  (line-width #f)
9                  (baseline-skip 0.3)
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))
14                            column-number)))
15      (let* ((line-stencils
16              (space-lines
17               baseline-skip
18               (map (lambda (line)
19                      (interpret-markup
20                       layout
21                       (cons `((line-width . ,column-width)) props)
22                       line))
23                    lines)))
24             (total-height
25              (reduce + 0 (map (lambda (stencil)
26                                 (interval-length (ly:stencil-extent stencil Y)))
27                               line-stencils)))
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 '()))
34          (if (null? lines)
35              ;; the end result: a single markup with all columns
36              (stack-stencil-line
37               0
38               (reverse! (if current-column-lines
39                             (cons (stack-lines
40                                    DOWN 0 0
41                                    (reverse! current-column-lines))
42                                   previous-columns)
43                             previous-columns)))
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)
54                                  0
55                                  '()
56                                  (cons (ly:make-stencil
57                                         "" (cons 0 inter-column-padding) '(0 . 0))
58                                        (cons (stack-lines
59                                               DOWN 0 0
60                                               (reverse! (cons line current-column-lines)))
61                                              previous-columns)))
62                    ;; there is still room in the current column
63                    ;; => go on filling it
64                    (fill-columns (cdr lines)
65                                  current-column-index
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?)
71    (interpret-markup
72     layout props
73     (markup #:column (#:fill-line (#:fontsize 4 #:pad-around 3 text)
74                       next))))
76 #(define-markup-command (livretScene layout props text next)
77      (markup? markup?)
78    (stack-lines DOWN 0 0
79                 (list (ly:make-stencil "" '(0 . 0) '(0 . 1))
80                       (interpret-markup
81                        layout props
82                        (markup #:column (#:fill-line (#:fontsize 2 #:pad-around 2 text)
83                                          next))))))
85 #(define-markup-command (livretDesc layout props text) (markup?)
86    (interpret-markup
87     layout props
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)
93                  (gap 12)
94                  (word-space 0))
95    (interpret-markup
96     layout props
97     (markup #:hspace gap
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)
102      (markup? markup?)
103    (interpret-markup
104     layout props
105     (markup #:column
106             (#:line (#:force-line-width-ratio 1/20 #:null
107                      #:fontsize 1 #:line-width-ratio 9/10 #:pad-around 2
108                                               #:italic text)
109              next))))
111 #(define-markup-command (livretDidasP layout props text) (markup?)
112    (interpret-markup
113     layout props
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?)
119    (interpret-markup
120     layout props
121     (markup #:column
122             (#:fill-line (#:fontsize 1 #:line-width-ratio 7/10
123                                      #:pad-around 2 text)
124              next))))
126 #(define livret-verse-aux
127    (let ((gauge-string
128           "Qu’en chantant vos feux nous chantions d’autres flâmes ;")
129          (gap #f))
130      (lambda (layout props verse margin)
131        (if (not gap)
132            (let ((line-width (chain-assoc-get 'line-width props 0))
133                  (gauge (interpret-markup
134                          layout props
135                          (markup #:fontsize 0 gauge-string))))
136              (set! gap (/ (- line-width
137                              (interval-length (ly:stencil-extent gauge X)))
138                           2.0))))
139        (interpret-markup
140         layout props
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)
155      (symbol? markup?)
156    (interpret-markup
157     layout props
158     (markup #:combine
159             #:with-link ref #:line ("[Page" #:page-refIII ref "]")
160             next)))
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)))))