From 6d28aebbaaab1be9961a00bf15a1ef93acb91e30 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Mon, 6 Sep 2010 22:49:28 +0100 Subject: [PATCH] Fix metronome alignment. Don't align on KeySignature unless explicitly requested via 'break-align-symbols and make order of 'break-align-symbols significant. * remove `key-signature' from 'break-align-symbols * acknowledge break_alignment, and set this as X-parent instead of break_aligned, but only if found break_aligned is visible * add regression test to test ordering * tweak existing test to reflect change in default for 'break-align-symbols --- input/regression/metronome-marking-align-order.ly | 28 ++++++++++++ input/regression/metronome-marking-break-align.ly | 56 ++++++++++++++--------- lily/metronome-engraver.cc | 21 +++++++-- scm/define-grobs.scm | 2 +- 4 files changed, 80 insertions(+), 27 deletions(-) create mode 100644 input/regression/metronome-marking-align-order.ly rewrite input/regression/metronome-marking-break-align.ly (79%) diff --git a/input/regression/metronome-marking-align-order.ly b/input/regression/metronome-marking-align-order.ly new file mode 100644 index 0000000000..8ec27a5843 --- /dev/null +++ b/input/regression/metronome-marking-align-order.ly @@ -0,0 +1,28 @@ +\version "2.13.33" + +\header { + texidoc = "Metronome marks respect symbol order in +@code{break-align-symbols}. + +In this example, the default is changed to +@code{'(time-signature key-signature)}: since @code{key-signature} +is second in the list, the mark should only be aligned with the key +signature if there is no time signature present, as in the second +measure. +" +} + +\paper { + ragged-right = ##t +} + +\relative c' { + \override Staff.KeySignature #'break-align-anchor-alignment = #LEFT + \override Score.MetronomeMark #'break-align-symbols = #'(time-signature key-signature) + \key c \minor + \tempo "Time" + c1 + \key as \major + \tempo "Key" + c1 +} diff --git a/input/regression/metronome-marking-break-align.ly b/input/regression/metronome-marking-break-align.ly dissimilarity index 79% index 4205904806..9d0149fde9 100644 --- a/input/regression/metronome-marking-break-align.ly +++ b/input/regression/metronome-marking-break-align.ly @@ -1,21 +1,35 @@ -\header { - - - texidoc = "@code{\\tempo} are aligned with Tempo, Key or first musical -element. - -" - -} -\version "2.13.24" - -\layout { - line-width = 50\mm -} -\relative { - \tempo "T-first" c1\mark \default \tempo "T-note" c \break - \tempo "T-break" c \tempo "T-rest" R - \break - \time 8/8 \tempo "T-time" R - \key as \major \tempo "T-key" R -} +\version "2.13.24" + +\header { + texidoc = "@code{\\tempo} marks are aligned with the time signature +or first musical element unless the first element is a multi-measure +rest: in this case, the tempo mark is aligned with the bar line. + +By overriding @code{break-align-symbols} the default alignment can be +changed, as shown by the final metronome mark in this snippet, aligned +with a key signature. +" +} + +\layout { + line-width = 50\mm +} + +\relative c' { + \tempo "T-first" + c1 + \mark \default + \tempo "T-note" + c1 \break + \tempo "T-break" + c1 + \tempo "T-rest" + R1 \break + \time 8/8 + \tempo "T-time" + R1 + \override Score.MetronomeMark #'break-align-symbols = #'(key-signature) + \key as \major + \tempo "T-key" + R1 +} diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index aed027544c..d55455f23d 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -47,6 +47,7 @@ protected: SCM last_text_; DECLARE_ACKNOWLEDGER (break_aligned); + DECLARE_ACKNOWLEDGER (break_alignment); DECLARE_ACKNOWLEDGER (grob); protected: @@ -92,11 +93,20 @@ Metronome_mark_engraver::acknowledge_break_aligned (Grob_info info) else if (text_ && !support_ && safe_is_member (g->get_property ("break-align-symbol"), - text_->get_property ("break-align-symbols"))) - { - support_ = g; - text_->set_parent (g, X_AXIS); - } + text_->get_property ("break-align-symbols")) + && Item::break_visible (g)) + support_ = g; +} + +void +Metronome_mark_engraver::acknowledge_break_alignment (Grob_info info) +{ + Grob *g = info.grob (); + + if (text_ + && support_ + && dynamic_cast (g)) + text_->set_parent (g, X_AXIS); } void @@ -176,6 +186,7 @@ Metronome_mark_engraver::process_music () ADD_ACKNOWLEDGER (Metronome_mark_engraver, break_aligned); +ADD_ACKNOWLEDGER (Metronome_mark_engraver, break_alignment); ADD_ACKNOWLEDGER (Metronome_mark_engraver, grob); ADD_TRANSLATOR (Metronome_mark_engraver, diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 71a167d80a..7d6c1b3dc1 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1170,7 +1170,7 @@ ,(ly:make-simple-closure (list ly:self-alignment-interface::x-aligned-on-self))))) (self-alignment-X . ,LEFT) - (break-align-symbols . (key-signature time-signature)) + (break-align-symbols . (time-signature)) (non-break-align-symbols . (multi-measure-rest-interface)) (non-musical . #t) (meta . ((class . Item) -- 2.11.4.GIT