2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2015 Jan Nieuwenhuizen <janneke@gnu.org>
6 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 LilyPond is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 LilyPond is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
22 #include "engraver.hh"
23 #include "arpeggio.hh"
25 #include "pointer-group-interface.hh"
26 #include "separation-item.hh"
27 #include "side-position-interface.hh"
28 #include "staff-symbol-referencer.hh"
30 #include "translator.icc"
35 Make arpeggios that span multiple staves. Catch arpeggios, and span a
36 Span_arpeggio over them if we find more than two arpeggios.
38 class Span_arpeggio_engraver : public Engraver
41 TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
42 DECLARE_ACKNOWLEDGER (arpeggio);
43 DECLARE_ACKNOWLEDGER (note_column);
46 void process_acknowledged ();
47 void stop_translation_timestep ();
51 vector<Grob *> arpeggios_;
52 vector<Grob *> note_columns_;
55 Span_arpeggio_engraver::Span_arpeggio_engraver ()
61 Span_arpeggio_engraver::acknowledge_arpeggio (Grob_info info)
63 if (info.origin_contexts (this).size ()) // huh? what's this test for?
64 arpeggios_.push_back (info.grob ());
68 Span_arpeggio_engraver::acknowledge_note_column (Grob_info info)
70 note_columns_.push_back (info.grob ());
74 Span_arpeggio_engraver::process_acknowledged ()
77 connectArpeggios is slightly brusque; we should really read a grob
78 property of the caught non-span arpeggios. That way, we can have
80 both non-connected and connected arps in one pianostaff.
83 if (!span_arpeggio_ && arpeggios_.size () > 1
84 && to_boolean (get_property ("connectArpeggios")))
85 span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
89 for (vsize i = 0; i < note_columns_.size (); i++)
90 Separation_item::add_conditional_item (note_columns_[i], span_arpeggio_);
91 note_columns_.clear ();
96 Span_arpeggio_engraver::stop_translation_timestep ()
101 we do this very late, to make sure we also catch `extra'
102 side-pos support like accidentals.
104 for (vsize j = 0; j < arpeggios_.size (); j++)
106 extract_grob_set (arpeggios_[j], "stems", stems);
107 for (vsize i = 0; i < stems.size (); i++)
108 Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"),
111 extract_grob_set (arpeggios_[j], "side-support-elements", sses);
112 for (vsize i = 0; i < sses.size (); i++)
113 Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"),
117 we can't kill the children, since we don't want to the
118 previous note to bump into the span arpeggio; so we make
120 arpeggios_[j]->set_property ("transparent", SCM_BOOL_T);
123 span_arpeggio_->set_parent (arpeggios_[0]->get_parent (Y_AXIS), Y_AXIS);
127 note_columns_.clear ();
130 ADD_ACKNOWLEDGER (Span_arpeggio_engraver, arpeggio);
131 ADD_ACKNOWLEDGER (Span_arpeggio_engraver, note_column);
132 ADD_TRANSLATOR (Span_arpeggio_engraver,
134 "Make arpeggios that span multiple staves.",