Re: centering text on a measure

2011-09-03 Thread Trevor Daniels


David Nalesnik


However, I'd like to be able to
center the text on the measure regardless of what's in it (or, by 
extension,
center it between items of my choosing).  I'm hoping that there's 
a way to
do this without relying on 'extra-offset, so that other grobs will 
move up

to avoid collisions.  Is this possible?


Hhm.  Can't think of a way without doing some
coding.  It would be nice if TextSpanner could
centre its text between the left and right
bounds (like the number on a tuplet bracket)
but it doesn't, AFAIK.  It would be a nice
extension to request, though.

MultiMeasureRestText can also be moved with
\once \override MultiMeasureRestText #'self-alignment-X = #-2
and this will enable collisions to be avoided
at the new position.

Trevor




___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: centering text on a measure

2011-09-03 Thread Trevor Daniels


David Nalesnik wrote Saturday, September 03, 2011 6:36 PM


I've adapted the snippet for centering text on hairpins
http://lsr.dsi.unimi.it/LSR/Snippet?id=233
to give an approximation of this.  Basically,  I've replaced the 
default
TextSpanner stencil with a blank with the same extents to which I 
add a
text.  The argument allows you to position this text using an 
alignment
value.  The example shows a few alignments over one-measure groups 
on the
first line, two-measure groups on the second.  (Unfortunately, if 
I don't
blank out the default stencil, the text appears on top of the 
extender line,
and of course the distance between the individual dashes or dots 
isn't
adapted to make for a nice fit.  Insert bad memories of another 
notation

program here.)


You can kill the extender line by setting
'dash-period negative, if that helps.

Now, I suppose the text's position is dependent on the NoteColumn 
grobs to
which the spanner is attached.  Would it be possible to reset the 
attachment
point to another grob? (I could use offsets as in the original 
function, but

that will once again bring in the 'extra-offset issue.)


Not sure I understand.  The spanner start and end
points are defined by the positions of \startTextSpanner
and \stopTextSpanner.  ??

I agree that this would be great feature for LilyPond.  How would 
I go about

making a request?


Well, you could add a snippet to the LSR to
show how you've done it.  This might then
find its way into the documentation if others
like it.  Instructions are on the LSR site:
http://lsr.dsi.unimi.it/, see Contributing.

And you could send a request for an enhancement
to bug-lilyp...@gnu.org, explaining why it would
be useful, and, if you have added a snippet to the
LSR, pointing to it.

Trevor



___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: centering text on a measure

2011-09-01 Thread Trevor Daniels

Hi David

Perhaps you could turn this idea into a music function:

\relative c'' {
 a4 a a a |
 
   { a4 a a a | }
   {
 \once \override MultiMeasureRest #'transparent = ##t
  R1_XIII |
   }
 
 a4 a a a |
}

Trevor

- Original Message - 
From: David Nalesnik david.nales...@gmail.com

To: lilypond-user lilypond-u...@gnu.org
Cc: Lilypond Dev lilypond-devel@gnu.org
Sent: Thursday, September 01, 2011 5:27 AM
Subject: centering text on a measure



Hi all,

I've been experimenting with a way to center text on measures.  (I 
create a
lot of exercises with blanks or roman numerals between the staff, 
and it's
nice not to need to position each one individually by trial and 
error.)
I've come up with the following function which works, but I wonder 
if

there's a simpler or more correct way to go about this.

Also, I'm wondering why I can't apply this function to 'X-offset 
rather than
'extra-offset.  I've attached a version of the file which returns 
an
'X-offset value, and it returns an error (also with 
'self-alignment-X).  Is

there a way to fix this?

Any suggestions will be much appreciated!

Thanks,
David

\version 2.15.8

#(define (bounding-coords grob-coord bar-coords end-coord)
  (if (null? (cdr bar-coords))
  (cons (car bar-coords) end-coord)
  (if (and ( (car bar-coords) grob-coord)
 ( (cadr bar-coords) grob-coord))
  (cons (car bar-coords)(cadr bar-coords))
  (bounding-coords grob-coord (cdr bar-coords) 
end-coord


#(define (center-on-measure grob)
  (let* ((sys (ly:grob-system grob))
 (array (ly:grob-object sys 'all-elements))
 (grob-coord (interval-center (ly:grob-extent grob sys 
X)))
 (grob-name (lambda (x) (assq-ref (ly:grob-property x 
'meta)

'name)))
 (bars (filter (lambda (x) (eq? 'NonMusicalPaperColumn 
(grob-name

x)))
 (ly:grob-array-list array)))
 (bar-coords (sort (map (lambda (x) (interval-center
(ly:grob-extent x sys X))) bars) ))
 (bounds (bounding-coords grob-coord bar-coords (cdr
(ly:grob-extent sys sys X)

(cons
  (- (- grob-coord (/ (+ (car bounds) (cdr bounds)) 2)))
  0)))

{
 \override TextScript #'extra-offset = #center-on-measure
 \repeat unfold 10 { s1_|^| }
 s2_|^|
}








___
lilypond-user mailing list
lilypond-u...@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user





___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel