2 staff-side.cc -- implement Staff_side
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "paper-def.hh"
12 #include "staff-side.hh"
13 #include "staff-sym.hh"
17 Staff_side::set_staffsym(Staff_symbol* s_l)
20 add_dependency( s_l );
23 Staff_side::Staff_side()
26 sym_int_ = Interval(0,0);
30 inside_staff_b_ =false;
34 Staff_side::read_staff_sym()
38 staff_size_i_ = staff_sym_l_->steps_i();
43 Staff_side::support_height() const
47 for (int i=0; i < support_l_arr_.size(); i++)
48 r.unite(support_l_arr_[i]->height());
56 Staff_side::add_support(Score_elem*i)
58 support_l_arr_.push(i);
63 Staff_side::get_position_i()const
66 warning("Staff_side::get_position_i(): "
67 "somebody forgot to set my vertical direction, returning -20");
73 Real inter_f = paper()-> internote_f();
74 if (!inside_staff_b_) {
75 y = (dir_i_ > 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2;
77 Interval v= support_height();
80 y = y >? (v.max() + 2*inter_f);
81 } else if (dir_i_ < 0) {
82 y = y <? (v.min() - 2*inter_f);
85 Interval v= support_height();
86 y = v[dir_i_] + 2*dir_i_*inter_f; // ugh
88 return int(rint(Real(y)/inter_f)); // should ret a float?
92 Staff_side::symbol_height() const
98 Staff_side::do_post_processing()
100 sym_int_ = symbol_height();
101 pos_i_ = get_position_i( );
103 pos_i_ += int(rint(- sym_int_[-dir_i_] / paper()->internote_f()));
107 Staff_side::do_substitute_dependency(Score_elem*o, Score_elem*n)
110 while ((i=support_l_arr_.find_i(o) ) >=0)
112 support_l_arr_[i] = n;
114 support_l_arr_.del(i);
116 if (staff_sym_l_ == o)
117 staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0;
120 IMPLEMENT_STATIC_NAME(Staff_side);
121 IMPLEMENT_IS_TYPE_B1(Staff_side, Score_elem);