]> git.donarmstrong.com Git - lilypond.git/blob - lily/slash-repeat-engraver.cc
Web-ja: update introduction
[lilypond.git] / lily / slash-repeat-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2015 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 "item.hh"
22 #include "engraver.hh"
23 #include "stream-event.hh"
24
25 #include "translator.icc"
26
27 /*
28   This acknowledges repeated music with "percent" style.  It typesets
29   a slash sign or double percent sign.
30 */
31 class Slash_repeat_engraver : public Engraver
32 {
33 public:
34   TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
35 protected:
36   Stream_event *slash_;
37 protected:
38   void listen_repeat_slash (Stream_event *);
39   void process_music ();
40 };
41
42 Slash_repeat_engraver::Slash_repeat_engraver (Context *c)
43   : Engraver (c)
44 {
45   slash_ = 0;
46 }
47
48 void
49 Slash_repeat_engraver::listen_repeat_slash (Stream_event *ev)
50 {
51   ASSIGN_EVENT_ONCE (slash_, ev);
52 }
53
54 void
55 Slash_repeat_engraver::process_music ()
56 {
57   if (slash_)
58     {
59       SCM count = slash_->get_property ("slash-count");
60       if (scm_to_int (count) == 0)
61         make_item ("DoubleRepeatSlash", slash_->self_scm ());
62       else
63         make_item ("RepeatSlash", slash_->self_scm ());
64       slash_ = 0;
65     }
66 }
67
68 void
69 Slash_repeat_engraver::boot ()
70 {
71   ADD_LISTENER (Slash_repeat_engraver, repeat_slash);
72 }
73
74 ADD_TRANSLATOR (Slash_repeat_engraver,
75                 /* doc */
76                 "Make beat repeats.",
77
78                 /* create */
79                 "DoubleRepeatSlash "
80                 "RepeatSlash ",
81
82                 /* read */
83                 "",
84
85                 /* write */
86                 ""
87                );