2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2007--2015 Han-Wen Nienhuys <hanwen@lilypond.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "international.hh"
23 #include "stream-event.hh"
27 #include "translator.icc"
29 class Spanner_break_forbid_engraver : public Engraver
31 TRANSLATOR_DECLARATIONS (Spanner_break_forbid_engraver);
32 vector<Spanner *> running_spanners_;
34 void acknowledge_unbreakable_spanner (Grob_info);
35 void acknowledge_end_unbreakable_spanner (Grob_info);
37 void process_music ();
41 Spanner_break_forbid_engraver::process_music ()
43 if (running_spanners_.size ())
45 context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
50 Spanner_break_forbid_engraver::acknowledge_end_unbreakable_spanner (Grob_info gi)
52 vector<Spanner *>::iterator i = find (running_spanners_.begin (), running_spanners_.end (),
54 if (i != running_spanners_.end ())
55 running_spanners_.erase (i);
59 Spanner_break_forbid_engraver::acknowledge_unbreakable_spanner (Grob_info gi)
61 if (!to_boolean (gi.grob ()->get_property ("breakable")))
62 running_spanners_.push_back (gi.spanner ());
65 Spanner_break_forbid_engraver::Spanner_break_forbid_engraver ()
70 Spanner_break_forbid_engraver::boot ()
72 ADD_END_ACKNOWLEDGER (Spanner_break_forbid_engraver, unbreakable_spanner);
73 ADD_ACKNOWLEDGER (Spanner_break_forbid_engraver, unbreakable_spanner);
76 ADD_TRANSLATOR (Spanner_break_forbid_engraver,
78 "Forbid breaks in certain spanners.",