]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-tremolo-iterator.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / chord-tremolo-iterator.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5                  Erik Sandberg <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 "chord-tremolo-iterator.hh"
22
23 #include "input.hh"
24 #include "international.hh"
25 #include "misc.hh"
26 #include "repeated-music.hh"
27
28 Chord_tremolo_iterator::Chord_tremolo_iterator ()
29 {
30 }
31
32 SCM
33 Chord_tremolo_iterator::get_music_list () const
34 {
35   Music *mus = get_music ();
36   Input *origin = mus->origin ();
37   Music *body = Repeated_music::body (mus);
38   bool body_is_sequential = body->is_mus_type ("sequential-music");
39
40   int elt_count = body_is_sequential ? scm_ilength (body->get_property ("elements")) : 1;
41
42   if (elt_count <= 0)
43     elt_count = 1;
44
45   if (elt_count == 1)
46     {
47       Music *ev = make_music_by_name (ly_symbol2scm ("TremoloEvent"));
48       ev->set_spot (*origin);
49       ev->set_property ("repeat-count", mus->get_property ("repeat-count"));
50       ev->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
51       return scm_list_2 (ev->unprotect (), body->self_scm ());
52     }
53   else
54     {
55       SCM tremolo_symbol = ly_symbol2scm ("TremoloSpanEvent");
56       SCM start_event_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), tremolo_symbol, scm_from_int (START));
57       unsmob_music (start_event_scm)->set_spot (*origin);
58       SCM stop_event_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), tremolo_symbol, scm_from_int (STOP));
59
60       Music *start_event = unsmob_music (start_event_scm);
61       Music *stop_event = unsmob_music (stop_event_scm);
62       start_event->set_spot (*origin);
63       stop_event->set_spot (*origin);
64       start_event->set_property ("repeat-count", mus->get_property ("repeat-count"));
65       start_event->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
66
67       return scm_list_3 (start_event_scm, body->self_scm (), stop_event_scm);
68     }
69 }
70
71 IMPLEMENT_CTOR_CALLBACK (Chord_tremolo_iterator);