2 volta-engraver.cc -- implement Volta_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "translator-group.hh"
12 #include "volta-spanner.hh"
14 #include "note-column.hh"
16 #include "side-position-interface.hh"
19 Create Volta spanners, by reading repeatCommands property, usually
20 set by Unfolded_repeat_iterator.
22 class Volta_engraver : public Engraver
26 VIRTUAL_COPY_CONS(Translator);
29 virtual void start_translation_timestep ();
30 virtual void acknowledge_grob (Grob_info);
31 virtual void do_removal_processing ();
32 virtual void stop_translation_timestep ();
33 void deprecated_process_music ();
34 virtual void create_grobs ();
37 Spanner *volta_span_p_;
38 Spanner *end_volta_span_p_;
43 ADD_THIS_TRANSLATOR(Volta_engraver);
45 Volta_engraver::Volta_engraver ()
49 end_volta_span_p_ = 0;
53 Volta_engraver::create_grobs ()
57 deprecated_process_music ();
63 Volta_engraver::deprecated_process_music ()
67 SCM cs = get_property ("repeatCommands");
71 while (gh_pair_p (cs))
75 if (gh_pair_p (c) && gh_car (c) == ly_symbol2scm ("volta"))
77 if (gh_cadr (c) == SCM_BOOL_F)
86 SCM l (get_property ("voltaSpannerDuration"));
87 Moment now = now_mom ();
89 bool early_stop = volta_span_p_ && unsmob_moment (l)
90 &&*unsmob_moment (l) <= now - started_mom_;
92 if (end && !volta_span_p_)
94 warning (_("No volta spanner to end")); // fixme: be more verbose.
96 else if (end || early_stop)
98 end_volta_span_p_ = volta_span_p_;
102 maybe do typeset_grob () directly?
105 if (!gh_string_p (str))
106 end_volta_span_p_->set_grob_property ("last-volta", SCM_BOOL_T);
109 if (gh_string_p (str))
114 warning (_ ("Already have a volta spanner. Stopping that one prematurely."));
116 if (end_volta_span_p_)
118 warning (_("Also have a stopped spanner. Giving up."));
124 end_volta_span_p_ = volta_span_p_;
128 volta_span_p_ = new Spanner (get_property ("VoltaBracket"));
129 Volta_spanner::set_interface (volta_span_p_);
130 announce_grob (volta_span_p_,0);
131 volta_span_p_->set_grob_property ("text", str);
136 Volta_engraver::acknowledge_grob (Grob_info i)
138 if (Item* item = dynamic_cast<Item*> (i.elem_l_))
140 if (Note_column::has_interface (item))
143 Volta_spanner::add_column (volta_span_p_,item);
144 if (end_volta_span_p_)
145 Volta_spanner::add_column (end_volta_span_p_,item);
147 if (Bar::has_interface (item))
150 Volta_spanner::add_bar (volta_span_p_, item);
151 if (end_volta_span_p_)
152 Volta_spanner::add_bar(end_volta_span_p_ , item);
158 Volta_engraver::do_removal_processing ()
162 typeset_grob(volta_span_p_);
164 if (end_volta_span_p_)
166 typeset_grob (end_volta_span_p_);
171 Volta_engraver::start_translation_timestep ()
177 Volta_engraver::stop_translation_timestep ()
179 if (end_volta_span_p_)
181 Side_position::add_staff_support (end_volta_span_p_);
183 typeset_grob (end_volta_span_p_ );
184 end_volta_span_p_ =0;
189 TODO: should attach volta to paper-column if no bar is found.