2 key-reg.cc -- implement Key_register
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
12 #include "key-item.hh"
13 #include "command-request.hh"
14 #include "staff-column.hh"
15 #include "local-key-reg.hh"
16 #include "musical-request.hh"
17 #include "local-key-item.hh"
20 Key_register::Key_register()
22 post_move_processing();
26 Key_register::try_request(Request * req_l)
28 Command_req* creq_l= req_l->command();
29 if (!creq_l|| !creq_l->keychange())
32 assert(!keyreq_l_); // todo
33 keyreq_l_ = creq_l->keychange();
40 Key_register::acknowledge_element(Staff_elem_info info)
42 Command_req * r_l = info.req_l_->command() ;
43 if (r_l && r_l->clefchange()) {
47 if (info.elem_p_->name() == Bar::static_name())
48 default_key_b_ = true;
53 Key_register::process_requests()
55 int c0_i= *get_staff_info().c0_position_i_l_;
57 if (key_.multi_octave_b_)
58 assert(false); // TODO .
60 kit_p_ = new Key_item(c0_i);
62 announce_element(Staff_elem_info(kit_p_, keyreq_l_));
66 Key_register::pre_move_processing()
69 if (! default_key_b_ && ! change_key_b_ ) {
76 typeset_breakable_item(
77 new Key_item(*kit_p_), kit_p_, new Key_item(*kit_p_));
79 typeset_breakable_item(0,0,kit_p_);
87 Key_register::read_req(Key_change_req * r)
89 key_.multi_octave_b_ = r->multi_octave_b_;
90 accidental_idx_arr_.set_size(0);
91 for (int i = 0; i < r->melodic_p_arr_.size(); i ++) {
92 Melodic_req * m_l =r->melodic_p_arr_[i];
93 int n_i=m_l->notename_i_;
94 int a_i = m_l->accidental_i_;
95 int o_i = m_l->octave_i_;
96 if (r->multi_octave_b_)
97 key_.set(o_i, n_i, a_i);
100 accidental_idx_arr_.push(n_i);
105 Key_register::post_move_processing()
108 default_key_b_ = false;
110 change_key_b_ = false;
112 IMPLEMENT_STATIC_NAME(Key_register);
113 ADD_THIS_REGISTER(Key_register);