lilypond-user
[Top][All Lists]
Advanced

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

Re: Derive the correct print function of a grob


From: tisimst
Subject: Re: Derive the correct print function of a grob
Date: Wed, 21 Jan 2015 12:19:34 -0700 (MST)

Perfect. Thanks, Harm!

- Abraham

Sent from my iPhone

On Jan 20, 2015, at 3:01 PM, Thomas Morley-2 [via Lilypond] <[hidden email]> wrote:

2015-01-20 22:49 GMT+01:00 Thomas Morley <[hidden email]>:

> 2015-01-20 22:30 GMT+01:00 tisimst <[hidden email]>:
>> Is it possible to derive the correct default print function for a grob?
>>
>> For example, if I want to get the stencil of a hairpin, I know the function
>> is called "ly:hairpin::print", but for accidentals, it's
>> "ly:accidental-interface:print".
>>
>> I'd like to be able to get the right one automatically (in scheme) without
>> needing to specify them all and use conditionals to figure out the right
>> one. Any suggestions? I'm not sure if this is even possible, and I can deal
>> with it if it's not, but I'd rather not if I can help it.
>>
>> Thanks,
>> Abraham
>
> Hi Abraham,
>
> it's not that hard ;)
> Though, one Problem might be a previous applied stencil-override...
>
> The code below will return the name of the default and the actual
> print-procedure.
>
> \version "2.19.15"
>
> #(define new-stil
>   (lambda (grob)
>     (grob-interpret-markup grob "xy")))
>
> {
>     \override NoteHead.stencil = #new-stil
>     \override NoteHead.after-line-breaking =
>     #(lambda (grob)
>       (display "\nactual-stencil:\t\t")
>       (display
>         (procedure-name
>           (assoc-get 'stencil
>             (ly:grob-basic-properties grob))))
>       (display "\ndefault-stencil:\t")
>       (display
>         (procedure-name
>           (assoc-get 'stencil
>             (reverse (ly:grob-basic-properties grob)))))
>       )
>     c''1
> }
>
> HTH,
>   Harm
Maybe better to do some more afford, to return useful output, if it's
applied to a grob without 'stencil property

#(define new-stil
  (lambda (grob)
    (grob-interpret-markup grob "xy")))

{
    \override NoteHead.stencil = #new-stil
    \override NoteHead.after-line-breaking =
    #(lambda (grob)
      (display "\nactual-stencil:\t\t")
      (display
        (let ((actual-stil-proc
                (assoc-get 'stencil
                  (ly:grob-basic-properties grob))))
          (if (procedure? actual-stil-proc)
              (procedure-name actual-stil-proc)
              (format #f "no stencil found for ~a" grob))))
      (display "\ndefault-stencil:\t")
      (display
        (let ((default-stil-proc
                (assoc-get 'stencil
                  (reverse (ly:grob-basic-properties grob)))))
          (if (procedure? default-stil-proc)
              (procedure-name default-stil-proc)
              (format #f "no stencil found for ~a" grob)))))

    c''1
}

Cheers,
 Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user



If you reply to this email, your message will be added to the discussion below:
http://lilypond.1069038.n5.nabble.com/Derive-the-correct-print-function-of-a-grob-tp170809p170811.html
To start a new topic under User, email [hidden email]
To unsubscribe from Lilypond, click here.
NAML


View this message in context: Re: Derive the correct print function of a grob
Sent from the User mailing list archive at Nabble.com.

reply via email to

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