Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / collision-engraver.cc
bloba645f36f7efc70df4701790d5882172693b85de0
1 /*
2 collision-engraver.cc -- implement Collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "engraver.hh"
10 #include "note-column.hh"
11 #include "note-collision.hh"
12 #include "axis-group-interface.hh"
13 #include "item.hh"
15 class Collision_engraver : public Engraver
17 Item *col_;
18 vector<Grob*> note_columns_;
20 protected:
21 DECLARE_ACKNOWLEDGER (note_column);
22 void process_acknowledged ();
23 void stop_translation_timestep ();
24 public:
25 TRANSLATOR_DECLARATIONS (Collision_engraver);
28 void
29 Collision_engraver::process_acknowledged ()
31 if (col_ || note_columns_.size () < 2)
32 return;
33 if (!col_)
34 col_ = make_item ("NoteCollision", SCM_EOL);
36 for (vsize i = 0; i < note_columns_.size (); i++)
37 Note_collision_interface::add_column (col_, note_columns_[i]);
40 void
41 Collision_engraver::acknowledge_note_column (Grob_info i)
43 if (Note_column::has_interface (i.grob ()))
45 /*should check Y axis? */
46 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
47 return;
49 if (to_boolean (i.grob ()->get_property ("ignore-collision")))
50 return;
52 note_columns_.push_back (i.grob ());
56 void
57 Collision_engraver::stop_translation_timestep ()
59 col_ = 0;
60 note_columns_.clear ();
63 Collision_engraver::Collision_engraver ()
65 col_ = 0;
68 #include "translator.icc"
70 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
72 ADD_TRANSLATOR (Collision_engraver,
73 /* doc */
74 "Collect @code{NoteColumns}, and as soon as there are two or"
75 " more, put them in a @code{NoteCollision} object.",
77 /* create */
78 "NoteCollision ",
80 /* read */
81 "",
83 /* write */