2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dot-column.hh"
11 #include "rhythmic-head.hh"
12 #include "group-interface.hh"
13 #include "staff-symbol-referencer.hh"
14 #include "directional-element-interface.hh"
17 Dot_column::add_dots (Dots *d)
19 Group_interface gi (this, "dots");
27 Dot_column::add_head (Rhythmic_head *r)
33 add_dots (r->dots_l ());
38 Dot_column::compare (Dots * const &d1, Dots * const &d2)
40 Staff_symbol_referencer_interface s1(d1);
41 Staff_symbol_referencer_interface s2(d2);
44 return int (s1.position_f () - s2.position_f ());
48 Dot_column::Dot_column ()
50 Group_interface gi (this, "dots");
53 directional_element (this).set (RIGHT);
54 set_axes(X_AXIS,X_AXIS);
58 Will fuck up in this case.
73 Dot_column::do_post_processing ()
75 Link_array<Dots> dots = Group_interface__extract_elements (this, (Dots*)0 , "dots");
76 dots.sort (Dot_column::compare);
83 Array<int> taken_posns;
85 for (int i=0; i < dots.size (); i++)
87 Real p = Staff_symbol_referencer_interface (dots[i]).position_f ();
88 for (int j=0; j < taken_posns.size (); j++)
90 if (taken_posns[j] == (int) p)
93 taken_posns.push ((int)p);
94 s.unite (Slice ((int)p,
101 int middle = s.center ();
105 int pos = middle - dots.size () + 1;
107 pos ++; // center () rounds down.
109 for (int i=0; i <dots.size (); pos += 2, i++)
111 staff_symbol_referencer (dots[i]).set_position(pos);