2 staff-side.cc -- implement Staff_side
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "staff-side.hh"
11 #include "staff-sym.hh"
15 Staff_side::set_staffsym(Staff_symbol
* s_l
)
20 Staff_side::Staff_side(Staff_elem
* elem_l
)
27 inside_staff_b_
=false;
31 Staff_side::read_staff_sym()
35 inter_f_
= staff_sym_l_
->inter_note_f();
36 staff_size_i_
= staff_sym_l_
->steps_i();
41 Staff_side::support_height() const
45 for (int i
=0; i
< support_l_arr_
.size(); i
++)
46 r
.unite(support_l_arr_
[i
]->height());
54 Staff_side::add_support(Staff_elem
*i
)
56 support_l_arr_
.push(i
);
57 elem_l_
->add_dependency(i
);
61 Staff_side::get_position_i()const
63 ((Staff_side
*)this)->read_staff_sym();
65 warning("Staff_side::get_position_i(): "
66 "somebody forgot to set my vertical direction, returning -20");
72 if (!inside_staff_b_
) {
73 y
= (dir_i_
> 0) ? staff_size_i_
+ 2: -2;
75 Interval v
= support_height();
78 y
= y
>? (v
.max() + 2*inter_f_
);
79 } else if (dir_i_
< 0) {
80 y
= y
<? (v
.min() - 2*inter_f_
);
83 Interval v
= support_height();
84 y
= v
[dir_i_
] + 2*dir_i_
*inter_f_
; // ugh
86 return int(rint(Real(y
)/inter_f_
)); // should ret a float?
90 Staff_side::get_position_i(Interval sym_dim
) const
92 int i
= get_position_i();
93 return i
+ int(rint(- sym_dim
[-dir_i_
] / inter_f_
));