lilypond-user
[Top][All Lists]
Advanced

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

Re: centering text on a measure


From: David Nalesnik
Subject: Re: centering text on a measure
Date: Tue, 4 Oct 2011 20:35:38 -0500

Hi Harm,

On Mon, Oct 3, 2011 at 5:29 PM, Thomas Morley <address@hidden> wrote:
Hi David, 

I'm only a musician and music-teacher without any previous programming-experience, trying to learn scheme and to dive into lilypond-internals deeper and deeper. So excuse me if I remark some moonshine. :)


You've pretty much described me :) 

Regarding the idea of defining custom-properties I thought: What could be done with such a property? After defining a name, the needed type of argument and the description - give it functionality. At first, I thought about rebuilding an existent renamed property. But how?


\version "2.14.2"

#(define (define-grob-custom-property symbol type? description)
  (if (not (equal? (object-property symbol 'backend-doc) #f))
      (ly:error (_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'backend-type? type?)
  (set-object-property! symbol 'backend-doc description)
  symbol)
 
#(define all-user-grob-custom-properties
  (map
   (lambda (x)
     (apply define-grob-custom-property x))

   `(
     (x-y-offset ,pair? "Rebuild extra-offset")
     )))
     
     \relative c' {
             \override TextScript #'x-y-offset = #'(1 . 1)
    c1-"hello"
     }

This does nothing (of course not)!

Maybe I'm wrong, but I thought adding an interface could be the solution. If not, how to do?


I tried to make your snippet work, but with no success.  I think this might be a question that's worth a separate thread (especially since this one has gotten so tangled!): Is it possible to create a new property with its own callback in Scheme? I really have no idea.  Perhaps this could be asked on the -devel list as well.

I revisited one of the earlier ideas in this thread, which was to use a TextSpanner as a device to center the text between the barlines.  I think I finally made it work, and I've attached what I came up with.  Adding markers makes it easy to specify a pair of grobs to stretch the spanner between  One limitation here is that spanners can only be attached to Item objects (so not to other spanners).  Another is that you can't attach the left end of the spanner to an object before the first note of the first measure.  And don't even think about spanners across the line break :)  

Overriding 'attach-dir in 'bound-details lets you choose which side of a grob to start and end on.

If you want to remove the line, leaving only the added text, comment out the lines I've indicated in the function.

Many thanks for all the fine functions you've created!!


You're really too kind!  Thank you so much for all the great suggestions you've given me and all the time you've invested in testing everything I send along. 

-David

Attachment: center-between3.ly
Description: Binary data

Attachment: center-between3.png
Description: PNG image


reply via email to

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