Rehearsal marks wrongly placed with Mark_engraver moved to StaffGroup and lyrics above staff
\version "2.23.10"
\layout {
\context {
\Score
\remove Mark_engraver
\remove Staff_collecting_engraver
}
\context {
\StaffGroup
\consists Mark_engraver
\consists Staff_collecting_engraver
}
}
\new StaffGroup <<
\new Staff = "staff" <<
{ s1 \mark \default s1 }
\new Voice = "voice" { a'1~ 1 }
>>
\new Staff { c'1~ 1 }
\new Lyrics \with { alignAboveContext = "staff" }
\lyricsto "voice" { foo __ }
>>
In this snippet, there are two Staff contexts and one Lyrics context within a StaffGroup. The Mark_engraver
is moved to StaffGroup
(along with Staff_collecting_engraver
, which should always follow it), so the rehearsal marks are expected to be printed above the whole StaffGroup. (The usefulness of moving the engraver to StaffGroup doesn't appear here because the example is reduced, but it could be one StaffGroup in a larger score.) Yet, the mark places itself below the lyrics.
The problem apparently lies in the Vertical_align_engraver
. alignAboveContext
is honored in the code path for creating the top-level VerticalAlignment
, but not in the one for StaffGrouper
. Consequently, the elements
array of StaffGrouper
contains VerticalAxisGroup
s in the order in which contexts have been declared, not the order in which they are laid out. When the rehearsal mark tries to find the top vertical axis group to align to, the first one it finds in this order is the upper staff.
Cf. also
#3409 (comment 732678506)
This whole dance is suboptimal. Independently of fixing the Staff_grouper_engraver
, it would be nice to get rid of ly:staff-position-interface::move-to-extremal-staff
and find another way to have outside-staff-priority
work on rehearsal mark (allowing it to blend the marks with other elements from the top staff).
CC @lemzwerg, this relates to https://lists.gnu.org/archive/html/lilypond-user/2022-06/msg00011.html.