]> git.donarmstrong.com Git - lilypond.git/blob - lily/forbid-break-engraver.cc
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond...
[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 "pitch.hh"
14 #include "rhythmic-head.hh"
15
16 #include "translator.icc"
17
18 class Forbid_line_break_engraver : public Engraver
19 {
20 public:
21   TRANSLATOR_DECLARATIONS (Forbid_line_break_engraver);
22   void start_translation_timestep ();
23 };
24
25 Forbid_line_break_engraver::Forbid_line_break_engraver ()
26 {
27 }
28
29 void
30 Forbid_line_break_engraver::start_translation_timestep ()
31 {
32   /*
33     Check for running note heads. This should probably be done elsewhere.
34   */
35   SCM busy = get_property ("busyGrobs");
36
37   Moment now = now_mom ();
38   while (scm_is_pair (busy) && unsmob_moment (scm_caar (busy))->main_part_ == now.main_part_)
39     busy = scm_cdr (busy);
40
41   while (scm_is_pair (busy))
42     {
43       Grob *g = unsmob_grob (scm_cdar (busy));
44       if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
45         context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
46       busy = scm_cdr (busy);
47     }
48 }
49
50 ADD_TRANSLATOR (Forbid_line_break_engraver,
51                 /* doc */
52                 "Forbid line breaks when note heads are still playing at some"
53                 " point.",
54
55                 /* create */
56                 "",
57
58                 /* read */
59                 "busyGrobs ",
60
61                 /* write */
62                 "forbidBreak "
63                 );