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