lilypond-0.0.39
[lilypond.git] / lily / local-key-reg.cc
blobf13ec98b9fd471f422ff77d95572ebd93a9d1e91
1 /*
2 local-key-reg.cc -- implement Local_key_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "musicalrequest.hh"
8 #include "commandrequest.hh"
9 #include "local-key-reg.hh"
10 #include "local-key-item.hh"
11 #include "complex-walker.hh"
12 #include "key-reg.hh"
13 #include "debug.hh"
14 #include "key-item.hh"
16 Local_key_register::Local_key_register()
18 key_item_p_ = 0;
19 key_c_l_ = 0;
22 void
23 Local_key_register::pre_move_processing()
25 if (key_item_p_) {
26 typeset_element(key_item_p_);
27 key_item_p_ = 0;
30 void
31 Local_key_register::acknowledge_element(Staff_elem_info info)
33 if (info.req_l_->melodic()) {
34 Melodic_req * melodic_l_ = info.req_l_->melodic();
36 if( melodic_l_->forceacc_b_ ||
37 local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_)
38 != melodic_l_->accidental_i_) {
39 Item * support_l_ = info.elem_p_->item();
42 if (!key_item_p_) {
43 key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_);
46 key_item_p_->add(melodic_l_);
47 key_item_p_->add(support_l_);
48 local_key_.oct(melodic_l_->octave_i_)
49 .set(melodic_l_->notename_i_, melodic_l_->accidental_i_);
51 } else if (info.elem_p_->name()==Key_item::static_name()) {
52 Key_register * key_reg_l =
53 (Key_register*)info.origin_reg_l_arr_[0];
54 key_c_l_ = &key_reg_l->key_;
55 local_key_.reset(*key_c_l_);
59 void
60 Local_key_register::process_requests()
62 const Time_description * time_c_l_ = get_staff_info().time_c_l_;
63 if (! time_c_l_->whole_in_measure_){
64 if (key_c_l_)
65 local_key_.reset(*key_c_l_);
66 else if( time_c_l_->when_ >Moment(0))
67 warning ("Help me! can't figure current key", 0);