2 slur-reg.cc -- implement Slur_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "musicalrequest.hh"
9 #include "complex-walker.hh"
10 #include "slur-reg.hh"
13 #include "notehead.hh"
16 Slur_register::set_feature(Features i
)
18 dir_i_
= i
.direction_i_
;
21 Slur_register::Slur_register()
23 set_feature(Features::dir(0));
27 Slur_register::try_request(Request
*req_l
)
32 new_slur_req_l_arr_
.push(req_l
->slur());
37 Slur_register::acknowledge_element(Staff_elem_info info
)
39 if (info
.elem_p_
->name() == Notehead::static_name()) {
40 Notehead
*head_p
=(Notehead
*) info
.elem_p_
;// ugh
41 for (int i
= 0; i
< slur_l_stack_
.size(); i
++)
42 slur_l_stack_
[i
]->add(head_p
);
43 for (int i
= 0; i
< end_slur_l_arr_
.size(); i
++)
44 end_slur_l_arr_
[i
]->add(head_p
);
51 Slur_register::process_requests()
53 Array
<Slur
*> start_slur_l_arr_
;
54 for (int i
=0; i
< new_slur_req_l_arr_
.size(); i
++) {
55 Slur_req
* slur_req_l
= new_slur_req_l_arr_
[i
];
56 // end slur: move the slur to other array
57 if (slur_req_l
->spantype
== Span_req::STOP
) {
58 if (slur_l_stack_
.empty())
59 warning("can't find slur to end",
60 slur_req_l
->defined_ch_c_l_
);
62 end_slur_l_arr_
.push(slur_l_stack_
.pop());
65 } else if (slur_req_l
->spantype
== Span_req::START
) {
66 // push a new slur onto stack.
67 //(use temp. array to wait for all slur STOPs)
69 requests_arr_
.push(slur_req_l
);
70 start_slur_l_arr_
.push(s_p
);
71 announce_element(Staff_elem_info(s_p
, slur_req_l
));
74 for (int i
=0; i
< start_slur_l_arr_
.size(); i
++)
75 slur_l_stack_
.push(start_slur_l_arr_
[i
]);
79 Slur_register::pre_move_processing()
81 for (int i
= 0; i
< end_slur_l_arr_
.size(); i
++) {
83 end_slur_l_arr_
[i
]->dir_i_
= dir_i_
;
84 typeset_element(end_slur_l_arr_
[i
]);
86 end_slur_l_arr_
.set_size(0);
90 Slur_register::post_move_processing()
92 new_slur_req_l_arr_
.set_size(0);
94 Slur_register::~Slur_register()
96 for (int i
=0; i
< requests_arr_
.size(); i
++) {
97 warning("unterminated slur", requests_arr_
[i
]->defined_ch_c_l_
);