X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslash-repeat-engraver.cc;h=ab1425cfd41e64998fcd264be98fd0d198f0c0e3;hb=36342ddfdbf0c112be9cb4ce471417e9c0e8fa1f;hp=b7595056e109a7c68febb78a311d6207c57acfb6;hpb=10809c81d2cf7066eb9838e732900229a900824b;p=lilypond.git diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index b7595056e1..ab1425cfd4 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -1,43 +1,37 @@ -/* - slash-repeat-engraver.cc -- implement Chord_tremolo_engraver - +/* + slash-repeat-engraver.cc -- implement Slash_repeat_engraver + source file of the GNU LilyPond music typesetter - - (c) 2000--2003 Han-Wen Nienhuys - - */ -#include "engraver.hh" + (c) 2000--2005 Han-Wen Nienhuys +*/ + #include "repeated-music.hh" -#include "engraver-group-engraver.hh" -#include "global-translator.hh" +#include "global-context.hh" #include "warn.hh" #include "misc.hh" #include "spanner.hh" #include "item.hh" #include "percent-repeat-iterator.hh" #include "bar-line.hh" - #include "score-engraver.hh" -#include "translator-group.hh" /** - This acknowledges repeated music with "percent" style. It typesets - a % sign. + This acknowledges repeated music with "percent" style. It typesets + a % sign. - TODO: + TODO: - - BEAT case: Create items for single beat repeats, i.e. c4 / / / + - BEAT case: Create items for single beat repeats, i.e. c4 / / / - - DOUBLE_MEASURE case: attach a % to an appropriate barline. - + - DOUBLE_MEASURE case: attach a % to an appropriate barline. */ class Slash_repeat_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Slash_repeat_engraver); + TRANSLATOR_DECLARATIONS (Slash_repeat_engraver); protected: - Repeated_music * repeat_; + Music *repeat_; /// moment (global time) where beam started. Moment start_mom_; @@ -48,56 +42,47 @@ protected: Moment next_moment_; Moment body_length_; - Item * beat_slash_; - Item * double_percent_; + Item *beat_slash_; + Item *double_percent_; protected: - virtual bool try_music (Music*); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void process_music (); + virtual bool try_music (Music *); + void start_translation_timestep (); + void process_music (); }; Slash_repeat_engraver::Slash_repeat_engraver () { - repeat_ =0; + repeat_ = 0; beat_slash_ = 0; } bool -Slash_repeat_engraver::try_music (Music * m) +Slash_repeat_engraver::try_music (Music *m) { - Repeated_music * rp = dynamic_cast (m); - if (rp + if (m->is_mus_type ("repeated-music") && !repeat_ - && rp->get_mus_property ("iterator-ctor") + && m->get_property ("iterator-ctor") == Percent_repeat_iterator::constructor_proc) { - body_length_ = rp->body_get_length (); - int count = rp->repeat_count (); - + body_length_ = Repeated_music::body_get_length (m); + int count = Repeated_music::repeat_count (m); + 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; - } + Moment meas_length + = robust_scm2moment (get_property ("measureLength"), Moment (0)); + if (body_length_ < meas_length) + repeat_ = m; else return false; - - Global_translator *global =top_engraver(); - for (int i = 0; i < count; i++) + + Global_context *global = get_global_context (); + for (int i = 0; i < count; i++) global->add_moment_to_process (next_moment_ + Moment (i) * body_length_); - + return true; } @@ -109,41 +94,26 @@ 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()); + beat_slash_ = make_item ("RepeatSlash", repeat_->self_scm ()); next_moment_ = next_moment_ + body_length_; - top_engraver()->add_moment_to_process (next_moment_); + get_global_context ()->add_moment_to_process (next_moment_); } } - void Slash_repeat_engraver::start_translation_timestep () { if (stop_mom_ == now_mom ()) - { - repeat_ = 0; - } -} - -void -Slash_repeat_engraver::stop_translation_timestep () -{ - if (beat_slash_) - { - typeset_grob (beat_slash_); - beat_slash_ = 0; - } + repeat_ = 0; + beat_slash_ = 0; } +#include "translator.icc" - - -ENTER_DESCRIPTION(Slash_repeat_engraver, -/* descr */ "Make beat repeats.", -/* creats*/ "RepeatSlash", -/* accepts */ "repeated-music", -/* acks */ "", -/* reads */ "measureLength", -/* write */ ""); +ADD_TRANSLATOR (Slash_repeat_engraver, + /* doc */ "Make beat repeats.", + /* create */ "RepeatSlash", + /* accept */ "repeated-music", + /* read */ "measureLength", + /* write */ "");