Release: update news.
[lilypond/patrick.git] / lily / slash-repeat-engraver.cc
blob26a64f9380d8d461d254c79c401c1a914937cece
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>, Erik Sandberg
5 <mandolaerik@gmail.com>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "bar-line.hh"
22 #include "global-context.hh"
23 #include "international.hh"
24 #include "item.hh"
25 #include "misc.hh"
26 #include "repeated-music.hh"
27 #include "score-engraver.hh"
28 #include "spanner.hh"
29 #include "stream-event.hh"
30 #include "warn.hh"
32 #include "translator.icc"
34 /**
35 This acknowledges repeated music with "percent" style. It typesets
36 a slash sign.
38 class Slash_repeat_engraver : public Engraver
40 public:
41 TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
42 protected:
43 Stream_event *slash_;
44 protected:
45 DECLARE_TRANSLATOR_LISTENER (percent);
46 void process_music ();
49 Slash_repeat_engraver::Slash_repeat_engraver ()
51 slash_ = 0;
54 IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, percent);
55 void
56 Slash_repeat_engraver::listen_percent (Stream_event *ev)
58 /*todo: separate events for percent and slash */
59 Moment meas_length
60 = robust_scm2moment (get_property ("measureLength"), Moment (0));
62 if (get_event_length (ev) < meas_length)
63 ASSIGN_EVENT_ONCE (slash_, ev);
66 don't warn if nothing happens: this can happen if there are whole
67 measure repeats.
71 void
72 Slash_repeat_engraver::process_music ()
74 if (slash_)
76 make_item ("RepeatSlash", slash_->self_scm ());
77 slash_ = 0;
81 ADD_TRANSLATOR (Slash_repeat_engraver,
82 /* doc */
83 "Make beat repeats.",
85 /* create */
86 "RepeatSlash ",
88 /* read */
89 "measureLength ",
91 /* write */