X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmetronome-engraver.cc;h=aed027544c498ac6a65fe607f9e74b740b57283c;hb=19b37df119ff6ca84421d984fe1d33112ad08299;hp=24c5664f14ecc2f5cfd945ccdbde83c1debf678f;hpb=1d4914c023a672e0e80b9b9eafc123605f4c0f00;p=lilypond.git diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index 24c5664f14..aed027544c 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -26,9 +26,9 @@ using namespace std; #include "duration.hh" #include "grob-array.hh" #include "item.hh" +#include "music.hh" #include "stream-event.hh" #include "text-interface.hh" -#include "time-signature.hh" #include "translator.icc" @@ -40,13 +40,15 @@ public: protected: Item *text_; Grob *support_; + Grob *bar_; SCM last_duration_; SCM last_count_; SCM last_text_; DECLARE_ACKNOWLEDGER (break_aligned); - + DECLARE_ACKNOWLEDGER (grob); + protected: virtual void derived_mark () const; void stop_translation_timestep (); @@ -57,6 +59,7 @@ Metronome_mark_engraver::Metronome_mark_engraver () { text_ = 0; support_ = 0; + bar_ = 0; last_duration_ = SCM_EOL; last_count_ = SCM_EOL; last_text_ = SCM_EOL; @@ -70,12 +73,43 @@ Metronome_mark_engraver::derived_mark () const scm_gc_mark (last_text_); } +static bool +safe_is_member (SCM scm, SCM lst) +{ + return scm_list_p (lst) == SCM_BOOL_T + && scm_member (scm, lst) != SCM_BOOL_F; +} + +void +Metronome_mark_engraver::acknowledge_break_aligned (Grob_info info) +{ + Grob *g = info.grob (); + + if (text_ + && g->get_property ("break-align-symbol") + == ly_symbol2scm ("staff-bar")) + bar_ = g; + 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); + } +} + void -Metronome_mark_engraver::acknowledge_break_aligned (Grob_info inf) +Metronome_mark_engraver::acknowledge_grob (Grob_info info) { - Grob *s = inf.grob (); - if (text_ && Time_signature::has_interface (s)) - support_ = s; + Grob *g = info.grob (); + + if (text_) + for (SCM s = text_->get_property ("non-break-align-symbols"); + scm_is_pair (s); + s = scm_cdr (s)) + if (g->internal_has_interface (scm_car (s))) + text_->set_parent (g, X_AXIS); } void @@ -83,7 +117,11 @@ Metronome_mark_engraver::stop_translation_timestep () { if (text_) { - if (!support_) + if (text_->get_parent (X_AXIS) + && text_->get_parent (X_AXIS)->internal_has_interface (ly_symbol2scm ("multi-measure-rest-interface")) + && bar_) + text_->set_parent (bar_, X_AXIS); + else if (!support_) { /* Gardner Read "Music Notation", p.278 @@ -92,13 +130,16 @@ Metronome_mark_engraver::stop_translation_timestep () first notational element of the measure if no time signature is present in that measure). */ - Grob *mc = unsmob_grob (get_property ("currentMusicalColumn")); - text_->set_parent (mc, X_AXIS); + if (Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"))) + text_->set_parent (mc, X_AXIS); + else if (Grob *cc = unsmob_grob (get_property ("currentCommandColumn"))) + text_->set_parent (cc, X_AXIS); } text_->set_object ("side-support-elements", grob_list_to_grob_array (get_property ("stavesFound"))); text_ = 0; support_ = 0; + bar_ = 0; } } @@ -135,6 +176,7 @@ Metronome_mark_engraver::process_music () ADD_ACKNOWLEDGER (Metronome_mark_engraver, break_aligned); +ADD_ACKNOWLEDGER (Metronome_mark_engraver, grob); ADD_TRANSLATOR (Metronome_mark_engraver, /* doc */