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