[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Display Question Mark at center of a measure
From: |
Jean Abou Samra |
Subject: |
Re: Display Question Mark at center of a measure |
Date: |
Fri, 14 Jan 2022 13:10:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 |
Le 14/01/2022 à 10:39, Lukas-Fabian Moser a écrit :
Hi Rajesh,
Am 14.01.22 um 01:44 schrieb Rajesh Baskar:
I'm tying to display a question mark at the center of the 1st measure
in a 2 measure score.
I have got this working with hard-coding the offset (3 . 4.5) but
this will not work when the number of notes in a measure is larger
than 3. Is there a way to get this to work dynamically where the
question mark moves to the center of the measure irrespective of the
length of a measure.
Please try to remove everything in your examples not actually related
to the problem at hand (here, for example, everything having to do
with MIDI, proportional notation, boxed measure counters etc.).
What comes to mind is that your question mark is exactly in the
position where you would normally expect a whole bar rest. So how about:
\version "2.22.0"
#(define (center-stencil stil)
(ly:stencil-aligned-to
(ly:stencil-aligned-to stil X CENTER)
Y CENTER))
This is predefined under the name
'centered-stencil' :-)
questionMarkMultiMeasureRest = {
\override MultiMeasureRest.stencil =
#(grob-transformer
'stencil
(lambda (grob default)
(ly:stencil-translate-axis
(center-stencil (ly:text-interface::print grob))
(interval-center (ly:stencil-extent default X))
X)))
\override MultiMeasureRest.text = "?"
\override MultiMeasureRest.font-size = 7
\override MultiMeasureRest.color = "#6A00F4"
}
\new Staff {
\clef bass
<<
{ \hideNotes b2 c }
\new Voice {
\questionMarkMultiMeasureRest
R1
}
>>
\unHideNotes a2 c'4 g
}
One could of course wrap the simultaenous addition of the tweaked full
bar rest in a music function.
The reason I'm using such a comparatively complex stencil override is
that the default positioning of the MultiMeasureRest (which is what we
want here) is handled in the default stencil; if we overwrite that
function completely, we don't get the nice centered alignment we want.
To add another solution, in current development versions,
you can do this:
\version "2.23.5"
questionMarkMultiMeasureRest = \once {
\override MultiMeasureRest.stencil = #centered-text-interface::print
\override MultiMeasureRest.text = \markup \vcenter "?"
\override MultiMeasureRest.self-alignment-X = #CENTER
\override MultiMeasureRest.font-size = 7
\override MultiMeasureRest.color = "#6A00F4"
}
\new Staff {
\clef bass
<<
{ \hideNotes b2 c }
\new Voice {
\questionMarkMultiMeasureRest
R1
}
>>
\unHideNotes a2 c'4 g
}
I'm not sure if it's much simpler to find, but
it doesn't require Scheme at all.
Cheers,
Jean