2 multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver
4 (c) 1998 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 "multi-measure-rest-engraver.hh"
12 #include "score-column.hh"
13 #include "time-description.hh"
14 //#include "paper-score.hh"
15 //#include "p-score.hh"
16 //#include "paper-def.hh"
18 //#include "global-translator.hh"
22 ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver
);
24 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
28 // rest_item_creation_mom_ = 0;
29 multi_measure_req_l_
= 0;
34 Multi_measure_rest_engraver::acknowledge_element (Score_element_info i
)
36 if (Bar
*c
= dynamic_cast<Bar
*> (i
.elem_l_
))
39 mmrest_p_
->add_column (c
);
41 lastrest_p_
->add_column (c
);
46 Multi_measure_rest_engraver::do_try_music (Music
* req_l
)
48 if (Multi_measure_rest_req
*mr
= dynamic_cast<Multi_measure_rest_req
*> (req_l
))
50 if (multi_measure_req_l_
)
51 if (!multi_measure_req_l_
->equal_b (mr
)
52 || rest_start_mom_
!= now_moment ())
55 multi_measure_req_l_
= mr
;
56 rest_start_mom_
= now_moment ();
58 rest_stop_mom_
= rest_start_mom_
+ multi_measure_req_l_
->duration_
.length ();
65 Multi_measure_rest_engraver::do_process_requests ()
67 if (multi_measure_req_l_
&& !mmrest_p_
)
69 Time_description
const *time
= get_staff_info().time_C_
;
70 mmrest_p_
= new Multi_measure_rest
;
71 announce_element (Score_element_info (mmrest_p_
, multi_measure_req_l_
));
72 start_measure_i_
= time
->bars_i_
;
77 Multi_measure_rest_engraver::do_pre_move_processing ()
79 Moment
now (now_moment ());
80 Time_description
const *time
= get_staff_info().time_C_
;
81 if (mmrest_p_
&& (now
>= rest_start_mom_
)
82 && !time
->whole_in_measure_
83 && (mmrest_p_
->column_arr_
.size () >= 2))
85 typeset_element (mmrest_p_
);
87 must keep mmrest_p_ around to set measures_i_
92 typeset_element (lastrest_p_
);
98 Multi_measure_rest_engraver::do_post_move_processing ()
100 Time_description
const *time
= get_staff_info().time_C_
;
101 Moment
now (now_moment ());
103 if (mmrest_p_
&& !time
->whole_in_measure_
)
105 lastrest_p_
= mmrest_p_
;
106 lastrest_p_
->measures_i_
= time
->bars_i_
- start_measure_i_
;
110 if (now
>= rest_stop_mom_
)
112 multi_measure_req_l_
= 0;