[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printKeyCancellation, a way to never show key cancellations?
From: |
Thomas Morley |
Subject: |
Re: printKeyCancellation, a way to never show key cancellations? |
Date: |
Mon, 3 Dec 2012 00:49:31 +0100 |
2012/12/2 Paul Morris <address@hidden>:
>
> On Dec 2, 2012, at 3:01 PM, Keith OHara <address@hidden> wrote:
>
>> Paul Morris <paul <at> paulwmorris.com> writes:
>>
>>> For greater flexibility, would it make sense for PrintKeyCancellation to
>>> have 3 options instead of 2?
>>> 1. show key cancellations
>>> 2. hide key cancellations, except C major / A minor
>>> 3. hide all key cancellations
>>>
>> Maybe it would have, but we have gotten used to the simple true/false, which
>> does the right thing for most situations.
>>
>> Option number 3 can be had most simply with
>>
>>> \override Staff.KeyCancellation #'stencil = ##f
>>
>> but it looks like you wrote code that restores the 'stencil for
>> anything that answers to the "key-signature-interface"
>>
>>> ((key-signature-interface engraver grob source-engraver)
>>> (ly:grob-set-property! grob 'stencil
>>> (make-circle-stencil .7 .3 #f))))))
>>
>> You can stop the key cancellation by some other means as Harm suggested,
>> or change your code to stencil KeySignatures only.
>
> That makes sense. Reading through the docs I haven't been able to figure out
> how to do this. If anyone has suggestions or pointers, I would appreciate it.
>
> From what I could tell the Key_engraver engraves both signatures and their
> cancellations, and I couldn't see how (or whether) it knows which one it's
> engraving, or how one might replicate that with custom Scheme code. Maybe
> one would need to hook into the code at a higher step in the order of
> operations, where the difference between signatures and cancellations was
> still accessible?
You can distinguish KeySignature and KeyCancellation by 'name:
\version "2.16.1"
#(define Custom_key_engraver
(make-engraver
(acknowledgers
((key-signature-interface engraver grob source-engraver)
(let ((grob-name (lambda (x) (assq-ref (ly:grob-property x
'meta) 'name))))
;; For testing:
;; (newline)(write (grob-name grob))
;; (if (eq? 'KeySignature (grob-name grob))
;; (ly:grob-set-property! grob 'color red)
;; (ly:grob-set-property! grob 'color green))
(if (eq? 'KeySignature (grob-name grob))
(ly:grob-set-property! grob 'stencil (make-circle-stencil .7 .3 #f))
(ly:grob-set-property! grob 'stencil #f)))))))
music = \relative c' {
\time 1/4
\key a \major
d4
\key f \major
d
\key a \major
d
\key f \major
d
\key a \major
d
\break
\key c \major
d
\key a \major
d
\key c \major
d
}
\score
{
<<
\new Staff { \music }
\new Staff \with { \consists \Custom_key_engraver }
{ \music }
>>
\layout { }
}
HTH,
Harm
Re: printKeyCancellation, a way to never show key cancellations?, Keith OHara, 2012/12/02