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 acknowledge_element (Score_element_info);
30 virtual void do_removal_processing ();
31 virtual void do_pre_move_processing ();
32 virtual void do_process_music ();
35 Spanner * volta_span_p_;
36 Spanner* end_volta_span_p_;
39 ADD_THIS_TRANSLATOR(Volta_engraver);
41 Volta_engraver::Volta_engraver ()
44 end_volta_span_p_ = 0;
48 Volta_engraver::do_process_music ()
50 SCM cs = get_property ("repeatCommands");
54 while (gh_pair_p (cs))
58 if (gh_pair_p (c) && gh_car (c) == ly_symbol2scm ("volta"))
60 if (gh_cadr (c) == SCM_BOOL_F)
69 SCM l (get_property ("voltaSpannerDuration"));
70 Moment now = now_mom ();
72 bool early_stop = volta_span_p_ && unsmob_moment (l)
73 &&*unsmob_moment (l) <= now - started_mom_;
75 if (end && !volta_span_p_)
77 warning (_("No volta spanner to end")); // fixme: be more verbose.
79 else if (end || early_stop)
81 end_volta_span_p_ = volta_span_p_;
85 maybe do typeset_element () directly?
88 if (!gh_string_p (str))
89 end_volta_span_p_->set_elt_property ("last-volta", SCM_BOOL_T);
92 if (gh_string_p (str))
97 warning (_ ("Already have a volta spanner. Stopping that one prematurely."));
99 if (end_volta_span_p_)
101 warning (_("Also have a stopped spanner. Giving up."));
108 end_volta_span_p_ = volta_span_p_;
112 volta_span_p_ = new Spanner (get_property ("basicVoltaBracketProperties"));
113 Volta_spanner::set_interface (volta_span_p_);
114 announce_element (volta_span_p_,0);
115 volta_span_p_->set_elt_property ("text", str);
120 Volta_engraver::acknowledge_element (Score_element_info i)
122 if (Item* item = dynamic_cast<Item*> (i.elem_l_))
124 if (Note_column::has_interface (item))
127 Volta_spanner::add_column (volta_span_p_,item);
128 if (end_volta_span_p_)
129 Volta_spanner::add_column (end_volta_span_p_,item);
131 if (Bar::has_interface (item))
134 Volta_spanner::add_bar (volta_span_p_, item);
135 if (end_volta_span_p_)
136 Volta_spanner::add_bar(end_volta_span_p_ , item);
142 Volta_engraver::do_removal_processing ()
146 typeset_element(volta_span_p_);
148 if (end_volta_span_p_)
150 typeset_element (end_volta_span_p_);
155 Volta_engraver::do_pre_move_processing ()
157 if (end_volta_span_p_)
159 Side_position::add_staff_support (end_volta_span_p_);
161 typeset_element (end_volta_span_p_ );
162 end_volta_span_p_ =0;