Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / script-row-engraver.cc
blob430c2c9dc3f1b08073024ed9486d61c68f5c1247
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
23 #include "accidental-placement.hh"
24 #include "item.hh"
25 #include "script-column.hh"
26 #include "side-position-interface.hh"
28 #include "translator.icc"
31 /**
32 Find potentially colliding scripts, and put them in a
33 Script_row
35 class Script_row_engraver : public Engraver
37 Grob *script_row_;
38 vector<Grob*> scripts_;
40 public:
41 TRANSLATOR_DECLARATIONS (Script_row_engraver);
42 protected:
43 DECLARE_ACKNOWLEDGER (accidental_placement);
44 DECLARE_ACKNOWLEDGER (side_position);
45 void process_acknowledged ();
46 void stop_translation_timestep ();
49 Script_row_engraver::Script_row_engraver ()
51 script_row_ = 0;
54 void
55 Script_row_engraver::stop_translation_timestep ()
57 if (script_row_)
59 for (vsize i = 0; i < scripts_.size (); i++)
60 if (Accidental_placement::has_interface (scripts_[i])
61 || Side_position_interface::get_axis (scripts_[i]) == X_AXIS)
62 Script_column::add_side_positioned (script_row_, scripts_[i]);
65 scripts_.clear ();
66 script_row_ = 0;
69 void
70 Script_row_engraver::acknowledge_side_position (Grob_info inf)
72 Item *thing = dynamic_cast<Item *> (inf.grob ());
73 if (thing)
75 if (!Item::is_non_musical (thing))
76 scripts_.push_back (thing);
81 void
82 Script_row_engraver::acknowledge_accidental_placement (Grob_info inf)
84 scripts_.push_back (inf.grob ());
88 void
89 Script_row_engraver::process_acknowledged ()
91 if (!script_row_ && scripts_.size () > 1)
92 script_row_ = make_item ("ScriptRow", SCM_EOL);
96 ADD_ACKNOWLEDGER (Script_row_engraver, accidental_placement);
97 ADD_ACKNOWLEDGER (Script_row_engraver, side_position);
98 ADD_TRANSLATOR (Script_row_engraver,
99 /* doc */
100 "Determine order in horizontal side position elements.",
102 /* create */
103 "ScriptRow ",
105 /* read */
108 /* write */