lilypond-1.3.28
[lilypond.git] / lily / g-script-column-engraver.cc
blobd7116dcf76060026f93ad17b0a6c33854201bd31
1 /*
2 g-script-column-engraver.cc -- implement G_script_column_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "g-script-column.hh"
12 #include "g-staff-side.hh"
14 /**
15 Find potentially colliding scripts, and put them in a
16 G_script_column, that will fix the collisions. */
17 class G_script_column_engraver : public Engraver
19 G_script_column *scol_p_;
20 Link_array<Item> script_l_arr_;
21 Link_array<G_staff_side_item> staff_side_l_arr_;
22 public:
23 G_script_column_engraver ();
24 VIRTUAL_COPY_CONS(Translator);
25 protected:
26 virtual void acknowledge_element (Score_element_info);
27 virtual void process_acknowledged ();
28 virtual void do_pre_move_processing ();
29 virtual void do_post_move_processing ();
33 G_script_column_engraver::G_script_column_engraver()
35 scol_p_ =0;
38 void
39 G_script_column_engraver::do_pre_move_processing ()
41 if (scol_p_)
43 typeset_element (scol_p_);
44 scol_p_ =0;
48 void
49 G_script_column_engraver::do_post_move_processing ()
51 script_l_arr_.clear ();
52 staff_side_l_arr_.clear ();
55 void
56 G_script_column_engraver::acknowledge_element( Score_element_info inf)
58 Item *thing = dynamic_cast<Item*>(inf.elem_l_);
59 if (!thing)
60 return;
62 Dimension_cache * parcache = thing->dim_cache_[Y_AXIS]->parent_l_;
63 if (!parcache || !thing)
64 return ;
66 Graphical_element *parent = parcache->element_l ();
68 if (G_staff_side_item * ss = dynamic_cast<G_staff_side_item*>(parent))
70 if (!ss->breakable_b ())
72 script_l_arr_.push (thing);
77 void
78 G_script_column_engraver::process_acknowledged ()
80 if (!scol_p_ && script_l_arr_.size () > 1)
82 scol_p_ = new G_script_column;
83 announce_element (Score_element_info (scol_p_, 0));
86 if (scol_p_)
88 for (int i=0; i < script_l_arr_.size (); i++)
89 scol_p_->add_staff_sided (script_l_arr_[i]);
90 script_l_arr_.clear ();
93 ADD_THIS_TRANSLATOR(G_script_column_engraver);