2 local-key-reg.cc -- implement Local_key_engraver
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 #include "musical-request.hh"
8 #include "command-request.hh"
9 #include "local-key-grav.hh"
10 #include "local-key-item.hh"
11 #include "key-grav.hh"
13 #include "key-item.hh"
15 #include "note-head.hh"
16 #include "time-description.hh"
18 Local_key_engraver::Local_key_engraver()
24 Local_key_engraver::do_pre_move_processing()
26 Local_key_item
*key_item_p
= 0;
27 if (mel_l_arr_
.size())
29 for (int i
=0; i
< mel_l_arr_
.size(); i
++)
31 Item
* support_l
= support_l_arr_
[i
];
32 Note_req
* note_l
= mel_l_arr_
[i
];
34 if (tied_l_arr_
.find_l (support_l
) &&
38 if (!note_l
->forceacc_b_
&&
39 local_key_
.oct (note_l
->octave_i_
).acc (note_l
->notename_i_
)
40 == note_l
->accidental_i_
)
46 Staff_info inf
= get_staff_info();
47 if (inf
.c0_position_i_l_
)
48 c0_i
= *get_staff_info().c0_position_i_l_
;
50 key_item_p
= new Local_key_item (c0_i
);
52 key_item_p
->add (note_l
);
53 key_item_p
->add_support (support_l
);
54 local_key_
.oct (note_l
->octave_i_
)
55 .set (note_l
->notename_i_
, note_l
->accidental_i_
);
61 for (int i
=0; i
< support_l_arr_
.size(); i
++)
62 key_item_p
->add_support (support_l_arr_
[i
]);
64 announce_element (Score_elem_info (key_item_p
, 0)); // ugh ugh ugh
65 typeset_element (key_item_p
);
70 support_l_arr_
.clear();
71 forced_l_arr_
.clear();
75 whoah .. this looks hairy!
78 Local_key_engraver::acknowledge_element (Score_elem_info info
)
80 Score_elem
* elem_l
= info
.elem_l_
;
81 if (info
.req_l_
->musical() && info
.req_l_
->musical ()->note ())
83 Note_req
* note_l
= info
.req_l_
->musical()->note ();
84 Item
* item_l
= info
.elem_l_
->item();
86 mel_l_arr_
.push (note_l
);
87 support_l_arr_
.push (item_l
);
90 else if (info
.req_l_
->command()
91 && info
.req_l_
->command()->keychange ())
93 Key_engraver
* key_grav_l
=
94 (Key_engraver
*)info
.origin_grav_l_arr_
[0];
95 key_C_
= &key_grav_l
->key_
;
98 else if (elem_l
->is_type_b (Key_item::static_name ()))
100 Key_engraver
* key_grav_l
=
101 (Key_engraver
*)info
.origin_grav_l_arr_
[0];
102 key_C_
= &key_grav_l
->key_
;
104 else if (elem_l
->is_type_b (Tie::static_name ()))
106 Tie
* tie_l
= (Tie
*)elem_l
->spanner();
107 if (tie_l
->same_pitch_b_
)
108 tied_l_arr_
.push (tie_l
-> head_l_drul_
[RIGHT
]);
113 Local_key_engraver::do_process_requests()
115 Time_description
const * time_C_
= get_staff_info().time_C_
;
116 if (time_C_
&& !time_C_
->whole_in_measure_
)
124 IMPLEMENT_IS_TYPE_B1(Local_key_engraver
,Engraver
);
125 ADD_THIS_TRANSLATOR(Local_key_engraver
);