X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslash-repeat-engraver.cc;h=a6b3faa56c42c76e3a9ad0d24b5fe66ddaa95f81;hb=0b544cfb7332615ef809b71b57ab656741311ae1;hp=456013b67f18fa9d06d6021fa011667b538f19aa;hpb=0a84151a3709fcf51b4b77f0e7e991db1a47eafc;p=lilypond.git diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 456013b67f..a6b3faa56c 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -1,149 +1,81 @@ -/* - slash-repeat-engraver.cc -- implement Chord_tremolo_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2000--2003 Han-Wen Nienhuys - - */ +/* + This file is part of LilyPond, the GNU music typesetter. -#include "engraver.hh" -#include "repeated-music.hh" -#include "engraver-group-engraver.hh" -#include "global-translator.hh" -#include "warn.hh" -#include "misc.hh" -#include "spanner.hh" -#include "item.hh" -#include "percent-repeat-iterator.hh" -#include "bar-line.hh" + Copyright (C) 2000--2014 Han-Wen Nienhuys , Erik Sandberg + -#include "score-engraver.hh" -#include "translator-group.hh" + 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. -/** - This acknowledges repeated music with "percent" style. It typesets - a % sign. + 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. - TODO: + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ - - BEAT case: Create items for single beat repeats, i.e. c4 / / / +#include "item.hh" +#include "engraver.hh" +#include "stream-event.hh" + +#include "translator.icc" - - DOUBLE_MEASURE case: attach a % to an appropriate barline. - +/* + This acknowledges repeated music with "percent" style. It typesets + a slash sign or double percent sign. */ class Slash_repeat_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Slash_repeat_engraver); + TRANSLATOR_DECLARATIONS (Slash_repeat_engraver); protected: - Repeated_music * repeat_; - - /// moment (global time) where beam started. - Moment start_mom_; - Moment stop_mom_; - - /// location within measure where beam started. - Moment beam_start_location_; - Moment next_moment_; - Moment body_length_; - - Item * beat_slash_; - Item * double_percent_; + Stream_event *slash_; protected: - virtual bool try_music (Music*); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + DECLARE_TRANSLATOR_LISTENER (repeat_slash); + void process_music (); }; Slash_repeat_engraver::Slash_repeat_engraver () { - repeat_ =0; - beat_slash_ = 0; + slash_ = 0; } -bool -Slash_repeat_engraver::try_music (Music * m) -{ - Repeated_music * rp = dynamic_cast (m); - if (rp - && !repeat_ - && rp->get_mus_property ("iterator-ctor") - == Percent_repeat_iterator::constructor_proc) - { - body_length_ = rp->body_get_length (); - int count = rp->repeat_count (); - - Moment now = now_mom (); - start_mom_ = now; - stop_mom_ = start_mom_ + Moment (count) * body_length_; - next_moment_ = start_mom_ + body_length_; - - SCM m = get_property ("measureLength"); - Moment meas_len; - if (Moment *mp = unsmob_moment (m)) - meas_len = *mp; - - if (body_length_ < meas_len - && meas_len.main_part_.mod_rat (body_length_.main_part_) - == Moment (Rational (0,0))) - { - repeat_ = rp; - } - else - return false; - - Global_translator *global =top_engraver(); - for (int i = 0; i < count; i++) - global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); - - return true; - } - - return false; -} - -void -Slash_repeat_engraver::process_music () -{ - if (repeat_ && now_mom () == next_moment_) - { - beat_slash_ = new Item (get_property ("RepeatSlash")); - announce_grob(beat_slash_, repeat_->self_scm()); - next_moment_ = next_moment_ + body_length_; - - top_engraver()->add_moment_to_process (next_moment_); - } -} - - +IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, repeat_slash); void -Slash_repeat_engraver::start_translation_timestep () +Slash_repeat_engraver::listen_repeat_slash (Stream_event *ev) { - if (stop_mom_ == now_mom ()) - { - repeat_ = 0; - } + ASSIGN_EVENT_ONCE (slash_, ev); } void -Slash_repeat_engraver::stop_translation_timestep () +Slash_repeat_engraver::process_music () { - if (beat_slash_) + if (slash_) { - typeset_grob (beat_slash_); - beat_slash_ = 0; + SCM count = slash_->get_property ("slash-count"); + if (scm_to_int (count) == 0) + make_item ("DoubleRepeatSlash", slash_->self_scm ()); + else + make_item ("RepeatSlash", slash_->self_scm ()); + slash_ = 0; } } +ADD_TRANSLATOR (Slash_repeat_engraver, + /* doc */ + "Make beat repeats.", + /* create */ + "DoubleRepeatSlash " + "RepeatSlash ", + /* read */ + "", -ENTER_DESCRIPTION(Slash_repeat_engraver, -/* descr */ "Make beat repeats.", -/* creats*/ "RepeatSlash", -/* accepts */ "repeated-music", -/* acks */ "", -/* reads */ "measureLength currentCommandColumn", -/* write */ ""); + /* write */ + "" + );