-void
-Tie::do_substitute_element_pointer (Score_element*o, Score_element*n)
-{
- Note_head *new_l =n?dynamic_cast<Note_head *> (n):0;
- if (dynamic_cast <Item *> (o) == head_l_drul_[LEFT])
- head_l_drul_[LEFT] = new_l;
- else if (dynamic_cast <Item *> (o) == head_l_drul_[RIGHT])
- head_l_drul_[RIGHT] = new_l;
+ b = slur_shape (width,h_inf, r_0);
+ b.scale (1, dir);
+ b.translate (Offset (left_x, ypos));
+
+
+ /*
+ Avoid colliding of the horizontal part with stafflines.
+
+
+ TODO: redo this, heuristic is half-baken, and ties often look ugly
+ as a result.
+
+ TODO: doesn't work when on staff with even number of lines.
+ */
+ Array<Real> horizontal (b.solve_derivative (Offset (1,0)));
+ if (horizontal.size ())
+ {
+ /*
+ ugh. Doesnt work for non-horizontal curves.
+ */
+ Real y = b.curve_point (horizontal[0])[Y_AXIS];
+
+ Real ry = rint (y/staff_space) * staff_space;
+ Real diff = ry - y;
+ Real newy = y;
+
+ Real clear = staff_space * gh_scm2double (me->get_grob_property ("staffline-clearance"));
+
+ if (fabs (y) <= Staff_symbol_referencer::staff_radius (me)
+ && fabs (diff) < clear)
+ {
+ Real y1 = ry + clear;
+ Real y2 = ry - clear;
+
+ newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2;
+
+ // newy = ry - 0.5 * staff_space * sign (diff) ;
+
+ /*
+ we don't want horizontal ties
+ */
+ if (fabs (newy - b.control_[0][Y_AXIS]) < 1e-2)
+ {
+ newy = newy + dir * staff_space;
+ }
+ }
+
+ Real y0 = b.control_ [0][Y_AXIS];
+ b.control_[2][Y_AXIS] =
+ b.control_[1][Y_AXIS] =
+ (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0;
+ }
+ else
+ programming_error ("Tie is nowhere horizontal");
+
+
+
+ SCM controls = SCM_EOL;
+ for (int i= 4; i--;)
+ controls = gh_cons (ly_offset2scm (b.control_[i]), controls);
+ return controls;