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"
15 Dot_column::add_dots (Dots *d)
17 Group_interface gi (this, "dots");
25 Dot_column::add_head (Rhythmic_head *r)
31 add_dots (r->dots_l ());
36 Dot_column::compare (Dots * const &d1, Dots * const &d2)
38 return int (d1->position_f () - d2->position_f ());
42 Dot_column::Dot_column ()
44 Group_interface gi (this, "dots");
47 set_direction (RIGHT);
48 set_axes(X_AXIS,X_AXIS);
52 Will fuck up in this case.
67 Dot_column::do_post_processing ()
69 Link_array<Dots> dots = Group_interface__extract_elements (this, (Dots*)0 , "dots");
70 dots.sort (Dot_column::compare);
77 Array<int> taken_posns;
79 for (int i=0; i < dots.size (); i++)
81 for (int j=0; j < taken_posns.size (); j++)
82 if (taken_posns[j] == (int) dots[i]->position_f ())
84 taken_posns.push ((int)dots[i]->position_f ());
85 s.unite (Slice ((int)dots[i]->position_f (),
86 (int)dots[i]->position_f ()));
92 int middle = s.center ();
96 int pos = middle - dots.size () + 1;
98 pos ++; // center () rounds down.
100 for (int i=0; i <dots.size (); pos += 2, i++)
102 dots[i]->set_position(pos);