2 new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "repeated-music.hh"
11 #include "global-context.hh"
16 #include "percent-repeat-iterator.hh"
17 #include "bar-line.hh"
18 #include "score-engraver.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 TRANSLATOR_DECLARATIONS (Percent_repeat_engraver);
39 /// moment (global time) where beam started.
43 /// location within measure where beam started.
44 Moment beam_start_location_;
54 Item * double_percent_;
56 Spanner * finished_perc_;
58 virtual void finalize ();
59 virtual bool try_music (Music*);
60 virtual void stop_translation_timestep ();
61 virtual void start_translation_timestep ();
62 virtual void process_music ();
65 Percent_repeat_engraver::Percent_repeat_engraver ()
75 Percent_repeat_engraver::try_music (Music * m)
77 if (m->is_mus_type ("repeated-music")
78 && m->get_property ("iterator-ctor")
79 == Percent_repeat_iterator::constructor_proc
82 body_length_ = Repeated_music::body_get_length (m);
83 int count = Repeated_music::repeat_count (m);
85 Moment now = now_mom ();
87 stop_mom_ = start_mom_ + Moment (count) * body_length_;
88 next_moment_ = start_mom_ + body_length_;
90 Moment meas_len (robust_scm2moment (get_property ("measureLength"), Moment (1)));
91 if (meas_len == body_length_)
92 repeat_sign_type_ = MEASURE;
93 else if (Moment (2)* meas_len == body_length_)
95 repeat_sign_type_ = DOUBLE_MEASURE;
96 next_moment_ += meas_len ;
100 warning (_ ("Don't know how to handle a percent repeat of this length."));
107 Global_context *global = get_global_context ();
108 for (int i = 0; i < count; i++)
110 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
115 if (repeat_sign_type_ == DOUBLE_MEASURE)
116 global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_);
127 Percent_repeat_engraver::process_music ()
129 if (repeat_ && now_mom () == next_moment_)
131 if (repeat_sign_type_ == MEASURE)
133 finished_perc_ = perc_;
135 perc_ = make_spanner ("PercentRepeat", repeat_->self_scm ());
136 SCM col = get_property ("currentCommandColumn");
137 perc_->set_bound (LEFT, unsmob_grob (col));
139 else if (repeat_sign_type_ == DOUBLE_MEASURE)
141 double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ());
143 forbid breaks on a % line. Should forbid all breaks, really.
146 get_score_engraver ()->forbid_breaks (); // guh. Use properties!
148 next_moment_ = next_moment_ + body_length_;
150 get_global_context ()->add_moment_to_process (next_moment_);
155 Percent_repeat_engraver::finalize ()
160 repeat_->origin ()->warning (_ ("unterminated percent repeat"));
166 Percent_repeat_engraver::typeset_perc ()
170 SCM col = get_property ("currentCommandColumn");
171 finished_perc_->set_bound (RIGHT, unsmob_grob (col));
182 Percent_repeat_engraver::start_translation_timestep ()
184 if (stop_mom_ == now_mom ())
188 finished_perc_ = perc_;
193 repeat_sign_type_ = UNKNOWN;
199 Percent_repeat_engraver::stop_translation_timestep ()
207 ADD_TRANSLATOR (Percent_repeat_engraver,
208 /* descr */ "Make whole bar and double bar repeats.",
209 /* creats*/ "PercentRepeat DoublePercentRepeat",
210 /* accepts */ "repeated-music",
212 /* reads */ "measureLength currentCommandColumn",