[Top][All Lists]

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

Re: How to catch the current height of a StaffGroup?

From: address@hidden
Subject: Re: How to catch the current height of a StaffGroup?
Date: Wed, 23 May 2012 19:38:32 +0200

On 23 mai 2012, at 19:19, Thomas Morley wrote:

> 2012/5/23 Urs Liska <address@hidden>:
>> but shouldn't a standard barline have the desired length by default?
> Of course, but the new BreathingSign-stencil is only to visualize that
> I've got the correct value.
> And a BarLine lives in Staff-context but I want the "StaffGroup-size".
> Trying:
>                \override Score.BarLine #'stencil =
>                  #(lambda (grob)
>                    (let* ((stil (ly:bar-line::print grob))
>                           (stil-ext-y (interval-length
> (ly:stencil-extent stil Y))))
>                           (newline)(display stil-ext-y)
>                           stil))
> returns every time the same value, in this case: 3.9975
> As expected.

Try the buddy engraver!

buddyEngraver =
    #(let ((match-list '())
           (name-list '()))
         (cons 'acknowledgers
                 (cons 'grob-interface
                       (lambda (engraver grob source-engraver)
                               (let ((name (ly:grob-property grob 'my-name))
                                     (searching (ly:grob-property grob 
                                    (set! name-list (cons (cons name grob) 
                                    (set! match-list (append (map (lambda (x) 
(cons name x)) searching) match-list)))))))
         (cons 'finalize
              (lambda (trans)
                  (lambda (x) ;(format #t "MATCHING ~a\n" x)
                    (let ((grob1 (assoc-get (car x) name-list))
                          (grob2 (assoc-get (cdr x) name-list)))
                    (ly:grob-set-property! grob2 'buddies (cons (cons (car x) 
grob1) (ly:grob-property grob2 'buddies)))
                    (ly:grob-set-property! grob1 'buddies (cons (cons (cdr x) 
grob2) (ly:grob-property grob1 'buddies)))))

Then, \layout \context { \Staff \consists \buddyEngraver }

If you do something like \override Staff.BarLine #'my-name = #'foo in one staff 
and \override Staff.BarLine #'my-name = #'bar in another and then \override 
BreathingSign #'searching = #'(foo bar) then BreathingSign will have a property 
'buddies set with two buddies (the two barlines). You can then find their 
positions via the normal grob-relative-position-finding functions.


reply via email to

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