2 key-reg.cc -- implement Key_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
9 Todo: key undo, special keys.
12 #include "key-grav.hh"
13 #include "key-item.hh"
14 #include "command-request.hh"
15 #include "local-key-grav.hh"
16 #include "musical-request.hh"
17 #include "local-key-item.hh"
19 #include "time-description.hh"
21 Key_engraver::Key_engraver()
24 do_post_move_processing();
28 Key_engraver::create_key()
34 Staff_info inf
= get_staff_info();
35 if (inf
.c0_position_i_l_
)
36 c0_i
= *get_staff_info().c0_position_i_l_
;
38 kit_p_
= new Key_item (c0_i
);
39 kit_p_
->break_priority_i_
= -1; // ugh
40 announce_element (Score_elem_info (kit_p_
,keyreq_l_
));
46 Key_engraver::do_try_request (Request
* req_l
)
48 Command_req
* creq_l
= req_l
->command();
49 if (!creq_l
|| !creq_l
->keychange())
54 keyreq_l_
= creq_l
->keychange();
60 Key_engraver::acknowledge_element (Score_elem_info info
)
62 Command_req
* r_l
= info
.req_l_
->command() ;
63 if (r_l
&& r_l
->clefchange())
67 else if (info
.elem_l_
->is_type_b (Bar::static_name ()))
70 default_key_b_
= true;
77 Key_engraver::do_process_requests()
79 if (key_
.multi_octave_b_
)
81 assert (false); // TODO .
90 Key_engraver::do_pre_move_processing()
94 kit_p_
->default_b_
= default_key_b_
;
95 typeset_element (kit_p_
);
103 Key_engraver::read_req (Key_change_req
const * r
)
106 key_
.multi_octave_b_
= r
->multi_octave_b_
;
107 accidental_idx_arr_
.clear();
109 for (int i
= 0; i
< r
->pitch_arr_
.size(); i
++)
111 Musical_pitch m_l
=r
->pitch_arr_
[i
];
112 if (r
->multi_octave_b_
)
115 key_
.set (m_l
.notename_i_
, m_l
.accidental_i_
);
117 accidental_idx_arr_
.push (m_l
.notename_i_
);
122 Key_engraver::do_post_move_processing()
125 default_key_b_
= false;
129 IMPLEMENT_IS_TYPE_B1(Key_engraver
,Engraver
);
130 ADD_THIS_TRANSLATOR(Key_engraver
);