2 new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.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 Percent_repeat_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Percent_repeat_engraver);
37 /// moment (global time) where beam started.
41 /// location within measure where beam started.
42 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;
99 warning (_f ("can't handle a percent repeat of length: %s",
100 body_length_.to_string ()));
106 Global_context *global = get_global_context ();
107 for (int i = 1; i < count; i++)
109 Moment m = next_moment_ + Moment (i) * body_length_;
110 global->add_moment_to_process (m);
112 /* bars between % too. */
113 if (repeat_sign_type_ == DOUBLE_MEASURE)
114 global->add_moment_to_process (m - meas_len);
117 if (repeat_sign_type_ == DOUBLE_MEASURE)
118 next_moment_ += meas_len;
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 ());
144 forbid breaks on a % line. Should forbid all breaks, really.
146 Ugh. Why can't this be regular communication between
149 get_score_engraver ()->forbid_breaks ();
151 next_moment_ = next_moment_ + body_length_;
156 Percent_repeat_engraver::finalize ()
161 repeat_->origin ()->warning (_ ("unterminated percent repeat"));
167 Percent_repeat_engraver::typeset_perc ()
171 SCM col = get_property ("currentCommandColumn");
172 finished_perc_->set_bound (RIGHT, unsmob_grob (col));
180 Percent_repeat_engraver::start_translation_timestep ()
182 if (stop_mom_ == now_mom ())
186 finished_perc_ = perc_;
191 repeat_sign_type_ = UNKNOWN;
196 Percent_repeat_engraver::stop_translation_timestep ()
201 ADD_TRANSLATOR (Percent_repeat_engraver,
202 /* descr */ "Make whole bar and double bar repeats.",
203 /* creats*/ "PercentRepeat DoublePercentRepeat",
204 /* accepts */ "repeated-music",
206 /* reads */ "measureLength currentCommandColumn",