Hi all,

On Sun, Apr 6, 2014 at 11:10 AM, Trevor Daniels <t.dani...@treda.co.uk>wrote:


> Maybe someone else will have a better solution.
>

Well, here's something rough which appears to do the trick.

The basic idea is that the function locates a PaperColumn that is related
to both our MetronomeMark grob and an AccidentalPlacement grob.  If it
finds it, it calculates the extent of all the accidentals and sets X-offset
based on this.

Hope this helps.  Let me know if you run into problems with it.

--David
\version "2.19.3"

#(define align-tempo-with-accidental
   (lambda (grob)
     (let* ((p-col (ly:grob-parent grob X))
            (sys (ly:grob-parent p-col X))
            (all (ly:grob-object sys 'all-elements))
            (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
            (pl (filter
                   (lambda (x) (eq? 'AccidentalPlacement (grob-name x)))
                   (ly:grob-array->list all)))
            (pl-p-col (filter
                        (lambda (x) (eq? p-col (ly:grob-parent x X)))
                        pl)))
       (if (pair? pl-p-col)
           (let* ((accs (map cadr (ly:grob-object (car pl-p-col) 'accidental-grobs)))
                  (X-exts (map (lambda (x) (ly:grob-extent x sys X)) accs))
                  (un (reduce interval-union '() X-exts)))
             (car un))
             ; Return the default.
             (ly:make-simple-closure
              `(,+
                ,(ly:make-simple-closure
                  (list ly:break-alignable-interface::self-align-callback))
                ,(ly:make-simple-closure
                  (list ly:self-alignment-interface::x-aligned-on-self))))))))
            
{
  R1 |
  \override Score.MetronomeMark.X-offset = #align-tempo-with-accidental
  \tempo "Tempo"
  <aes' bes'>
  \tempo "Tempo II"
  <as' bes' ges' fes' es' des' ces'>
  \tempo "Tempo III"
  <ais' bis' gis' fis' eis' dis' cis'>
}

<<attachment: metronome-mark-alignment.png>>

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to