source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "debug.hh"
+#include "warn.hh"
+#include "engraver.hh"
#include "rest-collision.hh"
-#include "rest-collision-engraver.hh"
-#include "collision.hh"
#include "note-column.hh"
+class Rest_collision_engraver : public Engraver
+{
+ Item* rest_collision_;
+ int rest_count_;
+ Link_array<Grob> 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);
+};
-IMPLEMENT_IS_TYPE_B1(Rest_collision_engraver, Engraver);
-ADD_THIS_TRANSLATOR(Rest_collision_engraver);
-
-Rest_collision_engraver::Rest_collision_engraver()
+Rest_collision_engraver::Rest_collision_engraver ()
{
- rest_collision_p_ =0;
+ rest_collision_ =0;
+ rest_count_ = 0;
}
void
-Rest_collision_engraver::process_acknowledged ()
+Rest_collision_engraver::process_acknowledged_grobs ()
{
- if (rest_collision_p_ || note_column_l_arr_.size () < 2)
+ if (rest_collision_
+ || note_columns_.is_empty ()
+ || !rest_count_
+ || (note_columns_.size () == rest_count_
+ && rest_count_ < 2))
return;
- rest_collision_p_ = new Rest_collision;
- announce_element (Score_element_info (rest_collision_p_, 0));
- for (int i=0; i< note_column_l_arr_.size (); i++)
- rest_collision_p_->add_column (note_column_l_arr_[i]);
+ rest_collision_ = make_item ("RestCollision");
+
+ announce_grob(rest_collision_, SCM_EOL);
+ for (int i=0; i < note_columns_.size (); i++)
+ Rest_collision::add_column (rest_collision_,note_columns_[i]);
}
void
-Rest_collision_engraver::acknowledge_element (Score_element_info i)
+Rest_collision_engraver::acknowledge_grob (Grob_info i)
{
- if (i.elem_l_->is_type_b (Note_column::static_name()))
- note_column_l_arr_.push ((Note_column*)i.elem_l_->access_Item ());
+ if (Note_column::has_interface (i.grob_))
+ {
+ note_columns_.push (i.grob_);
+ if (Note_column::has_rests (i.grob_))
+ rest_count_ ++;
+ }
}
void
-Rest_collision_engraver::do_pre_move_processing()
+Rest_collision_engraver::stop_translation_timestep ()
{
- if (rest_collision_p_)
+ if (rest_collision_)
{
- typeset_element (rest_collision_p_);
- rest_collision_p_ = 0;
+ typeset_grob (rest_collision_);
+ rest_collision_ = 0;
}
- note_column_l_arr_.clear ();
+ note_columns_.clear ();
+ rest_count_ = 0;
}
+
+ENTER_DESCRIPTION(Rest_collision_engraver,
+/* descr */ "Handles collisions of rests.",
+/* creats*/ "RestCollision",
+/* accepts */ "",
+/* acks */ "note-column-interface",
+/* reads */ "",
+/* write */ "");