2 staff-side.cc -- implement Staff_side
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "paper-def.hh"
11 #include "staff-side.hh"
12 #include "staff-sym.hh"
14 #include "dimensions.hh"
17 Staff_side::Staff_side()
19 coordinate_offset_f_=0;
20 sym_int_ = Interval (0,0);
28 Staff_side::support_extent() const
31 for (int i=0; i < support_l_arr_.size(); i++)
33 Dimension_cache *common =
34 common_group (support_l_arr_[i], axis_);
36 Real y = support_l_arr_[i]->relative_coordinate (common, axis_)
37 -relative_coordinate (common,axis_);
39 y_int.unite (y + support_l_arr_[i]->extent(axis_));
44 y_int = Interval (0,0);
46 return Interval(y_int[LEFT] - padding_f_, y_int[RIGHT] + padding_f_);
50 Staff_side::add_support (Score_element*i)
52 support_l_arr_.push (i);
57 Staff_side::get_position_f () const
61 warning (_ ("Staff_side::get_position_f(): "
62 "somebody forgot to set my direction, returning -20"));
68 Real inter_f = paper()-> internote_f ();
70 Interval v = support_extent();
72 // ugh, dim[y] = PT over here
73 y = v[dir_] + 1 * dir_ * inter_f;
75 int coordinate_offset_f_i = (int)rint (y / inter_f);
76 // ugh: 5 -> staff_lines
77 if (axis_ == Y_AXIS && abs (coordinate_offset_f_i) < 5)
79 if (!(abs (coordinate_offset_f_i) % 2))
80 y += (Real)dir_ * inter_f;
87 Staff_side::symbol_height() const
89 return Interval (0,0);
93 Staff_side::do_pre_processing ()
96 do_side_processing ();
100 Staff_side::do_side_processing ()
102 sym_int_ = symbol_extent();
103 coordinate_offset_f_ = get_position_f();
105 coordinate_offset_f_ += - sym_int_[-dir_];
110 ugh should use do_width (), do_height (), get_extent ()
113 Staff_side::symbol_extent () const
116 return symbol_height ();
125 Staff_side::do_post_processing()
128 do_side_processing ();
132 Staff_side::do_substitute_dependency (Score_element*o, Score_element*n)
134 support_l_arr_.unordered_substitute (o,n);