2 key-reg.cc -- implement Key_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 Todo: key undo, special keys.
13 #include "key-item.hh"
14 #include "command-request.hh"
15 #include "local-key-reg.hh"
16 #include "musical-request.hh"
17 #include "local-key-item.hh"
19 #include "time-description.hh"
21 Key_register::Key_register()
24 do_post_move_processing();
28 Key_register::create_key()
31 int c0_i
= *get_staff_info().c0_position_i_l_
;
33 kit_p_
= new Key_item(c0_i
);
34 announce_element(Score_elem_info(kit_p_
,keyreq_l_
));
40 Key_register::do_try_request(Request
* req_l
)
42 Command_req
* creq_l
= req_l
->command();
43 if (!creq_l
|| !creq_l
->keychange())
48 keyreq_l_
= creq_l
->keychange();
54 Key_register::acknowledge_element(Score_elem_info info
)
56 Command_req
* r_l
= info
.req_l_
->command() ;
57 if (r_l
&& r_l
->clefchange()) {
59 } else if (info
.elem_l_
->name() == Bar::static_name()) {
61 default_key_b_
= true;
68 Key_register::do_process_requests()
70 if (key_
.multi_octave_b_
)
71 assert(false); // TODO .
78 Key_register::do_pre_move_processing()
81 kit_p_
->default_b_
= default_key_b_
;
82 typeset_breakable_item( kit_p_
);
90 Key_register::read_req(Key_change_req
* r
)
92 key_
.multi_octave_b_
= r
->multi_octave_b_
;
93 accidental_idx_arr_
.set_size(0);
94 for (int i
= 0; i
< r
->melodic_p_arr_
.size(); i
++) {
95 Melodic_req
* m_l
=r
->melodic_p_arr_
[i
];
96 int n_i
=m_l
->notename_i_
;
97 int a_i
= m_l
->accidental_i_
;
98 int o_i
= m_l
->octave_i_
;
99 if (r
->multi_octave_b_
)
100 key_
.set(o_i
, n_i
, a_i
);
103 accidental_idx_arr_
.push(n_i
);
108 Key_register::do_post_move_processing()
111 default_key_b_
= false;
114 IMPLEMENT_STATIC_NAME(Key_register
);
115 IMPLEMENT_IS_TYPE_B1(Key_register
,Request_register
);
116 ADD_THIS_REGISTER(Key_register
);