lilypond-0.0.39
[lilypond.git] / src / slur-reg.cc
blob15a9af8eaab10ee75d79a323fa1bf085f50fb62f
1 /*
2 slur-reg.cc -- implement Slur_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "plist.hh"
8 #include "musicalrequest.hh"
9 #include "complex-walker.hh"
10 #include "slur-reg.hh"
11 #include "slur.hh"
12 #include "debug.hh"
13 #include "notehead.hh"
15 void
16 Slur_register::set_feature(Features i)
18 dir_i_ = i.direction_i_;
21 Slur_register::Slur_register()
23 set_feature(Features::dir(0));
26 bool
27 Slur_register::try_request(Request *req_l)
29 if(!req_l->slur())
30 return false;
32 new_slur_req_l_arr_.push(req_l->slur());
33 return true;
36 void
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);
48 abracadabra
50 void
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_);
61 else {
62 end_slur_l_arr_.push(slur_l_stack_.pop());
63 requests_arr_.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)
68 Slur * s_p =new Slur;
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]);
78 void
79 Slur_register::pre_move_processing()
81 for (int i = 0; i < end_slur_l_arr_.size(); i++) {
82 if (dir_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);
89 void
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_);