-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)))
- {
- s = set_extremities (me);
- }
-
- 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;
-
- int slurdir = gh_scm2int (me->get_grob_property ("direction"));
-
- 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
- */
- Real stem_thickness =
- gh_scm2double (stem->get_grob_property ("thickness"))
- * stem->paper_l ()->get_var ("linethickness");
- o += Offset (0.5 *
- x_extent * (1 + Stem::get_direction (stem))
- - ((dir + 1)/2) * stem_thickness
- + ((1 - slurdir)/2) * stem_thickness,
- 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.