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);
37 Repeated_music * repeat_;
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 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
79 && rp->get_property ("iterator-ctor")
80 == Percent_repeat_iterator::constructor_proc
83 body_length_ = rp->body_get_length ();
84 int count = rp->repeat_count ();
86 Moment now = now_mom ();
88 stop_mom_ = start_mom_ + Moment (count) * body_length_;
89 next_moment_ = start_mom_ + body_length_;
91 Moment meas_len (robust_scm2moment (get_property ("measureLength"), Moment (1)));
92 if (meas_len == body_length_)
93 repeat_sign_type_ = MEASURE;
94 else if (Moment (2)* meas_len == body_length_)
96 repeat_sign_type_ = DOUBLE_MEASURE;
97 next_moment_ += meas_len ;
101 warning (_ ("Don't know how to handle a percent repeat of this length."));
108 Global_context *global = get_global_context ();
109 for (int i = 0; i < count; i++)
111 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
116 if (repeat_sign_type_ == DOUBLE_MEASURE)
117 global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_);
128 Percent_repeat_engraver::process_music ()
130 if (repeat_ && now_mom () == next_moment_)
132 if (repeat_sign_type_ == MEASURE)
134 finished_perc_ = perc_;
136 perc_ = make_spanner ("PercentRepeat", repeat_->self_scm ());
137 SCM col = get_property ("currentCommandColumn");
138 perc_->set_bound (LEFT, unsmob_grob (col));
140 else if (repeat_sign_type_ == DOUBLE_MEASURE)
142 double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ());
144 forbid breaks on a % line. Should forbid all breaks, really.
147 get_score_engraver ()->forbid_breaks (); // guh. Use properties!
149 next_moment_ = next_moment_ + body_length_;
151 get_global_context ()->add_moment_to_process (next_moment_);
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));
183 Percent_repeat_engraver::start_translation_timestep ()
185 if (stop_mom_ == now_mom ())
189 finished_perc_ = perc_;
194 repeat_sign_type_ = UNKNOWN;
200 Percent_repeat_engraver::stop_translation_timestep ()
208 ENTER_DESCRIPTION (Percent_repeat_engraver,
209 /* descr */ "Make whole bar and double bar repeats.",
210 /* creats*/ "PercentRepeat DoublePercentRepeat",
211 /* accepts */ "repeated-music",
213 /* reads */ "measureLength currentCommandColumn",