]> git.donarmstrong.com Git - lilypond.git/blob - lily/forbid-break-engraver.cc
unsmob_pitch -> Pitch::unsmob and related
[lilypond.git] / lily / forbid-break-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2002--_2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "context.hh"
20 #include "duration.hh"
21 #include "engraver.hh"
22 #include "grob.hh"
23 #include "input.hh"
24 #include "pitch.hh"
25 #include "rhythmic-head.hh"
26
27 #include "translator.icc"
28
29 class Forbid_line_break_engraver : public Engraver
30 {
31 public:
32   TRANSLATOR_DECLARATIONS (Forbid_line_break_engraver);
33   void start_translation_timestep ();
34 };
35
36 Forbid_line_break_engraver::Forbid_line_break_engraver ()
37 {
38 }
39
40 void
41 Forbid_line_break_engraver::start_translation_timestep ()
42 {
43   /*
44     Check for running note heads. This should probably be done elsewhere.
45   */
46   SCM busy = get_property ("busyGrobs");
47
48   Moment now = now_mom ();
49   while (scm_is_pair (busy) && Moment::unsmob (scm_caar (busy))->main_part_ == now.main_part_)
50     busy = scm_cdr (busy);
51
52   while (scm_is_pair (busy))
53     {
54       Grob *g = Grob::unsmob (scm_cdar (busy));
55       if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
56         context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
57       busy = scm_cdr (busy);
58     }
59 }
60
61 ADD_TRANSLATOR (Forbid_line_break_engraver,
62                 /* doc */
63                 "Forbid line breaks when note heads are still playing at some"
64                 " point.",
65
66                 /* create */
67                 "",
68
69                 /* read */
70                 "busyGrobs ",
71
72                 /* write */
73                 "forbidBreak "
74                );