* lily/music-iterator.cc (quit, do_quit): new function: break link
[lilypond.git] / lily / script-column-engraver.cc
blob6141568630d6b851dc49ceb3bfe312c74977ad81
1 /*
2 script-column-engraver.cc -- implement Script_column_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "script-column.hh"
12 #include "item.hh"
13 #include "side-position-interface.hh"
15 /**
16 Find potentially colliding scripts, and put them in a
17 Script_column, that will fix the collisions. */
18 class Script_column_engraver : public Engraver
20 Grob *scol_;
21 Link_array<Item> scripts_;
23 public:
24 TRANSLATOR_DECLARATIONS(Script_column_engraver);
25 protected:
26 virtual void acknowledge_grob (Grob_info);
27 virtual void process_acknowledged_grobs ();
28 virtual void stop_translation_timestep ();
29 virtual void start_translation_timestep ();
33 Script_column_engraver::Script_column_engraver ()
35 scol_ =0;
38 void
39 Script_column_engraver::stop_translation_timestep ()
41 if (scol_)
43 typeset_grob (scol_);
44 scol_ =0;
48 void
49 Script_column_engraver::start_translation_timestep ()
51 scripts_.clear ();
55 void
56 Script_column_engraver::acknowledge_grob (Grob_info inf)
58 Item *thing = dynamic_cast<Item*> (inf.grob_);
59 if (thing && Side_position_interface::has_interface (inf.grob_)) // ugh FIXME
61 if (!Item::breakable_b (thing)
62 && Side_position_interface::get_axis (inf.grob_) == Y_AXIS)
64 scripts_.push (thing);
69 void
70 Script_column_engraver::process_acknowledged_grobs ()
72 if (!scol_ && scripts_.size () > 1)
74 scol_ = new Item (get_property ("ScriptColumn"));
75 announce_grob(scol_, SCM_EOL);
78 if (scol_)
80 for (int i=0; i < scripts_.size (); i++)
81 Script_column::add_staff_sided (scol_, scripts_[i]);
82 scripts_.clear ();
87 ENTER_DESCRIPTION(Script_column_engraver,
88 /* descr */ "",
89 /* creats*/ "ScriptColumn",
90 /* acks */ "side-position-interface",
91 /* reads */ "",
92 /* write */ "");