2 slash-repeat-engraver.cc -- implement Slash_repeat_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "repeated-music.hh"
10 #include "global-context.hh"
15 #include "percent-repeat-iterator.hh"
16 #include "bar-line.hh"
17 #include "score-engraver.hh"
20 This acknowledges repeated music with "percent" style. It typesets
25 - BEAT case: Create items for single beat repeats, i.e. c4 / / /
27 - DOUBLE_MEASURE case: attach a % to an appropriate barline.
29 class Slash_repeat_engraver : public Engraver
32 TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
36 /// moment (global time) where beam started.
40 /// location within measure where beam started.
41 Moment beam_start_location_;
46 Item *double_percent_;
48 virtual bool try_music (Music *);
49 void start_translation_timestep ();
50 void process_music ();
53 Slash_repeat_engraver::Slash_repeat_engraver ()
60 Slash_repeat_engraver::try_music (Music *m)
62 if (m->is_mus_type ("repeated-music")
64 && m->get_property ("iterator-ctor")
65 == Percent_repeat_iterator::constructor_proc)
67 body_length_ = Repeated_music::body_get_length (m);
68 int count = Repeated_music::repeat_count (m);
70 Moment now = now_mom ();
72 stop_mom_ = start_mom_ + Moment (count) * body_length_;
73 next_moment_ = start_mom_ + body_length_;
76 = robust_scm2moment (get_property ("measureLength"), Moment (0));
77 if (body_length_ < meas_length)
82 Global_context *global = get_global_context ();
83 for (int i = 0; i < count; i++)
84 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
93 Slash_repeat_engraver::process_music ()
95 if (repeat_ && now_mom () == next_moment_)
97 beat_slash_ = make_item ("RepeatSlash", repeat_->self_scm ());
98 next_moment_ = next_moment_ + body_length_;
100 get_global_context ()->add_moment_to_process (next_moment_);
105 Slash_repeat_engraver::start_translation_timestep ()
107 if (stop_mom_ == now_mom ())
112 #include "translator.icc"
114 ADD_TRANSLATOR (Slash_repeat_engraver,
115 /* doc */ "Make beat repeats.",
116 /* create */ "RepeatSlash",
117 /* accept */ "repeated-music",
118 /* read */ "measureLength",