X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frest-collision-engraver.cc;h=0291bfae3b75430aab0d5469fb06edba8ddffa56;hb=6d7cb5da867db7a077f02fb10f969394b11e7390;hp=b5aaa7722e31360a6cd8be93fa836b2e58230c73;hpb=a6ee9dcd388111e842064a8d46ab06c4897a00d2;p=lilypond.git diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index b5aaa7722e..0291bfae3b 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -3,45 +3,47 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2002 Han-Wen Nienhuys + (c) 1997--2004 Han-Wen Nienhuys */ #include "warn.hh" -#include "rest-collision.hh" #include "engraver.hh" -#include "note-collision.hh" +#include "rest-collision.hh" #include "note-column.hh" class Rest_collision_engraver : public Engraver { Item* rest_collision_; - + int rest_count_; Link_array note_columns_; protected: virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); virtual void stop_translation_timestep (); public: - TRANSLATOR_DECLARATIONS(Rest_collision_engraver); + TRANSLATOR_DECLARATIONS (Rest_collision_engraver); }; - - Rest_collision_engraver::Rest_collision_engraver () { - rest_collision_ =0; + rest_collision_ = 0; + rest_count_ = 0; } void Rest_collision_engraver::process_acknowledged_grobs () { - if (rest_collision_ || note_columns_.size () < 2) + if (rest_collision_ + || note_columns_.is_empty () + || !rest_count_ + || (note_columns_.size () == rest_count_ + && rest_count_ < 2)) return; - rest_collision_ = new Item (get_property ("RestCollision")); + rest_collision_ = make_item ("RestCollision", SCM_EOL); - announce_grob(rest_collision_, SCM_EOL); - for (int i=0; i< note_columns_.size (); i++) + + for (int i = 0; i < note_columns_.size (); i++) Rest_collision::add_column (rest_collision_,note_columns_[i]); } @@ -49,22 +51,25 @@ void Rest_collision_engraver::acknowledge_grob (Grob_info i) { if (Note_column::has_interface (i.grob_)) - note_columns_.push (i.grob_); + { + note_columns_.push (i.grob_); + if (Note_column::has_rests (i.grob_)) + rest_count_ ++; + } } void Rest_collision_engraver::stop_translation_timestep () { - if (rest_collision_) - { - typeset_grob (rest_collision_); - rest_collision_ = 0; - } + rest_collision_ = 0; note_columns_.clear (); + rest_count_ = 0; } -ENTER_DESCRIPTION(Rest_collision_engraver, + +ADD_TRANSLATOR (Rest_collision_engraver, /* descr */ "Handles collisions of rests.", /* creats*/ "RestCollision", -/* acks */ "note-column-interface", +/* accepts */ "", +/* acks */ "note-column-interface", /* reads */ "", /* write */ "");