lilypond-user
[Top][All Lists]
Advanced

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

Re: changing grob properties?


From: Neil Puttock
Subject: Re: changing grob properties?
Date: Sat, 16 May 2009 01:06:12 +0100

2009/5/15 Marc Hohl <address@hidden>:

> Upto now, I have achieved to make tablature fret numbers invisible which are
> tied to another note.
> But I don't know how to add parentheses to the numbers that are tied but
> show up after a line break
> (for example the first note in measure 5, see attachment).
>
> I tried something like
>
> (set! (ly:music-property note 'elements)
>                (cons (make-music 'NoteEvent 'parenthesize #t)
>                      (ly:music-property note 'elements)))
>
> but I realized that a grob is not a music expression as the variable called
> "note" in the code fragment above.

Indeed, once the grob's been created it's too late to be setting music
properties.

> Then I came up with the vague idea to combine the TabNoteHead-Stencil with
> the
> stencil for the parentheses, but this was beyond my knowledge, it didn't
> work.

It won't work, since the stencil callback for parentheses has some
rather specific requirements which are set in the
Parenthesis_engraver.

You could use markup to place the parentheses around the TabNoteHead,
but unless I'm mistaken, that's not possible inside a callback for
'after-line-breaking, since it's called after stencils have been
generated.

> \version "2.12.2"
>
> #(define (tie::handle-tab-tie grob)
>  (let* ((original (ly:grob-original grob))
>         (tied-tabnotehead (ly:spanner-bound original RIGHT))

Should be (ly:spanner-bound grob RIGHT).

The unbroken grob is only used to obtain the list of broken spanners,
if there are any (remember that this callback will be called for every
tie, including those which aren't split).

>         (siblings (if (ly:grob? original)
>                     (ly:spanner-broken-into original) '() )))
>
>    (if (and (>= (length siblings) 2)
>            (eq? (car (last-pair siblings)) grob))
>       ;; tie is split
>       ;; just a dummy function here, parentheses should be inserted
>       (begin (ly:grob-set-property! tied-tabnotehead 'transparent #f)

It would be easier to see whether this is actually working on the
correct grob if you changed the override to 'color.

>              (newline)
>              (display "Tie is split.")
>              (newline))
>       ;; tie is not split -> make fret number invisible
>       (ly:grob-set-property! tied-tabnotehead 'transparent #t)
>       );; end if
>       ))
>
> test = \relative c {
>       f2 ~ f4 \parenthesize e
>       g8 g ~ g g ~ g g~ g g ~
>       g1
>       c1 ~ \break c2 ~ c
>       < c\3 e\2 g\1 >4 < c\3 e\2 g\1 > ~ < c\3 e\2 g\1 > < c\3 e\2 g\1 >
>       \bar "|."
>       }
>
> \score {
>   << \new Staff { \clef "G_8" \test }
>      \new TabStaff { \clef "tab"
>                      \override Tie  #'stencil = #tie::handle-tab-tie

Should be \override Tie #'after-line-breaking = #tie::handle-tab-tie

There's no stencil returned by the function, which is why you're
getting loads of programming errors and invisible ties.

Regards,
Neil




reply via email to

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