X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpartial-iterator.cc;fp=lily%2Fpartial-iterator.cc;h=d38a9514659131be55e000a6441e91d564ff1e78;hb=941dff9d2a67080e0dd8474f1e70f0c72ace6424;hp=0000000000000000000000000000000000000000;hpb=5a22d6233a39d3164e1ca043244794c268be4ad0;p=lilypond.git diff --git a/lily/partial-iterator.cc b/lily/partial-iterator.cc new file mode 100644 index 0000000000..d38a951465 --- /dev/null +++ b/lily/partial-iterator.cc @@ -0,0 +1,56 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2010--2011 Neil Puttock + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#include "context.hh" +#include "input.hh" +#include "international.hh" +#include "moment.hh" +#include "music.hh" +#include "simple-music-iterator.hh" + +class Partial_iterator : public Simple_music_iterator +{ +public: + DECLARE_SCHEME_CALLBACK (constructor, ()); + protected: + virtual void process (Moment); +}; + +void +Partial_iterator::process (Moment m) +{ + if (Duration *dur + = unsmob_duration (get_music ()->get_property ("partial-duration"))) + { + Context *ctx = get_outlet (); + Moment now = ctx->now_mom (); + if (now.main_part_ > Rational (0)) + get_music ()->origin ()-> + warning (_ ("trying to use \\partial after the start of a piece")); + Moment length = Moment (dur->get_length ()); + now = Moment (0, now.grace_part_); + ctx->set_property ("measurePosition", (now - length).smobbed_copy ()); + } + else + programming_error ("invalid duration in \\partial"); + + Simple_music_iterator::process (m); +} + +IMPLEMENT_CTOR_CALLBACK (Partial_iterator);