]> git.donarmstrong.com Git - lilypond.git/blob - lily/forbid-break-engraver.cc
lily/system.cc (get_paper_system): reinstate the backwards-
[lilypond.git] / lily / forbid-break-engraver.cc
1 /*
2   forbid-break-engraver.cc -- implement Forbid_line_break_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2002--_2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8 #include "context.hh"
9 #include "duration.hh"
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "input.hh"
13 #include "moment.hh"
14 #include "pitch.hh"
15 #include "rhythmic-head.hh"
16
17 #include "translator.icc"
18
19 class Forbid_line_break_engraver : public Engraver
20 {
21 public:
22   TRANSLATOR_DECLARATIONS (Forbid_line_break_engraver);
23   void start_translation_timestep ();
24 };
25
26 Forbid_line_break_engraver::Forbid_line_break_engraver ()
27 {
28 }
29
30 void
31 Forbid_line_break_engraver::start_translation_timestep ()
32 {
33   /*
34     Check for running note heads. This should probably be done elsewhere.
35   */
36   SCM busy = get_property ("busyGrobs");
37
38   Moment now = now_mom ();
39   while (scm_is_pair (busy) && unsmob_moment (scm_caar (busy))->main_part_ == now.main_part_)
40     busy = scm_cdr (busy);
41
42   while (scm_is_pair (busy))
43     {
44       Grob *g = unsmob_grob (scm_cdar (busy));
45       if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
46         context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
47       busy = scm_cdr (busy);
48     }
49 }
50
51 ADD_TRANSLATOR (Forbid_line_break_engraver,
52                 /* doc */ "Forbid line breaks when note heads "
53                 "are still playing at some point.",
54                 /* create */ "",
55                 /* read */ "busyGrobs",
56                 /* write */ "forbidBreak");