- Grob *a = ape->grobs_[i];
- vector<Box> boxes = Accidental_interface::accurate_boxes (a, common);
- ape->extents_.insert (ape->extents_.end (), boxes.begin (), boxes.end ());
-
- for (vsize j = boxes.size (); j--;)
- ape->vertical_extent_.unite (boxes[j][Y_AXIS]);
+ Grob *a = accs[i];
+ Pitch *p = accidental_pitch (a);
+
+ if (!p)
+ continue;
+
+ if (i == accs.size () - 1 || p->get_octave () != last_octave)
+ {
+ last_offset = 0;
+ offset = a->extent (a, X_AXIS)[LEFT] - padding;
+ }
+ else if (p->get_alteration () == last_alteration)
+ a->translate_axis (last_offset, X_AXIS);
+ else /* Our alteration is different from the last one */
+ {
+ Real this_offset = offset - a->extent (a, X_AXIS)[RIGHT];
+ a->translate_axis (this_offset, X_AXIS);
+
+ last_offset = this_offset;
+ offset -= a->extent (a, X_AXIS).length () + padding;
+ }
+
+ if (Skyline_pair *sky = unsmob<Skyline_pair> (a->get_property ("horizontal-skylines")))
+ {
+ Skyline_pair copy (*sky);
+ copy.raise (a->relative_coordinate (common[X_AXIS], X_AXIS));
+ copy.shift (a->relative_coordinate (common[Y_AXIS], Y_AXIS));
+ ape->horizontal_skylines_.merge (copy);
+ }
+
+ last_octave = p->get_octave ();
+ last_alteration = p->get_alteration ();