]> git.donarmstrong.com Git - lilypond.git/blob - lily/forbid-break-engraver.cc
Web-ja: update introduction
[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 (Context *c)
37   : Engraver (c)
38 {
39 }
40
41 void
42 Forbid_line_break_engraver::start_translation_timestep ()
43 {
44   /*
45     Check for running note heads. This should probably be done elsewhere.
46   */
47   SCM busy = get_property ("busyGrobs");
48
49   Moment now = now_mom ();
50   while (scm_is_pair (busy) && unsmob<Moment> (scm_caar (busy))->main_part_ == now.main_part_)
51     busy = scm_cdr (busy);
52
53   while (scm_is_pair (busy))
54     {
55       Grob *g = unsmob<Grob> (scm_cdar (busy));
56       if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
57         context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
58       busy = scm_cdr (busy);
59     }
60 }
61
62 void
63 Forbid_line_break_engraver::boot ()
64 {
65
66 }
67
68 ADD_TRANSLATOR (Forbid_line_break_engraver,
69                 /* doc */
70                 "Forbid line breaks when note heads are still playing at some"
71                 " point.",
72
73                 /* create */
74                 "",
75
76                 /* read */
77                 "busyGrobs ",
78
79                 /* write */
80                 "forbidBreak "
81                );