force printing first chord on newline
This commit is contained in:
parent
754682afcf
commit
d56c11c5ff
@ -139,43 +139,32 @@ generalLayout = \layout {
|
|||||||
}
|
}
|
||||||
#}))
|
#}))
|
||||||
|
|
||||||
% If you add this engraver to ChordNames Context chords get only printed on chordchanges and not at newline.
|
% If you add this engraver to ChordNames Context chords get only printed on chordchanges and if its the first chord after line break.
|
||||||
% See https://lists.gnu.org/archive/html/lilypond-user/2020-07/msg00187.html
|
Ensure_first_chord_after_line_break_printed_engraver =
|
||||||
Ignoring_newline_chord_changes_engraver =
|
|
||||||
#(lambda (ctx)
|
#(lambda (ctx)
|
||||||
(let* ((chord #f)
|
(define last-system-column-rank 0)
|
||||||
(last-chord #f))
|
|
||||||
|
|
||||||
(define (at-line-beginning? grob)
|
|
||||||
(let* ((col (ly:item-get-column grob))
|
|
||||||
(ln (ly:grob-object col 'left-neighbor))
|
|
||||||
(col-to-check (if (ly:grob? ln) ln col)))
|
|
||||||
(and (eq? #t (ly:grob-property col-to-check 'non-musical))
|
|
||||||
(= 1 (ly:item-break-dir col-to-check)))))
|
|
||||||
|
|
||||||
(make-engraver
|
(make-engraver
|
||||||
(acknowledgers
|
(acknowledgers
|
||||||
((chord-name-interface this-engraver grob source-engraver)
|
((chord-name-interface this-engraver grob source-engraver)
|
||||||
|
|
||||||
(if chord
|
|
||||||
(begin
|
|
||||||
(set! last-chord chord)
|
|
||||||
(set! chord #f)))
|
|
||||||
|
|
||||||
(set! chord (ly:grob-property grob 'text))
|
|
||||||
|
|
||||||
;; If two subsequent chords are equal and chordChanges is enabled,
|
|
||||||
;; set 'after-line-breaking to a procedure which sets the stencil
|
|
||||||
;; to an empty-stencil if the new chord is at line-start.
|
|
||||||
(if (and (equal? chord last-chord)
|
|
||||||
(ly:context-property ctx 'chordChanges #f))
|
|
||||||
(ly:grob-set-property! grob 'after-line-breaking
|
(ly:grob-set-property! grob 'after-line-breaking
|
||||||
(lambda (grob)
|
(lambda (grob)
|
||||||
(if (at-line-beginning? grob)
|
(let ((current-system-column-rank (car (ly:grob-spanned-column-rank-interval (ly:grob-system grob)))))
|
||||||
(ly:grob-set-property! grob 'stencil empty-stencil))
|
(if (and
|
||||||
;; keep default
|
(ly:context-property ctx 'chordChanges #f)
|
||||||
(ly:chord-name::after-line-breaking grob))))))
|
(ly:grob-property grob 'begin-of-line-visible #f)
|
||||||
((finalize this-engraver)
|
(not (= last-system-column-rank current-system-column-rank)))
|
||||||
;; house keeping
|
; the current chord handling implementation in lilypond uses 'begin-of-line-visible to mark repeated chords
|
||||||
(set! chord #f)
|
(ly:grob-set-property! grob 'begin-of-line-visible #f))
|
||||||
(set! last-chord #f)))))
|
(set! last-system-column-rank current-system-column-rank)
|
||||||
|
(ly:chord-name::after-line-breaking grob)
|
||||||
|
)))))))
|
||||||
|
|
||||||
|
% If you add this engraver to ChordNames Context chords get only printed on chordchanges and not at newline.
|
||||||
|
Ignoring_newline_chord_changes_engraver =
|
||||||
|
#(lambda (ctx)
|
||||||
|
(make-engraver
|
||||||
|
(acknowledgers
|
||||||
|
((chord-name-interface this-engraver grob source-engraver)
|
||||||
|
(when (and (ly:context-property ctx 'chordChanges #f) (ly:grob-property grob 'begin-of-line-visible #f))
|
||||||
|
(ly:grob-suicide! grob)
|
||||||
|
)))))
|
@ -277,7 +277,7 @@
|
|||||||
\ChordNames
|
\ChordNames
|
||||||
\override VerticalAxisGroup.staff-affinity = ##f
|
\override VerticalAxisGroup.staff-affinity = ##f
|
||||||
\override ChordName.extra-spacing-width = #'(-0.1 . 0.1)
|
\override ChordName.extra-spacing-width = #'(-0.1 . 0.1)
|
||||||
\consists \Ignoring_newline_chord_changes_engraver
|
\consists \Ensure_first_chord_after_line_break_printed_engraver
|
||||||
}
|
}
|
||||||
\context {
|
\context {
|
||||||
\Score
|
\Score
|
||||||
|
Loading…
Reference in New Issue
Block a user