lilypond-0.1.26
[lilypond.git] / lily / slur-reg.cc
blob2a4963c18af84e73c0b89f5f41e830c0410a0507
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 "musical-request.hh"
10 #include "slur-reg.hh"
11 #include "slur.hh"
12 #include "debug.hh"
13 #include "note-column.hh"
15 bool
16 Slur_register::do_try_request(Request *req_l)
18 Musical_req *mus_l = req_l->musical();
19 if(!mus_l || !mus_l->slur())
20 return false;
22 new_slur_req_l_arr_.push(mus_l->slur());
23 return true;
26 void
27 Slur_register::acknowledge_element(Score_elem_info info)
29 if (info.elem_l_->name() == Note_column::static_name()) {
30 Note_column *col_l =(Note_column*) info.elem_l_->item() ;// ugh
31 for (int i = 0; i < slur_l_stack_.size(); i++)
32 slur_l_stack_[i]->add(col_l );
33 for (int i = 0; i < end_slur_l_arr_.size(); i++)
34 end_slur_l_arr_[i]->add(col_l);
38 void
39 Slur_register::set_feature(Feature f)
41 if (f.type_ == "vdir")
42 dir_i_ = f.value_ ;
46 abracadabra
48 Slur_register::Slur_register()
50 dir_i_ =0;
52 void
53 Slur_register::do_process_requests()
55 Array<Slur*> start_slur_l_arr_;
56 for (int i=0; i< new_slur_req_l_arr_.size(); i++) {
57 Slur_req* slur_req_l = new_slur_req_l_arr_[i];
58 // end slur: move the slur to other array
59 if (slur_req_l->spantype == Span_req::STOP) {
60 if (slur_l_stack_.empty())
62 slur_req_l->warning("can't find slur to end");
63 else {
64 end_slur_l_arr_.push(slur_l_stack_.pop());
65 requests_arr_.pop();
67 } else if (slur_req_l->spantype == Span_req::START) {
68 // push a new slur onto stack.
69 //(use temp. array to wait for all slur STOPs)
70 Slur * s_p =new Slur;
71 requests_arr_.push(slur_req_l);
72 start_slur_l_arr_.push(s_p);
73 announce_element(Score_elem_info(s_p, slur_req_l));
76 for (int i=0; i < start_slur_l_arr_.size(); i++)
77 slur_l_stack_.push(start_slur_l_arr_[i]);
80 void
81 Slur_register::do_pre_move_processing()
83 for (int i = 0; i < end_slur_l_arr_.size(); i++) {
84 if (dir_i_)
85 end_slur_l_arr_[i]->dir_i_ = dir_i_;
86 typeset_element(end_slur_l_arr_[i]);
88 end_slur_l_arr_.set_size(0);
91 void
92 Slur_register::do_post_move_processing()
94 new_slur_req_l_arr_.set_size(0);
96 Slur_register::~Slur_register()
98 for (int i=0; i < requests_arr_.size(); i++) {
99 requests_arr_[i]->warning("unterminated slur");
102 IMPLEMENT_STATIC_NAME(Slur_register);
103 IMPLEMENT_IS_TYPE_B1(Slur_register,Request_register);
104 ADD_THIS_REGISTER(Slur_register);