(all-grob-descriptions): remove gap from
[lilypond.git] / lily / rest-collision-engraver.cc
blob149ad7983122ba9efb576e072add9b570b0e6570
1 /*
2 rest-collision-reg.cc -- implement Rest_collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "warn.hh"
10 #include "engraver.hh"
11 #include "rest-collision.hh"
12 #include "note-column.hh"
14 class Rest_collision_engraver : public Engraver
16 Item* rest_collision_;
17 int rest_count_;
18 Link_array<Grob> note_columns_;
19 protected:
20 virtual void acknowledge_grob (Grob_info);
21 virtual void process_acknowledged_grobs ();
22 virtual void stop_translation_timestep ();
23 public:
24 TRANSLATOR_DECLARATIONS (Rest_collision_engraver);
27 Rest_collision_engraver::Rest_collision_engraver ()
29 rest_collision_ =0;
30 rest_count_ = 0;
33 void
34 Rest_collision_engraver::process_acknowledged_grobs ()
36 if (rest_collision_
37 || note_columns_.is_empty ()
38 || !rest_count_
39 || (note_columns_.size () == rest_count_
40 && rest_count_ < 2))
41 return;
43 rest_collision_ = make_item ("RestCollision");
45 announce_grob (rest_collision_, SCM_EOL);
46 for (int i=0; i < note_columns_.size (); i++)
47 Rest_collision::add_column (rest_collision_,note_columns_[i]);
50 void
51 Rest_collision_engraver::acknowledge_grob (Grob_info i)
53 if (Note_column::has_interface (i.grob_))
55 note_columns_.push (i.grob_);
56 if (Note_column::has_rests (i.grob_))
57 rest_count_ ++;
61 void
62 Rest_collision_engraver::stop_translation_timestep ()
64 if (rest_collision_)
66 typeset_grob (rest_collision_);
67 rest_collision_ = 0;
69 note_columns_.clear ();
70 rest_count_ = 0;
73 ENTER_DESCRIPTION (Rest_collision_engraver,
74 /* descr */ "Handles collisions of rests.",
75 /* creats*/ "RestCollision",
76 /* accepts */ "",
77 /* acks */ "note-column-interface",
78 /* reads */ "",
79 /* write */ "");