2 multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver
4 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
5 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "musical-request.hh"
10 #include "multi-measure-rest.hh"
11 #include "paper-column.hh"
12 #include "engraver-group-engraver.hh"
13 #include "timing-translator.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "engraver.hh"
21 class Multi_measure_rest_engraver
: public Engraver
24 VIRTUAL_COPY_CONS(Translator
);
25 Multi_measure_rest_engraver ();
28 virtual void acknowledge_element (Score_element_info i
);
29 virtual void do_process_requests ();
30 virtual bool do_try_music (Music
*);
31 virtual void do_pre_move_processing ();
32 virtual void do_post_move_processing ();
33 virtual void do_removal_processing ();
35 Span_req
* new_req_l_
;
36 Span_req
* busy_span_req_l_
;
37 Span_req
* stop_req_l_
;
41 Multi_measure_rest
*mmrest_p_
;
42 Multi_measure_rest
*lastrest_p_
;
45 ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver
);
47 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
50 mmrest_p_
= lastrest_p_
=0;
51 new_req_l_
= busy_span_req_l_
= stop_req_l_
=0;
55 Multi_measure_rest_engraver::acknowledge_element (Score_element_info i
)
57 if (Bar
*c
= dynamic_cast<Bar
*> (i
.elem_l_
))
60 mmrest_p_
->add_column (c
);
62 lastrest_p_
->add_column (c
);
67 Multi_measure_rest_engraver::do_try_music (Music
* req_l
)
69 if (Span_req
* sp
= dynamic_cast<Span_req
*> (req_l
))
71 if (sp
->span_type_str_
== "rest")
73 if (sp
->span_dir_
== STOP
)
77 else if (sp
->span_dir_
== START
&& !new_req_l_
)
90 Multi_measure_rest_engraver::do_process_requests ()
92 if (new_req_l_
&& stop_req_l_
)
96 start_moment_
= now_mom ();
106 busy_span_req_l_
= new_req_l_
;
110 if (busy_span_req_l_
&& !mmrest_p_
)
112 Translator
* tr
= daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh
113 Timing_translator
* time
= dynamic_cast<Timing_translator
*> (tr
);
115 mmrest_p_
= new Multi_measure_rest
;
116 Staff_symbol_referencer_interface
si (mmrest_p_
);
119 announce_element (Score_element_info (mmrest_p_
, busy_span_req_l_
));
121 = gh_scm2int (time
->get_property ("currentBarNumber", 0));
126 Multi_measure_rest_engraver::do_pre_move_processing ()
128 Moment
now (now_mom ());
129 Translator
* tr
= daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh
130 Timing_translator
* time
= dynamic_cast<Timing_translator
*> (tr
);
132 if (mmrest_p_
&& (now
>= start_moment_
)
133 && !time
->measure_position ()
134 && (scm_ilength (mmrest_p_
->get_elt_property ("columns")) >= 2))
136 typeset_element (mmrest_p_
);
138 must keep mmrest_p_ around to set measures_i_
143 typeset_element (lastrest_p_
);
149 busy_span_req_l_
= new_req_l_
;
156 Multi_measure_rest_engraver::do_post_move_processing ()
158 Translator
* tr
= daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh
159 Timing_translator
* time
= dynamic_cast<Timing_translator
*> (tr
);
161 Moment
now (now_mom ());
163 if (mmrest_p_
&& !time
->measure_position ())
165 lastrest_p_
= mmrest_p_
;
166 int cur
= gh_scm2int (time
->get_property ("currentBarNumber", 0));
167 lastrest_p_
->set_elt_property ("measure-count",
168 gh_int2scm (cur
- start_measure_i_
));
175 Multi_measure_rest_engraver::do_removal_processing ()
178 typeset_element (mmrest_p_
);
180 typeset_element (lastrest_p_
);