blob: b92892de6fde6f1c71d8077f5962a795f22a7db9 (
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#include "musical-request.hh"
#include "paper-def.hh"
#include "script.hh"
#include "stem.hh"
#include "molecule.hh"
#include "lookup.hh"
void
Script::set_stem(Stem*st_l)
{
stem_l_ = st_l;
add_dependency(st_l);
}
void
Script::set_support(Item*i)
{
support.push(i);
add_dependency(i);
}
Script::Script(Script_req* rq, int staflen)
{
staffsize =staflen;
specs_l_ = rq->scriptdef_p_;
stem_l_ = 0;
pos = 0;
symdir=1;
dir =rq->dir_i_;
}
void
Script::set_symdir()
{
if (specs_l_->invertsym)
symdir = (dir < 0) ? -1:1;
}
void
Script::set_default_dir()
{
if (specs_l_->stemdir) {
if (!stem_l_)
dir = 1;
else
dir = stem_l_->dir * specs_l_->stemdir;
}
}
Interval
Script::support_height() const return r;
{
for (int i=0; i < support.size(); i++)
r.unite(support[i]->height());
}
void
Script::set_default_index()
{
Real inter_f= paper()->internote();
Interval dy = symbol().dim.y;
int d = specs_l_->staffdir;
Real y ;
if (!d) {
Interval v= support_height();
y = v[dir] -dy[-dir] + 2*dir*inter_f;
} else {
y = (d > 0) ? staffsize + 2: -2; // ug
y *=inter_f;
Interval v= support_height();
if (d > 0) {
y = y >? v.max();
} else if (d < 0) {
y = y <? v.min();
}
}
if (stem_l_) {
Interval v= stem_l_->height();
if (d > 0 || (!d && dir > 0)) {
y = y >? v.max();
}else if (d < 0 || (!d && dir < 0)) {
y = y <? v.min();
}
}
pos = int(rint(Real(y)/inter_f));
}
Interval
Script::width() const
{
return symbol().dim.x;
}
Symbol
Script::symbol()const
{
String preidx_str = (symdir < 0) ?"-" :"";
return paper()->lookup_l()->script(preidx_str + specs_l_->symidx);
}
void
Script::do_pre_processing()
{
set_default_dir();
set_symdir();
}
void
Script::do_post_processing()
{
set_default_index();
}
Molecule*
Script::brew_molecule_p() const
{
Real dy = paper()->internote();
Molecule*out = new Molecule(Atom(symbol()));
out->translate(Offset(0,dy * pos));
return out;
}
IMPLEMENT_STATIC_NAME(Script);
|