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 void deprecated_process_music ();
33 virtual void process_acknowledged ();
36 Spanner * volta_span_p_;
37 Spanner* end_volta_span_p_;
40 ADD_THIS_TRANSLATOR(Volta_engraver);
42 Volta_engraver::Volta_engraver ()
45 end_volta_span_p_ = 0;
49 Volta_engraver::process_acknowledged ()
51 deprecated_process_music ();
55 Volta_engraver::deprecated_process_music ()
59 SCM cs = get_property ("repeatCommands");
63 while (gh_pair_p (cs))
67 if (gh_pair_p (c) && gh_car (c) == ly_symbol2scm ("volta"))
69 if (gh_cadr (c) == SCM_BOOL_F)
78 SCM l (get_property ("voltaSpannerDuration"));
79 Moment now = now_mom ();
81 bool early_stop = volta_span_p_ && unsmob_moment (l)
82 &&*unsmob_moment (l) <= now - started_mom_;
84 if (end && !volta_span_p_)
86 warning (_("No volta spanner to end")); // fixme: be more verbose.
88 else if (end || early_stop)
90 end_volta_span_p_ = volta_span_p_;
94 maybe do typeset_element () directly?
97 if (!gh_string_p (str))
98 end_volta_span_p_->set_elt_property ("last-volta", SCM_BOOL_T);
101 if (gh_string_p (str))
106 warning (_ ("Already have a volta spanner. Stopping that one prematurely."));
108 if (end_volta_span_p_)
110 warning (_("Also have a stopped spanner. Giving up."));
116 end_volta_span_p_ = volta_span_p_;
120 volta_span_p_ = new Spanner (get_property ("VoltaBracket"));
121 Volta_spanner::set_interface (volta_span_p_);
122 announce_element (volta_span_p_,0);
123 volta_span_p_->set_elt_property ("text", str);
128 Volta_engraver::acknowledge_element (Score_element_info i)
130 if (Item* item = dynamic_cast<Item*> (i.elem_l_))
132 if (Note_column::has_interface (item))
135 Volta_spanner::add_column (volta_span_p_,item);
136 if (end_volta_span_p_)
137 Volta_spanner::add_column (end_volta_span_p_,item);
139 if (Bar::has_interface (item))
142 Volta_spanner::add_bar (volta_span_p_, item);
143 if (end_volta_span_p_)
144 Volta_spanner::add_bar(end_volta_span_p_ , item);
150 Volta_engraver::do_removal_processing ()
154 typeset_element(volta_span_p_);
156 if (end_volta_span_p_)
158 typeset_element (end_volta_span_p_);
163 Volta_engraver::do_pre_move_processing ()
165 if (end_volta_span_p_)
167 Side_position::add_staff_support (end_volta_span_p_);
169 typeset_element (end_volta_span_p_ );
170 end_volta_span_p_ =0;
175 TODO: should attach volta to paper-column if no bar is found.