- Offset o;
- if (Spanner *mother = dynamic_cast<Spanner*> (me->original_l_))
- {
- for (int i = dir == LEFT ? 0 : mother->broken_into_l_arr_.size () - 1;
- dir == LEFT ? i < mother->broken_into_l_arr_.size () : i > 0;
- dir == LEFT ? i++ : i--)
- {
- if (mother->broken_into_l_arr_[i - dir] == me)
- {
- Grob *neighbour = mother->broken_into_l_arr_[i];
- if (dir == RIGHT)
- neighbour->set_grob_property ("direction",
- me->get_grob_property ("direction"));
- Real neighbour_y = get_first_notecolumn_y (neighbour, dir);
- Real y = get_first_notecolumn_y (me, -dir);
- int neighbour_cols = scm_ilength (neighbour->get_grob_property ("note-columns"));
- int cols = scm_ilength (me->get_grob_property ("note-columns"));
- o = Offset (0, (y*neighbour_cols + neighbour_y*cols) /
- (cols + neighbour_cols));
- break;
- }
- }
- }
- return o;
-}
-
-Offset
-Slur::get_attachment (Grob *me, Direction dir,
- Grob **common)
-{
- SCM s = me->get_grob_property ("attachment");
- if (!gh_symbol_p (index_cell (s, dir)))
- {
- set_extremities (me);
- s = me->get_grob_property ("attachment");
- }
- SCM a = dir == LEFT ? ly_car (s) : ly_cdr (s);
- Spanner*sp = dynamic_cast<Spanner*> (me);
- String str = ly_symbol2string (a);
- Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
- Real hs = staff_space / 2.0;
- Offset o;
-
- Grob *stem = 0;
- if (Note_column::has_interface (sp->get_bound (dir)))
- {
- Grob * n =sp->get_bound (dir);
- if ((stem = Note_column::stem_l (n)))
- {
- Real x_extent;
- if (Grob *head = Note_column::first_head (n))
- x_extent = head->extent (head, X_AXIS).length ();
- else
- x_extent = n->extent (n, X_AXIS).length ();
-
- if (str == "head")
- {
- o = Offset (0, Stem::head_positions (stem)
- [Directional_element_interface::get (me)] * hs);
- /*
- Default position is centered in X, on outer side of head Y
- */
- o += Offset (0.5 * x_extent,
- 0.5 * staff_space
- * Directional_element_interface::get (me));
- }
- else if (str == "alongside-stem")
- {
- o = Offset (0, Stem::chord_start_f (stem));
- /*
- Default position is on stem X, on outer side of head Y
- */
- o += Offset (x_extent * (1 + Stem::get_direction (stem)),
- 0.5 * staff_space
- * Directional_element_interface::get (me));
- }
- else if (str == "stem")
- {
- o = Offset (0, Stem::stem_end_position (stem) * hs);
- /*
- Default position is on stem X, at stem end Y
- */
- o += Offset (0.5 *
- x_extent * (1 + Stem::get_direction (stem)),
- 0);
- }
- }
- }
- /*
- If we're not a note_column, we can't be anything but a loose-end.
- But if user has set (attachment . (stem . stem)), our string is
- stem, not loose-end.
-
- Hmm, maybe after-line-breaking should set this to loose-end? */
- else // if (str == "loose-end")
- {
- SCM other_a = dir == LEFT ? ly_cdr (s) : ly_car (s);
- if (ly_symbol2string (other_a) != "loose-end")
- o = broken_trend_offset (me, dir);
- }