]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-row-engraver.cc
Run `make grand-replace'.
[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--2008 Han-Wen Nienhuys <hanwen@lilypond.org>
7   
8 */
9
10 #include "engraver.hh"
11
12 #include "accidental-placement.hh"
13 #include "item.hh"
14 #include "script-column.hh"
15 #include "side-position-interface.hh"
16
17 #include "translator.icc"
18
19
20 /**
21    Find potentially colliding scripts, and put them in a
22    Script_row
23 */
24 class Script_row_engraver : public Engraver
25 {
26   Grob *script_row_;
27   vector<Grob*> scripts_;
28   
29 public:
30   TRANSLATOR_DECLARATIONS (Script_row_engraver);
31 protected:
32   DECLARE_ACKNOWLEDGER (accidental_placement);
33   DECLARE_ACKNOWLEDGER (side_position);
34   void process_acknowledged ();
35   void stop_translation_timestep ();
36 };
37
38 Script_row_engraver::Script_row_engraver ()
39 {
40   script_row_ = 0;
41 }
42
43 void
44 Script_row_engraver::stop_translation_timestep ()
45 {
46   if (script_row_)
47     {
48       for (vsize i = 0; i < scripts_.size (); i++)
49         if (Accidental_placement::has_interface (scripts_[i])
50             || Side_position_interface::get_axis (scripts_[i]) == X_AXIS)
51           Script_column::add_side_positioned (script_row_, scripts_[i]);
52     }
53
54   scripts_.clear ();
55   script_row_ = 0;
56 }
57
58 void
59 Script_row_engraver::acknowledge_side_position (Grob_info inf)
60 {
61   Item *thing = dynamic_cast<Item *> (inf.grob ());
62   if (thing)
63     {
64       if (!Item::is_non_musical (thing))
65         scripts_.push_back (thing);
66     }
67 }
68
69
70 void
71 Script_row_engraver::acknowledge_accidental_placement (Grob_info inf)
72 {
73   scripts_.push_back (inf.grob ());
74 }
75
76
77 void
78 Script_row_engraver::process_acknowledged ()
79 {
80   if (!script_row_ && scripts_.size () > 1)
81     script_row_ = make_item ("ScriptRow", SCM_EOL);
82 }
83
84
85 ADD_ACKNOWLEDGER (Script_row_engraver, accidental_placement);
86 ADD_ACKNOWLEDGER (Script_row_engraver, side_position);
87 ADD_TRANSLATOR (Script_row_engraver,
88                 /* doc */
89                 "Determine order in horizontal side position elements.",
90
91                 /* create */
92                 "ScriptRow ",
93
94                 /* read */
95                 "",
96
97                 /* write */
98                 ""
99                 );