]> git.donarmstrong.com Git - lilypond.git/blob - lily/partial-iterator.cc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / lily / partial-iterator.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2010 Neil Puttock <n.puttock@gmail.com>
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
20 #include "context.hh"
21 #include "input.hh"
22 #include "international.hh"
23 #include "moment.hh"
24 #include "music.hh"
25 #include "simple-music-iterator.hh"
26
27 class Partial_iterator : public Simple_music_iterator
28 {
29 public:
30   DECLARE_SCHEME_CALLBACK (constructor, ());
31  protected:
32   virtual void process (Moment);
33 };
34
35 void
36 Partial_iterator::process (Moment m)
37 {
38   if (Duration *dur
39       = unsmob_duration (get_music ()->get_property ("partial-duration")))
40     {
41       Context *ctx = get_outlet ();
42       Moment now = ctx->now_mom ();
43       if (now.main_part_ > Rational (0))
44         get_music ()->origin ()->
45           warning (_ ("trying to use \\partial after the start of a piece"));
46       Moment length = Moment (dur->get_length ());
47       now = Moment (0, now.grace_part_);
48       ctx->set_property ("measurePosition", (now - length).smobbed_copy ());
49     }
50   else
51     programming_error ("invalid duration in \\partial");
52
53   Simple_music_iterator::process (m);
54 }
55
56 IMPLEMENT_CTOR_CALLBACK (Partial_iterator);