Hi, > > El 30/05/15 a las 13:31, Thomas Morley escibió: > >> >> I'd deprecate the old one! >> > Well, this one doesn't have quite the same amount of testing so you'd best keep it around!
Attached you'll find a more streamlined version. Note that it's now an override of PaperColumn, not NoteColumn. (It would be nice if the measure size would actually change to accommodate the centered object, but that seems like quite an undertaking to implement.) --David
\version "2.19.15" #(define center-column (lambda (col) (let* ((left-col (ly:grob-object col 'left-neighbor)) (right-col (ly:grob-object col 'right-neighbor)) ; If a column adjoining our column is a PaperColumn, ours ; is not alone in the measure. We make no adjustments. (alone? (and (eq? #t (ly:grob-property left-col 'non-musical)) (eq? #t (ly:grob-property right-col 'non-musical))))) (if alone? (let* ((elts-list (ly:grob-array->list (ly:grob-object col 'elements))) (note-cols (filter (lambda (elt) (grob::has-interface elt 'note-column-interface)) elts-list)) (all-rests (map (lambda (c) (ly:grob-object c 'rest)) note-cols)) (all-rests (filter ly:grob? all-rests)) (all-notes (map (lambda (c) (ly:grob-object c 'note-heads)) note-cols)) (all (map (lambda (ga) (if (ly:grob-array? ga) (ly:grob-array->list ga) '())) all-notes)) (all (flatten-list all)) (all (append all all-rests)) (same-dur? (every (lambda (o) (equal? (ly:grob-property o 'duration-log) (ly:grob-property (car all) 'duration-log))) all))) (if same-dur? (let* ((sys (ly:grob-system col)) (col-center (interval-center (ly:grob-extent col sys X))) (left-right-X (cdr (ly:grob-extent left-col sys X))) (right-left-X (car (ly:grob-extent right-col sys X))) (middle-X (- (average left-right-X right-left-X) col-center))) (ly:grob-translate-axis! col middle-X X)))))))) centerSolitaryPaperColumn = \override Score.PaperColumn.after-line-breaking = #center-column %%%%%%%%%%%% global = { \key a \major \time 4/4 \partial 4 } pianoDerI = \relative c'' { \global \voiceOne a4 | a e' e( d8[ cis] | b4) cis d8[ cis] b4 | a2\fermata r4 a | b cis d b | e fis e\fermata cis | cis8[ d] e4 d cis8[( b]) | a[( b] cis4) b\fermata cis | a b8[ cis] d4\fermata cis | b cis d\fermata cis | b a e'4.( d8 | cis4) d8[ cis] b2 | %\centerNoteColumnOn a2.\fermata \bar "|." } pianoDerII = \relative c' { \global \voiceTwo fis4 | e8( fis gis a b4) e, | dis e d8 a' gis4 | e2 r4 fis | fis e8( cis) gis'( fis) e( dis) | e[ fis16 gis a8] fis gis4 a | a ais b8 a gis fis | e[( fis16 gis a8 fis]) gis4 a8[ gis] | fis4. gis16 ais b4 ais! | b8 a g4 fis e8 a~( | a gis4) fis8 gis a b4~ | b8 e, a4 a( gis) | e2. } pianoIzqI = \relative c' { \global \voiceOne cis8 d | e4 d8 cis b4( a | b) a8 g a4 e'8 d | cis2 r4 a | a gis b8( a) b4 | b8( e4) dis8 e4 e | fis fis fis e | e8( d cis dis) e4 e | d8( cis) d( e) fis4 fis8 e | d4 e a, a | b cis8 dis e2~ | e8 cis a cis fis d b e | %\centerNoteColumnOn cis2. } pianoIzqII = \relative c { \global \voiceTwo fis4 | cis' b8 a gis4 a~ | a8 g fis e fis d e4 | a,2\fermata r4 d | dis8 e4 eis fis8 gis a | gis e b'4 e,\fermata a8 gis | fis e d cis b4 e8 d | cis( b a4) e'\fermata a, | d8 e d cis b4\fermata fis' | g8 fis e4 d\fermata a | e'2~ e8 fis gis e | a gis fis e d( b e4) | a,2.\fermata } \score { << \new PianoStaff \with { instrumentName = "Piano" } << \new Staff = "right" << \new Voice \pianoDerI \new Voice \pianoDerII >> \new Staff = "left" << \clef bass \new Voice \pianoIzqI \new Voice \pianoIzqII >> >> >> \layout { %ragged-last= ##t \centerSolitaryPaperColumn } }
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user