2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011 Bertrand Bordage
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"
22 #include "arpeggio.hh"
23 #include "pointer-group-interface.hh"
24 #include "side-position-interface.hh"
25 #include "staff-symbol-referencer.hh"
29 Make braces that span multiple staves. Catch braces, and span a
30 Span_brace over them if we find more than two braces.
32 class Span_brace_engraver : public Engraver
35 TRANSLATOR_DECLARATIONS (Span_brace_engraver);
36 DECLARE_ACKNOWLEDGER (brace);
39 void process_acknowledged ();
40 void stop_translation_timestep ();
44 vector<Grob*> braces_;
47 Span_brace_engraver::Span_brace_engraver ()
53 Span_brace_engraver::acknowledge_brace (Grob_info info)
55 if (info.origin_contexts (this).size ()) // huh? what's this test for?
56 braces_.push_back (info.grob ());
60 Span_brace_engraver::process_acknowledged ()
63 connectBraces is slightly brusque; we should really read a grob
64 property of the caught non-span braces. That way, we can have
66 both non-connected and connected braces in one pianostaff.
69 if (!span_brace_ && braces_.size () > 1
70 && to_boolean (get_property ("connectBraces")))
72 span_brace_ = make_item ("Brace", SCM_EOL);
73 span_brace_->set_property ("cross-staff", SCM_BOOL_T);
78 Span_brace_engraver::stop_translation_timestep ()
83 we do this very late, to make sure we also catch `extra'
84 side-pos support like accidentals.
86 for (vsize j = 0; j < braces_.size (); j++)
88 extract_grob_set (braces_[j], "stems", stems);
89 for (vsize i = 0; i < stems.size (); i++)
90 Pointer_group_interface::add_grob (span_brace_, ly_symbol2scm ("stems"),
93 extract_grob_set (braces_[j], "side-support-elements", sses);
94 for (vsize i = 0; i < sses.size (); i++)
95 Pointer_group_interface::add_grob (span_brace_, ly_symbol2scm ("side-support-elements"),
99 we can't kill the children, since we don't want to the
100 previous note to bump into the span brace; so we make
102 braces_[j]->set_property ("transparent", SCM_BOOL_T);
106 span_brace_->set_parent (braces_[0]->get_parent (Y_AXIS), Y_AXIS);
112 #include "translator.icc"
114 ADD_ACKNOWLEDGER (Span_brace_engraver, brace);
115 ADD_TRANSLATOR (Span_brace_engraver,
117 "Make braces that span multiple staves.",