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