Sorry for the repeat messages. I now have a working version. This is a callback for InstrumentName.after-line-breaking. It looks at whether the next Staff below is alive on the current system, and if it's not, displays the instrumentName for this Staff instead of the shortInstrumentName. This is a bit simpler than automatically combining the names of hidden staves, but it serves more or less the same purpose. It might be a little nicer to define a new property for the combined/apart names, but I'm not sure how to do that.
\version "2.18.2" \language "english" \paper { left-margin = 1.5\cm } #(define change-instr-names (lambda (grob) (let* ( ;; Get the VerticalAxisGroup grob belonging to me (my-vaxis-arr (ly:grob-object grob 'elements)) (my-vaxis (car (if (ly:grob-array? my-vaxis-arr) (ly:grob-array->list my-vaxis-arr) '()))) ;; Get all the VerticalAxisGroup grobs per system (sys (ly:grob-system grob)) (sys-all-elts (ly:grob-object sys 'all-elements)) (sys-all-elts-list (if (ly:grob-array? sys-all-elts) (ly:grob-array->list sys-all-elts) '())) (vertical-axis-group-list (filter (lambda (g) (grob::has-interface g 'hara-kiri-group-spanner-interface)) sys-all-elts-list)) ;; Check if a VerticalAxisGroup is the next one below me (my-vindex (ly:grob-get-vertical-axis-group-index my-vaxis)) (next-vaxis? (lambda (v) (equal? (+ 1 my-vindex) (ly:grob-get-vertical-axis-group-index v))) ) ;; Get the next Staff below me (next-vaxis (car (filter next-vaxis? vertical-axis-group-list))) ;; Is it alive this system? (alive-next? (interval-sane? (ly:grob-property next-vaxis 'Y-extent))) ) ; (display alive-next?) ; (display "\n\n") (if (not alive-next?) (ly:grob-set-property! grob 'text (ly:grob-property grob 'long-text)) ) ) ) ) %% Example starts here global = { s1 \break s1 \break s1 } fluteI = { c'''1 \partcombineApart \oneVoice c'''1 \partcombineChords c'''1 } fluteII = { e''1 \change Staff = "Fl2" \oneVoice e''1 e''1 } oboeI = { % For parts that begin on separate staves, this is necessary: \once\set Staff.instrumentName = "1" \partcombineApart \oneVoice c'''1 \partcombineChords c'''1 \partcombineApart c'''1 } oboeII = { \change Staff = "Ob2" \oneVoice e''1 e''1 e''1 } \score { << \new StaffGroup \with { instrumentName = "Flute " shortInstrumentName = "Fl. " } << \new Staff = "Fl1" \with { instrumentName = \markup\column { "1" "2" } shortInstrumentName = "1" \override InstrumentName.after-line-breaking = #change-instr-names } << \global \partcombine \fluteI \fluteII >> \new Staff = "Fl2" \with { instrumentName = \markup\column { "2" } shortInstrumentName = \markup\column { "2" } \override VerticalAxisGroup.remove-empty = ##t \override VerticalAxisGroup.remove-first = ##t } << \global >> >> \new StaffGroup \with { instrumentName = "Oboe " shortInstrumentName = "Ob. " } << \new Staff = "Ob1" \with { instrumentName = \markup\column { "1" "2" } shortInstrumentName = "1" \override InstrumentName.after-line-breaking = #change-instr-names } << \global \partcombine \oboeI \oboeII >> \new Staff = "Ob2" \with { instrumentName = \markup\column { "2" } shortInstrumentName = \markup\column { "2" } \override VerticalAxisGroup.remove-empty = ##t \override VerticalAxisGroup.remove-first = ##t } << \global >> >> >> \layout { \context { \Staff \override InstrumentName.self-alignment-X = #1 } } } -- View this message in context: http://lilypond.1069038.n5.nabble.com/engraver-to-change-staff-name-based-on-visibility-of-related-staff-tp203905p204291.html Sent from the Dev mailing list archive at Nabble.com. _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel