[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TextScript implements self-alignment interface
From: |
Trevor Bača |
Subject: |
Re: TextScript implements self-alignment interface |
Date: |
Wed, 6 Sep 2006 09:11:52 -0500 |
On 9/6/06, Markus Schneider <address@hidden> wrote:
Hi Trevor,
I derived this from the hint given regarding the OctavateEight in
define-grobs.scm:
\override TextScript #'X-offset =
#(ly:make-simple-closure
`(,+ ,(ly:make-simple-closure (list
ly:self-alignment-interface::x-aligned-on-self))
,(ly:make-simple-closure (list
ly:self-alignment-interface::centered-on-x-parent))))
Tested in 2.9.17 (W2K).
Hi Markus,
This is exactly what I was looking for. Wow, thanks.
The Scheme code passed in as the last argument to \override is a
mouthful and so it's possible to save the whole thing to a named
variable. And, with that, here's an example of centering TextScripts
on their (NoteHead) X-parents, combined with moving around the
self-alignment-X of three different TextScripts.
%%% BEGIN X-PARENT CENTERING SNIPPET %%%
\version "2.9.16"
textScriptCenterOnParent = \override TextScript #'X-offset =
#(ly:make-simple-closure
`(,+ ,(ly:make-simple-closure (list
ly:self-alignment-interface::x-aligned-on-self))
,(ly:make-simple-closure (list
ly:self-alignment-interface::centered-on-x-parent))))
\new Staff {
\textScriptCenterOnParent
\override TextScript #'self-alignment-X = #left
c'4_\markup { MMM }
\override TextScript #'self-alignment-X = #center
c'4_\markup { MMM }
\override TextScript #'self-alignment-X = #right
c'4_\markup { MMM }
}
%%% END X-PARENT SNIPPET %%%
Also, since I've been lazy about actually learning Scheme, your
solution is educational because it taught me how transcribe the
craziest bits of the grob definition code in scr/define-grobs.scm into
Scheme code I can stick inside a normal .ly file.
I'll add this to the archive so I can find it easily next time I'm
wanting to copy over the behavior of any existing grob:
In the OctavateEight definition in scm/define-grobs.scm we find ...
<snip>
(X-offset . ,(ly:make-simple-closure
`(,+ ,(ly:make-simple-closure (list
ly:self-alignment-interface::x-aligned-on-self))
,(ly:make-simple-closure (list
ly:self-alignment-interface::centered-on-x-parent)))))
<snip>
... which then, in an ly input file, becomes ...
\override MyGrob #'X-offset =
#(ly:make-simple-closure
`(,+ ,(ly:make-simple-closure (list
ly:self-alignment-interface::x-aligned-on-self))
,(ly:make-simple-closure (list
ly:self-alignment-interface::centered-on-x-parent))))
... which looks like a pretty direct mapping: the last argument to
\override begins, like always, with a hash sign, whereas the second
element of the pair in scm/define-grobs.scm starts with a comma
instead.
Thanks again.
--
Trevor Bača
address@hidden
notehead-centering.png
Description: PNG image