]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/incipit.ly
New instrument name positioning in scheme.
[lilypond.git] / input / regression / incipit.ly
1 \version "2.13.4"
2
3 \header {
4   texidoc = "Incipits can be printed using an @code{InstrumentName}
5 grob."
6 }
7
8 %% to prevent warnings/programming errors:
9 #(set-object-property! 'music 'backend-type? ly:music?)
10 #(set-object-property! 'music 'backend-doc "Incipit music")
11 #(ly:add-interface 'incipit-interface "An incipit." '(music))
12 #(let* ((instrument-def (assoc 'InstrumentName all-grob-descriptions))
13         (meta-def (assoc 'meta (cdr instrument-def)))
14         (interfaces-def (assoc 'interfaces (cdr meta-def)))
15         (interfaces (cdr interfaces-def)))
16    (set-cdr! interfaces-def (cons 'incipit-interface interfaces)))
17
18 \score {
19   \new Staff {
20     %% All this would be shortcuted by an appropriate music function:
21     \override Staff.InstrumentName #'music = ##{ \clef "petrucci-c1" c'4 d' e' f' #}
22     \override Staff.InstrumentName #'self-alignment-X = #RIGHT
23     \override Staff.InstrumentName #'padding = #0
24     \override Staff.InstrumentName #'stencil =
25     #(lambda (grob)
26        (let* ((instrument-name (ly:grob-property grob 'long-text))
27               (layout (ly:output-def-clone (ly:grob-layout grob)))
28               (music (make-music 'SequentialMusic
29                       'elements (list (make-music 'ContextSpeccedMusic
30                                         'context-type 'MensuralStaff
31                                         'element (make-music 'PropertySet
32                                                    'symbol 'instrumentName
33                                                    'value instrument-name))
34                                       (ly:grob-property grob 'music))))
35               (score (ly:make-score music))
36               (mm (ly:output-def-lookup layout 'mm))
37               (indent (ly:output-def-lookup layout 'indent))
38               (incipit-width (ly:output-def-lookup layout 'incipit-width))
39               (scaled-incipit-width (if (number? incipit-width)
40                                         (* incipit-width mm)
41                                         (* indent 0.5))))
42          (ly:output-def-set-variable! layout 'indent (- indent scaled-incipit-width))
43          (ly:output-def-set-variable! layout 'line-width indent)
44          (ly:output-def-set-variable! layout 'ragged-right #f)
45          (ly:score-add-output-def! score layout)
46          (set! (ly:grob-property grob 'long-text)
47                (markup #:score score))
48          (system-start-text::print grob)))
49
50     %% the instrument name definition is separated:
51     \set Staff.instrumentName = #"Instrument"
52     c'4 d' e' f' g'1
53   }
54   \layout {
55     indent = 5\cm
56     incipit-width = 3\cm
57   }
58 }