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