lilypond-0.1.16
[lilypond.git] / src / localkeyreg.cc
blob3817a36ba21be6d4a66d04dd5a59179b2005f642
1 /*
2 localkeyreg.cc -- implement Local_key_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6 #include "musicalrequest.hh"
7 #include "commandrequest.hh"
8 #include "localkeyreg.hh"
9 #include "localkeyitem.hh"
10 #include "complexwalker.hh"
11 #include "keyreg.hh"
12 #include "debug.hh"
14 Local_key_register::Local_key_register(Complex_walker*w)
15 : Request_register(w)
17 key_item_p_ = 0;
18 key_c_l_ = 0;
21 void
22 Local_key_register::do_pre_move_process()
24 if (key_item_p_) {
25 walk_l_->typeset_element(key_item_p_);
26 key_item_p_ = 0;
29 void
30 Local_key_register::acknowledge_element(Staff_elem_info info)
32 if (info.req_l_->melodic()) {
33 Melodic_req * melodic_l_ = info.req_l_->melodic();
35 if( melodic_l_->forceacc_b_ ||
36 local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_)
37 != melodic_l_->accidental_i_) {
38 Item * support_l_ = info.elem_p_->item();
41 if (!key_item_p_) {
42 key_item_p_ = new Local_key_item(walk_l_->c0_position_i());
45 key_item_p_->add(melodic_l_);
46 key_item_p_->add(support_l_);
47 local_key_.oct(melodic_l_->octave_i_)
48 .set(melodic_l_->notename_i_, melodic_l_->accidental_i_);
50 } else if (info.req_l_->command() &&
51 info.req_l_->command()->keychange()) {
52 Key_register * key_reg_l = (Key_register*)info.origin_reg_l_;
53 key_c_l_ = &key_reg_l->key_;
54 local_key_.reset(*key_c_l_);
58 void
59 Local_key_register::process_request()
61 if (!walk_l_->time_.whole_in_measure_) {
62 if (key_c_l_)
63 local_key_.reset(*key_c_l_);
64 else if( walk_l_->when() >0)
65 warning ("Help me! can't figure current key", 0);