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