- else
- {
- y = encompass_offset (me, col, common)[Y_AXIS]
- - me->relative_coordinate (common[Y_AXIS], Y_AXIS);
- }
- return y;
-}
-
-Offset
-Slur::broken_trend_offset (Grob *me, Direction dir)
-{
- /*
- A broken slur should maintain the same vertical trend
- the unbroken slur would have had.
- */
- 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;
-
- 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 ("stafflinethickness");
- 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.
-
- 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);
- }
-
- SCM alist = me->get_grob_property ("extremity-offset-alist");
- int stemdir = stem ? Stem::get_direction (stem) : 1;
- SCM l = scm_assoc
- (scm_list_n (a,
- gh_int2scm (stemdir * dir),
- gh_int2scm (slurdir * dir),
- SCM_UNDEFINED), alist);
-
- if (l != SCM_BOOL_F)
- {
- Offset off = ly_scm2offset (ly_cdr (l)) * staff_space;
- off[X_AXIS] *= dir;
- off[Y_AXIS] *= Directional_element_interface::get (me);
- o += off;
- }
-
- /*
- What if get_bound () is not a note-column?
- */
- if (str != "loose-end"
- && sp->get_bound (dir)->common_refpoint (common[Y_AXIS], Y_AXIS) == common[Y_AXIS])
- {
- o[Y_AXIS] += sp->get_bound (dir)->relative_coordinate (common[Y_AXIS], Y_AXIS)
- - me->relative_coordinate (common[Y_AXIS], Y_AXIS);
- }
-
- Offset off = ly_scm2offset (index_cell (me->get_grob_property
- ("attachment-offset"),
- dir)) * staff_space;