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