2 new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "repeated-music.hh"
12 #include "engraver-group-engraver.hh"
13 #include "global-translator.hh"
18 #include "percent-repeat-iterator.hh"
21 This acknowledges repeated music with "percent" style. It typesets
26 - BEAT case: Create items for single beat repeats, i.e. c4 / / /
28 - DOUBLE_MEASURE case: attach a % to an appropriate barline.
31 class Percent_repeat_engraver : public Engraver
35 VIRTUAL_COPY_CONS (Translator);
36 Percent_repeat_engraver ();
38 Repeated_music * repeat_;
40 /// moment (global time) where beam started.
44 /// location within measure where beam started.
45 Moment beam_start_location_;
57 Spanner * finished_perc_p_;
60 virtual void finalize ();
61 virtual bool try_music (Music*);
62 virtual void acknowledge_grob (Grob_info);
63 virtual void stop_translation_timestep ();
64 virtual void start_translation_timestep ();
65 virtual void process_music ();
68 Percent_repeat_engraver::Percent_repeat_engraver ()
70 perc_p_ = finished_perc_p_ = 0;
76 Percent_repeat_engraver::try_music (Music * m)
78 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
80 && rp->get_mus_property ("iterator-ctor")
81 == Percent_repeat_iterator::constructor_cxx_function
84 body_length_ = rp->body_length_mom ();
85 int count = rp->repeat_count ();
87 Moment now = now_mom ();
89 stop_mom_ = start_mom_ + Moment (count) * body_length_;
90 next_moment_ = start_mom_ + body_length_;
92 SCM m = get_property ("timeSignatureFraction");
94 gh_scm2int (gh_cdr (m)));
96 if (mlen == body_length_)
97 repeat_sign_type_ = BEAT;
100 mlen *= gh_scm2int (gh_car (m));
101 if (mlen == body_length_)
102 repeat_sign_type_ = MEASURE;
103 else if (Moment (2)* mlen == body_length_)
104 repeat_sign_type_ = DOUBLE_MEASURE;
106 if (repeat_sign_type_ != MEASURE)
108 warning (_ ("Don't know yet how to handle this percent repeat."));
116 Global_translator *global_l =0;
117 Translator *t = this;
120 t = t->daddy_trans_l_ ;
121 global_l = dynamic_cast<Global_translator*> (t);
125 for (int i = 0; i < count; i++)
126 global_l->add_moment_to_process (now + Moment (1+i) * body_length_);
135 Percent_repeat_engraver::process_music ()
137 if (repeat_ && now_mom () == next_moment_)
139 if (repeat_sign_type_ == BEAT)
143 else if (repeat_sign_type_ == MEASURE)
145 finished_perc_p_ = perc_p_;
147 perc_p_ = new Spanner (get_property ("PercentRepeat"));
148 SCM col =get_property ("currentCommandColumn");
149 perc_p_->set_bound (LEFT, unsmob_grob (col));
150 announce_grob (perc_p_, repeat_);
153 next_moment_ = next_moment_ + body_length_;
157 Percent_repeat_engraver::finalize ()
162 repeat_->origin ()->warning (_ ("unterminated chord tremolo"));
168 Percent_repeat_engraver::typeset_perc ()
170 if (finished_perc_p_)
172 SCM col =get_property ("currentCommandColumn");
173 finished_perc_p_->set_bound (RIGHT, unsmob_grob (col));
174 typeset_grob (finished_perc_p_);
175 finished_perc_p_ = 0;
181 Percent_repeat_engraver::acknowledge_grob (Grob_info info)
187 Percent_repeat_engraver::start_translation_timestep ()
189 if (perc_p_ && stop_mom_ == now_mom ())
191 finished_perc_p_ = perc_p_;
195 repeat_sign_type_ = UNKNOWN;
201 Percent_repeat_engraver::stop_translation_timestep ()
206 ADD_THIS_TRANSLATOR (Percent_repeat_engraver);