2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 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"
16 Dot_column::add_dots (Dots *d)
18 Group_interface gi (this, "dots");
26 Dot_column::add_head (Rhythmic_head *r)
32 add_dots (r->dots_l ());
37 Dot_column::compare (Dots * const &d1, Dots * const &d2)
39 Staff_symbol_referencer_interface s1(d1);
40 Staff_symbol_referencer_interface s2(d2);
43 return int (s1.position_f () - s2.position_f ());
47 Dot_column::Dot_column ()
49 Group_interface gi (this, "dots");
52 set_direction (RIGHT);
53 set_axes(X_AXIS,X_AXIS);
57 Will fuck up in this case.
72 Dot_column::do_post_processing ()
74 Link_array<Dots> dots = Group_interface__extract_elements (this, (Dots*)0 , "dots");
75 dots.sort (Dot_column::compare);
82 Array<int> taken_posns;
84 for (int i=0; i < dots.size (); i++)
86 Real p = Staff_symbol_referencer_interface (dots[i]).position_f ();
87 for (int j=0; j < taken_posns.size (); j++)
89 if (taken_posns[j] == (int) p)
92 taken_posns.push ((int)p);
93 s.unite (Slice ((int)p,
100 int middle = s.center ();
104 int pos = middle - dots.size () + 1;
106 pos ++; // center () rounds down.
108 for (int i=0; i <dots.size (); pos += 2, i++)
110 staff_symbol_referencer_interface (dots[i]).set_position(pos);