lilypond-0.0.39
[lilypond.git] / lily / slur-reg.cc
blobf2b7113ca0cc277ca86647192ecdff15bd8f469b
1 /*
2 slur-reg.cc -- implement Slur_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "proto.hh"
8 #include "plist.hh"
9 #include "musicalrequest.hh"
10 #include "complex-walker.hh"
11 #include "slur-reg.hh"
12 #include "slur.hh"
13 #include "debug.hh"
14 #include "notehead.hh"
16 void
17 Slur_register::set_feature(Features i)
19 dir_i_ = i.direction_i_;
22 Slur_register::Slur_register()
24 set_feature(Features::dir(0));
27 bool
28 Slur_register::try_request(Request *req_l)
30 if(!req_l->slur())
31 return false;
33 new_slur_req_l_arr_.push(req_l->slur());
34 return true;
37 void
38 Slur_register::acknowledge_element(Staff_elem_info info)
40 if (info.elem_p_->name() == Notehead::static_name()) {
41 Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh
42 for (int i = 0; i < slur_l_stack_.size(); i++)
43 slur_l_stack_[i]->add(head_p );
44 for (int i = 0; i < end_slur_l_arr_.size(); i++)
45 end_slur_l_arr_[i]->add(head_p);
49 abracadabra
51 void
52 Slur_register::process_requests()
54 Array<Slur*> start_slur_l_arr_;
55 for (int i=0; i< new_slur_req_l_arr_.size(); i++) {
56 Slur_req* slur_req_l = new_slur_req_l_arr_[i];
57 // end slur: move the slur to other array
58 if (slur_req_l->spantype == Span_req::STOP) {
59 if (slur_l_stack_.empty())
60 warning("can't find slur to end",
61 slur_req_l->defined_ch_c_l_);
62 else {
63 end_slur_l_arr_.push(slur_l_stack_.pop());
64 requests_arr_.pop();
66 } else if (slur_req_l->spantype == Span_req::START) {
67 // push a new slur onto stack.
68 //(use temp. array to wait for all slur STOPs)
69 Slur * s_p =new Slur;
70 requests_arr_.push(slur_req_l);
71 start_slur_l_arr_.push(s_p);
72 announce_element(Staff_elem_info(s_p, slur_req_l));
75 for (int i=0; i < start_slur_l_arr_.size(); i++)
76 slur_l_stack_.push(start_slur_l_arr_[i]);
79 void
80 Slur_register::pre_move_processing()
82 for (int i = 0; i < end_slur_l_arr_.size(); i++) {
83 if (dir_i_)
84 end_slur_l_arr_[i]->dir_i_ = dir_i_;
85 typeset_element(end_slur_l_arr_[i]);
87 end_slur_l_arr_.set_size(0);
90 void
91 Slur_register::post_move_processing()
93 new_slur_req_l_arr_.set_size(0);
95 Slur_register::~Slur_register()
97 for (int i=0; i < requests_arr_.size(); i++) {
98 warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_);