lilypond-user
[Top][All Lists]
Advanced

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

Re: Accessing a grob from within a music function


From: Thomas Morley
Subject: Re: Accessing a grob from within a music function
Date: Thu, 16 Mar 2017 22:51:51 +0100

2017-03-16 14:23 GMT+01:00 Urs Liska <address@hidden>:
> Hi,
>
> I'm trying to write a function to push a note column like this:
>
> pushLeftBroken =
> #(define-music-function ()()
>    #{
>      \once \override NoteColumn.X-offset = 3
>    #})
>
> But I need to make that "3" depend on some characteristics of the actual
> note column. Basically I need the width of the note column, including
> attached accidentals.
>
> I know how to get to the accidental(s) within a note column, but if I'm
> not mistaken there's no actual grob inside that.
>
> Probably music-function isn't the right approach?
>
> What I need is a way to say something like
>
> \once \override NoteColumn.X-offset = #(+ 3
> extent-of-all-accidentals-in-the-note-column)
>
> Any ideas?
> TIA
> Urs



Hi Urs,

here my thoughts about the topic so far.
Although I'm afraid it will not help, because it has to be done
before-line-breaking.

wanted-value = 20

{
    c'1( \break
  \override NoteColumn.before-line-breaking =
  #(lambda (nc)
  ;; TODOs
  ;; add fall-backs if certain grobs are not present, i.e
  ;; (DotColumn, Arpeggio, AccidentalPlacement)
    (let* ((dot-col (ly:note-column-dot-column nc))
           (acc-placement (ly:note-column-accidentals nc))
           (common-ref
             (ly:grob-common-refpoint nc acc-placement X))
           (x-length-of-accs
             (interval-length
               (ly:relative-group-extent
                 (map last (ly:grob-object acc-placement 'accidental-grobs))
                 common-ref
                 X))))

       (for-each
         (lambda (el)
           (ly:grob-translate-axis!
             el
             (+ x-length-of-accs wanted-value)
             X))
         (filter
           (lambda (g) (ly:grob? g))
           (list
             acc-placement
             dot-col
             nc)))))


  <cis'' dis'' fis'' gis''-1\2>2)\arpeggio ^"foo"
}

Cheers,
  Harm



reply via email to

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