]> git.donarmstrong.com Git - lilypond.git/blob - lily/slash-repeat-engraver.cc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / slash-repeat-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>, Erik Sandberg
5   <mandolaerik@gmail.com>
6
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.
11
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.
16
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/>.
19 */
20
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"
31
32 #include "translator.icc"
33
34 /**
35    This acknowledges repeated music with "percent" style.  It typesets
36    a slash sign.
37 */
38 class Slash_repeat_engraver : public Engraver
39 {
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 ();
47 };
48
49 Slash_repeat_engraver::Slash_repeat_engraver ()
50 {
51   slash_ = 0;
52 }
53
54 IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, percent);
55 void
56 Slash_repeat_engraver::listen_percent (Stream_event *ev)
57 {
58   /*todo: separate events for percent and slash */
59   Moment meas_length
60     = robust_scm2moment (get_property ("measureLength"), Moment (0));
61   
62   if (get_event_length (ev) < meas_length)
63     ASSIGN_EVENT_ONCE (slash_, ev);
64   
65   /*
66     don't warn if nothing happens: this can happen if there are whole
67     measure repeats.
68    */
69 }
70
71 void
72 Slash_repeat_engraver::process_music ()
73 {
74   if (slash_)
75     {
76       make_item ("RepeatSlash", slash_->self_scm ());
77       slash_ = 0;
78     }
79 }
80
81 ADD_TRANSLATOR (Slash_repeat_engraver,
82                 /* doc */
83                 "Make beat repeats.",
84
85                 /* create */
86                 "RepeatSlash ",
87
88                 /* read */
89                 "measureLength ",
90
91                 /* write */
92                 ""
93                 );