]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-reg.cc
release: 0.0.63
[lilypond.git] / lily / slur-reg.cc
1 /*
2   slur-reg.cc -- implement Slur_register
3
4   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6
7 #include "proto.hh"
8 #include "plist.hh"
9 #include "musical-request.hh"
10 #include "complex-walker.hh"
11 #include "slur-reg.hh"
12 #include "slur.hh"
13 #include "debug.hh"
14 #include "note-column.hh"
15
16 bool
17 Slur_register::acceptable_request_b(Request*req_l)
18 {
19     return req_l->musical() && req_l->musical()->slur();
20 }
21
22 bool
23 Slur_register::try_request(Request *req_l)
24 {
25     if(!req_l->slur())
26         return false;
27
28     new_slur_req_l_arr_.push(req_l->slur());
29     return true;
30 }
31
32 void
33 Slur_register::acknowledge_element(Staff_elem_info info)
34 {
35     if (info.elem_l_->name() == Note_column::static_name()) { 
36         Note_column *col_l =(Note_column*) info.elem_l_ ;// ugh
37         for (int i = 0; i < slur_l_stack_.size(); i++)
38             slur_l_stack_[i]->add(col_l );
39         for (int i = 0; i < end_slur_l_arr_.size(); i++)
40             end_slur_l_arr_[i]->add(col_l);
41     }
42 }
43
44 void
45 Slur_register::set_feature(Feature f)
46 {
47     if (f.type_ == "vdir")
48         dir_i_ = f.value_ ;
49 }
50
51 /*
52   abracadabra
53   */
54 Slur_register::Slur_register()
55 {
56     dir_i_ =0;
57 }
58 void
59 Slur_register::process_requests()
60 {
61     Array<Slur*> start_slur_l_arr_;
62     for (int i=0; i< new_slur_req_l_arr_.size(); i++) {
63         Slur_req* slur_req_l = new_slur_req_l_arr_[i];
64         // end slur: move the slur to other array
65         if (slur_req_l->spantype == Span_req::STOP) {
66             if (slur_l_stack_.empty())
67                 
68                       slur_req_l->warning("can't find slur to end");
69             else {
70                 end_slur_l_arr_.push(slur_l_stack_.pop());
71                 requests_arr_.pop();
72             }
73         } else  if (slur_req_l->spantype == Span_req::START) {
74             // push a new slur onto stack.
75             //(use temp. array to wait for all slur STOPs)
76             Slur * s_p =new Slur;
77             requests_arr_.push(slur_req_l);
78             start_slur_l_arr_.push(s_p);
79             announce_element(Staff_elem_info(s_p, slur_req_l));
80         }
81     }
82     for (int i=0; i < start_slur_l_arr_.size(); i++)
83         slur_l_stack_.push(start_slur_l_arr_[i]);
84 }
85
86 void
87 Slur_register::pre_move_processing()
88 {
89     for (int i = 0; i < end_slur_l_arr_.size(); i++) {
90         if (dir_i_)
91             end_slur_l_arr_[i]->dir_i_ = dir_i_;
92         typeset_element(end_slur_l_arr_[i]);
93     }
94     end_slur_l_arr_.set_size(0);
95 }
96
97 void
98 Slur_register::post_move_processing()
99 {
100     new_slur_req_l_arr_.set_size(0);
101 }
102 Slur_register::~Slur_register()
103 {
104     for (int i=0; i < requests_arr_.size(); i++) {
105         requests_arr_[i]->warning("unterminated slur");
106     }
107 }
108 IMPLEMENT_STATIC_NAME(Slur_register);
109 ADD_THIS_REGISTER(Slur_register);