lilypond-user
[Top][All Lists]
Advanced

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

Re: Display Question Mark at center of a measure


From: Lukas-Fabian Moser
Subject: Re: Display Question Mark at center of a measure
Date: Fri, 14 Jan 2022 10:39:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

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))

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.

Lukas




reply via email to

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