]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-row-engraver.cc
* lily/*.cc, lily/include/*.hh: eliminate dummy arguments from
[lilypond.git] / lily / script-row-engraver.cc
1 /* 
2   script-row-engraver.cc -- implement Script_row_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
7   
8 */
9
10
11 #include "engraver.hh"
12 #include "script-column.hh"
13 #include "side-position-interface.hh"
14
15 #include "translator.icc"
16
17
18 /**
19    Find potentially colliding scripts, and put them in a
20    Script_row
21 */
22 class Script_row_engraver : public Engraver
23 {
24   Grob *script_row_;
25   vector<Grob*> scripts_;
26   
27 public:
28   TRANSLATOR_DECLARATIONS (Script_row_engraver);
29 protected:
30   DECLARE_ACKNOWLEDGER (side_position);
31   void process_acknowledged ();
32   void stop_translation_timestep ();
33 };
34
35 Script_row_engraver::Script_row_engraver ()
36 {
37   script_row_ = 0;
38 }
39
40 void
41 Script_row_engraver::stop_translation_timestep ()
42 {
43   if (script_row_)
44     {
45       for (vsize i = 0; i < scripts_.size (); i++)
46         if (Side_position_interface::get_axis (scripts_[i]) == X_AXIS)
47           Script_column::add_side_positioned (script_row_, scripts_[i]);
48     }
49
50   scripts_.clear ();
51   script_row_ = 0;
52 }
53
54 void
55 Script_row_engraver::acknowledge_side_position (Grob_info inf)
56 {
57   Item *thing = dynamic_cast<Item *> (inf.grob ());
58   if (thing)
59     {
60       if (!Item::is_non_musical (thing))
61         scripts_.push_back (thing);
62     }
63 }
64
65 void
66 Script_row_engraver::process_acknowledged ()
67 {
68   if (!script_row_ && scripts_.size () > 1)
69     script_row_ = make_item ("ScriptRow", SCM_EOL);
70 }
71
72
73 ADD_ACKNOWLEDGER (Script_row_engraver, side_position);
74 ADD_TRANSLATOR (Script_row_engraver,
75                 /* doc */ "Determine order in horizontal side position elements. ",
76                 /* create */ "ScriptRow ",
77                 /* read */ "",
78                 /* write */ "");