[Top][All Lists]

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

Re: Ottava printing at beginning of system

From: Valentin Petzel
Subject: Re: Ottava printing at beginning of system
Date: Tue, 30 Nov 2021 00:36:50 +0100

Hello Harm,

You’re right, I forgot a (begin ...) block. Seems like recalculating the 
stencil is not nescessary ...

Then (member grob (cdr siblings)) is hardly shorter than
(not (eq? grob (car siblings))), but requires to check against each entry in 
siblings, while the latter only needs to check against the first one (also you 
probably want memq for this one).
Thing is: We DO know that grob is a member of siblings!

About grob-original I suppose that you’re right. But if we are at that point 
you can omit (pair? siblings), as siblings will nescessarily be a non empty 
list. So I suppose the compact version should be

#(define (my-callback grob)
  (let* ((orig (ly:grob-original grob))
         (siblings (ly:spanner-broken-into orig)))
    (if (not (eq? grob (car siblings)))
        (ly:grob-set-property! grob 'text #f))))


Am Dienstag, 30. November 2021, 00:16:22 CET schrieb Thomas Morley:
> Am Mo., 29. Nov. 2021 um 22:49 Uhr schrieb Valentin Petzel 
> > Basically grob.after-line-breaking is a function that get’s called on grob
> > after line breaks are determined and allows us to do tweaks related to
> > line- breaking. So what this function does is:
> > 
> > If the ottava bracket is broken we check if the grob is a broken part.
> > This is done by getting all broken parts (the siblings) and checking if
> > grob is the first of these (implying that it is the first part which we
> > do not want to change) or not (in which case it is a broken part which we
> > want to change).
> > 
> > Then we we remove the text from these broken properties and recalculate
> > the
> > stencil (which will then be without text).
> > 
> > Cheers,
> > Valentin
> Well, actually you set 'stencil for the _first_ of siblings.
> Simply delete that:
> #(define (my-callback grob)
>   (let* (
>          ; have we been split?
>          (orig (ly:grob-original grob))
>          ; if yes, get the split pieces (our siblings)
>          (siblings (if (ly:grob? orig)
>                      (ly:spanner-broken-into orig) '() )))
>     (if (and (>= (length siblings) 2)
>               (not (eq? (car siblings) grob)))
>       (ly:grob-set-property! grob 'text #f))))
> Furthermore, I think ly:grob-original will always return a grob, thus
> the check for it could be removed.
> Probably a different if-condition may be cheaper (not sure about it,
> though), making for:
> #(define (my-callback grob)
>   (let* ((orig (ly:grob-original grob))
>          (siblings (ly:spanner-broken-into orig)))
>     (if (and (pair? siblings) (member grob (cdr siblings)))
>         (ly:grob-set-property! grob 'text #f))))
> Cheers,
>   Harm

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

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