2002->2003
[lilypond.git] / lily / rest-collision-engraver.cc
blob5ae86b5413c81149610b9d57ba1a83e4772577b0
1 /*
2 rest-collision-reg.cc -- implement Rest_collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "warn.hh"
10 #include "rest-collision.hh"
11 #include "engraver.hh"
12 #include "note-collision.hh"
13 #include "note-column.hh"
15 class Rest_collision_engraver : public Engraver
17 Item* rest_collision_;
19 Link_array<Grob> note_columns_;
20 protected:
21 virtual void acknowledge_grob (Grob_info);
22 virtual void process_acknowledged_grobs ();
23 virtual void stop_translation_timestep ();
24 public:
25 TRANSLATOR_DECLARATIONS(Rest_collision_engraver);
30 Rest_collision_engraver::Rest_collision_engraver ()
32 rest_collision_ =0;
35 void
36 Rest_collision_engraver::process_acknowledged_grobs ()
38 if (rest_collision_ || note_columns_.size () < 2)
39 return;
41 rest_collision_ = new Item (get_property ("RestCollision"));
43 announce_grob(rest_collision_, SCM_EOL);
44 for (int i=0; i< note_columns_.size (); i++)
45 Rest_collision::add_column (rest_collision_,note_columns_[i]);
48 void
49 Rest_collision_engraver::acknowledge_grob (Grob_info i)
51 if (Note_column::has_interface (i.grob_))
52 note_columns_.push (i.grob_);
55 void
56 Rest_collision_engraver::stop_translation_timestep ()
58 if (rest_collision_)
60 typeset_grob (rest_collision_);
61 rest_collision_ = 0;
63 note_columns_.clear ();
65 ENTER_DESCRIPTION(Rest_collision_engraver,
66 /* descr */ "Handles collisions of rests.",
67 /* creats*/ "RestCollision",
68 /* accepts */ "",
69 /* acks */ "note-column-interface",
70 /* reads */ "",
71 /* write */ "");