]> git.donarmstrong.com Git - lilypond.git/blob - lily/forbid-break-engraver.cc
* lily/include/translator.icc: new file.
[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 "rhythmic-head.hh"
9 #include "grob.hh"
10 #include "score-engraver.hh"
11 #include "input.hh"
12 #include "pitch.hh"
13 #include "duration.hh"
14 #include "moment.hh"
15
16 class Forbid_line_break_engraver : public Engraver
17 {
18 public:
19   TRANSLATOR_DECLARATIONS (Forbid_line_break_engraver);
20   PRECOMPUTED_VIRTUAL void start_translation_timestep ();
21 };
22
23 Forbid_line_break_engraver::Forbid_line_break_engraver (){}
24
25 void
26 Forbid_line_break_engraver::start_translation_timestep ()
27 {
28   /*
29     Check for running note heads. This should probably be done elsewhere.
30   */
31   SCM busy = get_property ("busyGrobs");
32
33   Moment now = now_mom ();
34   while (scm_is_pair (busy) && unsmob_moment (scm_caar (busy))->main_part_ == now.main_part_)
35     busy = scm_cdr (busy);
36
37   while (scm_is_pair (busy))
38     {
39       Grob *g = unsmob_grob (scm_cdar (busy));
40       if (Rhythmic_head::has_interface (g))
41         {
42           get_score_engraver ()->forbid_breaks ();
43         }
44       busy = scm_cdr (busy);
45     }
46 }
47
48 #include "translator.icc"
49
50 ADD_TRANSLATOR (Forbid_line_break_engraver,
51                 /* descr */ "Forbid line breaks when note heads are still playing at some point.",
52                 /* creats*/ "",
53                 /* accepts */ "",
54                 /* acks  */ "",
55                 /* reads */ "busyGrobs",
56                 /* write */ "");