2 spanner-break-forbid-engraver.cc -- implement Spanner_break_forbid_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2007--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
11 #include "engraver.hh"
12 #include "international.hh"
14 #include "stream-event.hh"
18 #include "translator.icc"
20 class Spanner_break_forbid_engraver
: public Engraver
22 TRANSLATOR_DECLARATIONS (Spanner_break_forbid_engraver
);
23 vector
<Spanner
*> running_spanners_
;
25 DECLARE_ACKNOWLEDGER (unbreakable_spanner
);
26 DECLARE_END_ACKNOWLEDGER (unbreakable_spanner
);
28 void process_music ();
33 Spanner_break_forbid_engraver::process_music ()
35 if (running_spanners_
.size ())
37 context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T
);
42 Spanner_break_forbid_engraver::acknowledge_end_unbreakable_spanner (Grob_info gi
)
44 vector
<Spanner
*>::iterator i
= find (running_spanners_
.begin (), running_spanners_
.end (),
46 if (i
!= running_spanners_
.end ())
47 running_spanners_
.erase (i
);
51 Spanner_break_forbid_engraver::acknowledge_unbreakable_spanner (Grob_info gi
)
53 if (!to_boolean (gi
.grob ()->get_property ("breakable")))
54 running_spanners_
.push_back (gi
.spanner ());
57 Spanner_break_forbid_engraver::Spanner_break_forbid_engraver ()
62 ADD_END_ACKNOWLEDGER (Spanner_break_forbid_engraver
, unbreakable_spanner
);
63 ADD_ACKNOWLEDGER (Spanner_break_forbid_engraver
, unbreakable_spanner
);
64 ADD_TRANSLATOR (Spanner_break_forbid_engraver
,
66 "Forbid breaks in certain spanners.",