- #if 0
- bool rest_b_a[4];
- rest_b_a[j] = (col_l_a[j]) ? col_l_a[j]->rest_b_ : false;
- do {
- int i1 = idx(d, false);
- int i2 = idx(d,true);
- if (!intersection(y_extent[i1] ,
- y_extent[i2]).empty_b()) {
- if (rest_b_a[i1]) {
- y_off[i1] = -y_extent[i1][-d] + y_extent[1][d] + d*4; // ugh
- y_extent[i1] += y_off[i1];
+ Grob * s = unsmob_grob (col->get_property ("rest"));
+
+ if (!s)
+ return SCM_BOOL_F;
+ else
+ return gh_cons (s->get_property ("duration-log"),
+ gh_int2scm (Rhythmic_head::dot_count (s)));
+}
+
+/*
+ TODO: look at horizontal-shift to determine ordering between rests
+ for more than two voices.
+
+ */
+SCM
+Rest_collision::do_shift (Grob *me)
+{
+ SCM elts = me->get_property ("elements");
+
+ Link_array<Grob> rests;
+ Link_array<Grob> notes;
+
+ for (SCM s = elts; gh_pair_p (s); s = ly_cdr (s))
+ {
+ Grob * e = unsmob_grob (ly_car (s));
+ if (unsmob_grob (e->get_property ("rest")))
+ {
+ /*
+ Ignore rests under beam.
+ */
+ Grob* st = unsmob_grob (e->get_property ("stem"));
+ if (st && unsmob_grob (st->get_property ("beam")))
+ continue;
+
+ rests.push (e);
+ }
+ else
+ notes.push (e);
+ }
+
+
+ /*
+ handle rest-rest and rest-note collisions
+
+ [todo]
+ * decide not to print rest if too crowded?
+ */
+
+ /*
+ no partners to collide with
+ */
+ if (rests.size () + notes.size () < 2)
+ return SCM_UNSPECIFIED;
+
+
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+ /*
+ only rests
+ */
+ if (!notes.size ())
+ {
+
+ /*
+ This is incomplete: in case of an uneven number of rests, the
+ center one should be centered on the staff.
+ */
+ Drul_array< Link_array <Grob > > ordered_rests;
+ for (int i= 0; i < rests.size (); i++)
+ {
+ Grob * r = Note_column::get_rest (rests[i]);
+
+ Direction d = get_grob_direction (r);
+ if (d)
+ {
+ ordered_rests[d].push (rests[i]);