2 keyreg.cc -- implement Key_register
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
14 #include "complexwalker.hh"
15 #include "commandrequest.hh"
16 #include "staffcolumn.hh"
17 #include "localkeyreg.hh"
18 #include "musicalrequest.hh"
20 Key_register::Key_register(Complex_walker
*w
)
23 do_post_move_process();
28 Key_register::try_request(Request
* req_l
)
30 if (!req_l
->command()->keychange())
32 assert(!keyreq_l_
); // todo
33 keyreq_l_
= req_l
->command()->keychange();
39 Key_register::acknowledge_element(Staff_elem_info info
)
41 Command_req
* r_l
= info
.req_l_
->command() ;
42 if (r_l
&& r_l
->clefchange() && !kit_p_
) {
43 kit_p_
= new Key_item(walk_l_
->c0_position_i());
45 announce_element(Staff_elem_info(kit_p_
, keyreq_l_
, this));
50 Key_register::process_request()
52 Time_description
*time_l
= &walk_l_
->time_
;
55 (!time_l
->whole_in_measure_
|| !time_l
->when_
)) {
56 default_key_b_
= true;
59 if ( default_key_b_
|| keyreq_l_
) {
60 kit_p_
= new Key_item(walk_l_
->c0_position_i());
62 announce_element(Staff_elem_info(kit_p_
, keyreq_l_
, this));
67 Key_register::do_pre_move_process()
71 typeset_breakable_item(0,0,kit_p_
);
73 typeset_breakable_item(
74 new Key_item(*kit_p_
), kit_p_
, new Key_item(*kit_p_
));
82 Key_register::read_req(Key_change_req
* r
)
84 accidental_idx_arr_
.set_size(0);
85 for (int i
= 0; i
< r
->melodic_p_arr_
.size(); i
++) {
86 int n_i
=r
->melodic_p_arr_
[i
]->notename_i_
;
87 key_
.set(n_i
, r
->melodic_p_arr_
[i
]->accidental_i_
);
88 accidental_idx_arr_
.push(n_i
);
93 Key_register::do_post_move_process()
96 default_key_b_
= false;