X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faccidental-engraver.cc;h=aaf8307cd7932b660429f8d10d82b30a17006417;hb=95a2da1c1a4837109b1f148539c074c00b73f340;hp=c7f956f9af5da3be856d3fb0972fe0ba05e56a6f;hpb=883e317d51c5e50011bc0e764a785631e5ea8689;p=lilypond.git diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index c7f956f9af..aaf8307cd7 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2006 Han-Wen Nienhuys + (c) 1997--2007 Han-Wen Nienhuys Modified 2001--2002 by Rune Zedeler */ @@ -17,6 +17,7 @@ #include "pitch.hh" #include "protected-scm.hh" #include "rhythmic-head.hh" +#include "separation-item.hh" #include "side-position-interface.hh" #include "stream-event.hh" #include "tie.hh" @@ -50,7 +51,6 @@ Accidental_entry::Accidental_entry () class Accidental_engraver : public Engraver { - int get_bar_number (); void update_local_key_signature (SCM new_signature); void create_accidental (Accidental_entry *entry, bool, bool); Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans, bool); @@ -64,6 +64,7 @@ protected: void acknowledge_arpeggio (Grob_info); void acknowledge_rhythmic_head (Grob_info); void acknowledge_finger (Grob_info); + void acknowledge_note_column (Grob_info); void stop_translation_timestep (); void process_acknowledged (); @@ -81,6 +82,7 @@ public: vector accidentals_; vector ties_; + vector note_columns_; }; /* @@ -294,21 +296,6 @@ check_pitch_against_rules (Pitch const &pitch, Context *origin, return result; } -int -Accidental_engraver::get_bar_number () -{ - SCM barnum = get_property ("internalBarNumber"); - SCM smp = get_property ("measurePosition"); - - int bn = robust_scm2int (barnum, 0); - - Moment mp = robust_scm2moment (smp, Moment (0)); - if (mp.main_part_ < Rational (0)) - bn--; - - return bn; -} - void Accidental_engraver::process_acknowledged () { @@ -316,7 +303,7 @@ Accidental_engraver::process_acknowledged () { SCM accidental_rules = get_property ("autoAccidentals"); SCM cautionary_rules = get_property ("autoCautionaries"); - int barnum = get_bar_number (); + int barnum = measure_number (context()); for (vsize i = 0; i < accidentals_.size (); i++) { @@ -351,12 +338,14 @@ Accidental_engraver::process_acknowledged () /* Cannot look for ties: it's not guaranteed that they reach us before the notes. */ - if (acc.need_acc - && !note->in_event_class ("trill-span-event")) - create_accidental (&accidentals_[i], acc.need_restore, cautionary); + if (!note->in_event_class ("trill-span-event")) + { + if (acc.need_acc) + create_accidental (&accidentals_[i], acc.need_restore, cautionary); - if (forced || cautionary) - accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); + if (forced || cautionary) + accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); + } } } } @@ -368,8 +357,6 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, { Stream_event *note = entry->melodic_; Grob *support = entry->head_; - Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); - bool as_suggestion = to_boolean (entry->origin_->get_property ("suggestAccidentals")); Grob *a = 0; if (as_suggestion) @@ -383,7 +370,6 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, a->set_property ("restore-first", SCM_BOOL_T); } - a->set_property ("alteration", scm_from_int (pitch->get_alteration () * Rational (4))); entry->accidental_ = a; } @@ -420,9 +406,6 @@ Accidental_engraver::make_standard_accidental (Stream_event *note, Side_position_interface::add_support (a, right_objects_[i]); a->set_parent (note_head, Y_AXIS); - if (cautionary) - a->set_property ("cautionary", SCM_BOOL_T); - if (!accidental_placement_) accidental_placement_ = make_item ("AccidentalPlacement", @@ -477,12 +460,12 @@ Accidental_engraver::stop_translation_timestep () } for (vsize i = accidentals_.size (); i--;) - { - int barnum = get_bar_number (); - + { Stream_event *note = accidentals_[i].melodic_; Context *origin = accidentals_[i].origin_; + int barnum = measure_number (origin); + Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); if (!pitch) continue; @@ -497,7 +480,8 @@ Accidental_engraver::stop_translation_timestep () && origin->where_defined (ly_symbol2scm ("localKeySignature"), &localsig)) { bool change = false; - if (accidentals_[i].tied_) + if (accidentals_[i].tied_ + && !(to_boolean (accidentals_[i].accidental_->get_property ("forced")))) { /* Remember an alteration that is different both from @@ -527,6 +511,10 @@ Accidental_engraver::stop_translation_timestep () } } + if (accidental_placement_) + for (vsize i = 0; i < note_columns_.size (); i++) + Separation_item::add_conditional_item (note_columns_[i], accidental_placement_); + accidental_placement_ = 0; accidentals_.clear (); left_objects_.clear (); @@ -564,6 +552,12 @@ Accidental_engraver::acknowledge_tie (Grob_info info) ties_.push_back (dynamic_cast (info.grob ())); } +void +Accidental_engraver::acknowledge_note_column (Grob_info info) +{ + note_columns_.push_back (info.grob ()); +} + void Accidental_engraver::acknowledge_arpeggio (Grob_info info) { @@ -588,26 +582,29 @@ ADD_ACKNOWLEDGER (Accidental_engraver, arpeggio); ADD_ACKNOWLEDGER (Accidental_engraver, finger); ADD_ACKNOWLEDGER (Accidental_engraver, rhythmic_head); ADD_ACKNOWLEDGER (Accidental_engraver, tie); +ADD_ACKNOWLEDGER (Accidental_engraver, note_column); ADD_TRANSLATOR (Accidental_engraver, - - "Make accidentals. " - "Catch note heads, ties and notices key-change events. " - "This engraver usually lives at Staff level, but " - "reads the settings for Accidental at @code{Voice} level, " - "so you can @code{\\override} them at @code{Voice}. ", - - /* grobs */ + /* doc */ + "Make accidentals." + " Catch note heads, ties and notices key-change events." + " This engraver usually lives at Staff level, but" + " reads the settings for Accidental at @code{Voice} level," + " so you can @code{\\override} them at @code{Voice}.", + + /* create */ "Accidental " - "AccidentalCautionary" - "AccidentalSuggestion", + "AccidentalCautionary " + "AccidentalSuggestion ", - /* props */ + /* read */ "autoAccidentals " "autoCautionaries " "internalBarNumber " "extraNatural " "harmonicAccidentals " "localKeySignature ", + + /* write */ "localKeySignature " );