[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Derive the correct print function of a grob
From: |
Thomas Morley |
Subject: |
Re: Derive the correct print function of a grob |
Date: |
Tue, 20 Jan 2015 23:00:31 +0100 |
2015-01-20 22:49 GMT+01:00 Thomas Morley <address@hidden>:
> 2015-01-20 22:30 GMT+01:00 tisimst <address@hidden>:
>> 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