lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding the objects at the start of the current measure


From: Thomas Morley
Subject: Re: Finding the objects at the start of the current measure
Date: Thu, 28 Feb 2019 01:34:31 +0100

Am Mi., 27. Feb. 2019 um 08:51 Uhr schrieb Urs Liska <address@hidden>:

> For me that means the results with 'minimum-length seem to be generally
> more reliable - with the exception of the start-measure objects.

Well, below an approach for minimal-length. The results are
inconsistent as well.
Currently not sure how to proceed...

\paper { ragged-right = ##t }

buzz =
  \override MultiMeasureRest.minimum-length =
    #(lambda (grob)
       (let* ((vag (ly:grob-parent grob Y)) ;; VerticalAxisGroup
              (vag-elts-array (ly:grob-object vag 'elements))
              (vag-elts-ls
                (if (ly:grob-array? vag-elts-array)
                    (ly:grob-array->list vag-elts-array)
                    '()))
              (mm-grobs
                (filter
                  (lambda (elt)
                    (and
                      (equal? (ly:grob-parent elt X) grob)
                      (grob::has-interface elt 'multi-measure-interface)))
                  vag-elts-ls)))

         (if (pair? mm-grobs)
             (let* ((mm-text-stil-x-lengths
                      (map
                        (lambda (mm)
                          (interval-length
                            (ly:stencil-extent
                              (grob-interpret-markup
                                mm
                                (ly:grob-property mm 'text))
                              X)))
                        mm-grobs))
                    (max-text-x-length
                      (apply max mm-text-stil-x-lengths))
                    (left-bound (ly:spanner-bound grob LEFT))
                    (left-bound-width
                      (ly:axis-group-interface::width left-bound))
                    (right-bound (ly:spanner-bound grob RIGHT))
                    (right-bound-width
                      (ly:axis-group-interface::width right-bound)))

                 (+ 1
                    (interval-length left-bound-width)
                    ;(interval-length right-bound-width)
                    max-text-x-length)))))

{
  \buzz

  R1^"very very long"_"not short"
  R1^"very very long"_"not short"
  \key cis \major
  R1^"very very long"_"not short"
  R1^"very very long"_"not short"
  R1^"very very long"_"not short"
  \key ces \major
  \break
  R1^"very very long"_"not short"
  \key cis \major
  R1^"very very long"_"not short"
}


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]