- {
- if (Text_interface::has_interface (b))
- {
- Interval e = b->extent (common, X_AXIS);
- if (!e.is_empty ())
- x_points[d] = e[-d] - d * padding;
- }
- else
- {
- bool neighbor_found = false;
- extract_grob_set (me, "adjacent-hairpins", pins);
- for (vsize i = 0; i < pins.size (); i++)
- {
- /*
- FIXME: this will fuck up in case of polyphonic
- notes in other voices. Need to look at note-columns
- in the current staff/voice.
- */
-
- Spanner *pin = dynamic_cast<Spanner *> (pins[i]);
- if (pin
- && (pin->get_bound (LEFT)->get_column () == b->get_column ()
- || pin->get_bound (RIGHT)->get_column () == b->get_column ()))
- neighbor_found = true;
- }
-
- Interval e = robust_relative_extent (b, common, X_AXIS);
- if (neighbor_found)
- {
- /*
- Handle back-to-back hairpins with a circle in the middle
- */
- if (circled_tip && (grow_dir != d))
- x_points[d] = e.center () + d * (rad - thick / 2.0);
- /*
- If we're hung on a paper column, that means we're not
- adjacent to a text-dynamic, and we may move closer. We
- make the padding a little smaller, here.
- */
- else
- x_points[d] = e.center () - d * padding / 3;
- }
- else
- {
- if (Note_column::has_interface (b)
- && Note_column::has_rests (b))
- x_points[d] = e[-d];
- else
- x_points[d] = e[d];
-
- Item *bound = me->get_bound (d);
- if (bound->is_non_musical (bound))
- x_points[d] -= d * padding;
- }
- }
- }
+ {
+ if (Text_interface::has_interface (b))
+ {
+ if (!e.is_empty ())
+ x_points[d] = e[-d] - d * padding;
+ }
+ else
+ {
+ bool neighbor_found = false;
+ Spanner *adjacent = NULL;
+ extract_grob_set (me, "adjacent-spanners", neighbors);
+ for (vsize i = 0; i < neighbors.size (); i++)
+ {
+ /*
+ FIXME: this will fuck up in case of polyphonic
+ notes in other voices. Need to look at note-columns
+ in the current staff/voice.
+ */
+ adjacent = dynamic_cast<Spanner *> (neighbors[i]);
+ if (adjacent
+ && (adjacent->get_bound (-d)->get_column ()
+ == b->get_column ()))
+ {
+ neighbor_found = true;
+ break;
+ }
+ }
+
+ if (neighbor_found)
+ {
+ if (Hairpin::has_interface (adjacent))
+ {
+ /*
+ Handle back-to-back hairpins with a circle in the middle
+ */
+ if (circled_tip && (grow_dir != d))
+ x_points[d] = e.center () + d * (rad - thick / 2.0);
+ /*
+ If we're hung on a paper column, that means we're not
+ adjacent to a text-dynamic, and we may move closer. We
+ make the padding a little smaller, here.
+ */
+ else
+ x_points[d] = e.center () - d * padding / 3;
+ }
+ // Our neighbor is a dynamic text spanner.
+ // If we end on the text, pad as for text dynamics
+ else if (d == RIGHT)
+ x_points[d] = e[-d] - d * padding;
+ }
+ else
+ {
+ if (d == RIGHT // end at the left edge of a rest
+ && Note_column::has_interface (b)
+ && Note_column::has_rests (b))
+ x_points[d] = e[-d];
+ else
+ x_points[d] = e[d];
+
+ if (Item::is_non_musical (b))
+ x_points[d] -= d * padding;
+ }
+ }
+ }