+
+/*
+ Ugh should have dash-length + dash-period
+ */
+MAKE_SCHEME_CALLBACK(Slur,brew_molecule);
+SCM
+Slur::brew_molecule (SCM smob)
+{
+ Score_element * me = unsmob_element (smob);
+ Real thick = me->paper_l ()->get_var ("stafflinethickness") *
+ gh_scm2double (me->get_elt_property ("thickness"));
+ Bezier one = get_curve (me);
+
+ Molecule a;
+ SCM d = me->get_elt_property ("dashed");
+ if (gh_number_p (d))
+ a = me->lookup_l ()->dashed_slur (one, thick, thick * gh_scm2double (d));
+ else
+ a = me->lookup_l ()->slur (one, Directional_element_interface (me).get () * thick, thick);
+
+ return a.create_scheme();
+}
+
+void
+Slur::set_control_points (Score_element*me)
+{
+ Real staff_space = Staff_symbol_referencer::staff_space ((Score_element*)me);
+ Real h_inf = me->paper_l ()->get_var ("slur_height_limit_factor") *
+ staff_space;
+ Real r_0 = me->paper_l ()->get_var ("slur_ratio");
+
+ Slur_bezier_bow bb (get_encompass_offset_arr (me),
+ Directional_element_interface (me).get (),
+ h_inf, r_0);
+
+ if (bb.fit_factor () > 1.0)
+ {
+ Real length = bb.curve_.control_[3][X_AXIS];
+ Real default_height = slur_height (length, h_inf, r_0);
+ bb.minimise_enclosed_area (me->paper_l());
+
+ Real bff = me->paper_l ()->get_var ("slur_force_blowfit");
+ bb.curve_.control_[1][Y_AXIS] *= bff;
+ bb.curve_.control_[2][Y_AXIS] *= bff;
+ bb.blow_fit ();
+
+ Real sb = me->paper_l ()->get_var ("slur_beautiful");
+ Real beautiful = length * default_height * sb;
+ Real area = bb.enclosed_area_f ();
+
+ /*
+ Slurs that fit beautifully are not ugly
+ */
+ if (area > beautiful)
+ de_uglyfy (me, &bb, default_height);
+ }
+
+ Bezier b = bb.get_bezier ();
+
+
+ SCM controls = SCM_EOL;
+ for (int i= 4; i--;)
+ controls = gh_cons ( ly_offset2scm (b.control_[i]), controls);
+
+ me->set_elt_property ("control-points", controls);
+}
+
+
+Bezier
+Slur::get_curve (Score_element*me)
+{
+ Bezier b;
+ int i = 0;
+
+ if (!Directional_element_interface (me).get ()
+ || ! gh_symbol_p (index_cell (me->get_elt_property ("attachment"), LEFT)))
+ set_extremities (me);
+
+ if (!gh_pair_p (me->get_elt_property ("control-points")))
+ set_control_points (me);
+
+
+ for (SCM s= me->get_elt_property ("control-points"); s != SCM_EOL; s = gh_cdr (s))
+ {
+ b.control_[i] = ly_scm2offset (gh_car (s));
+ i++;
+ }
+
+ Array<Offset> enc (get_encompass_offset_arr (me));
+ Direction dir = Directional_element_interface (me).get ();
+
+ Real x1 = enc[0][X_AXIS];
+ Real x2 = enc.top ()[X_AXIS];
+
+ Real off = 0.0;
+ for (int i=1; i < enc.size ()-1; i++)
+ {
+ Real x = enc[i][X_AXIS];
+ if (x > x1 && x <x2)
+ {
+ Real y = b.get_other_coordinate (X_AXIS, x);
+ off = off >? dir * (enc[i][Y_AXIS] - y);
+ }
+ }
+ b.translate (Offset (0, dir * off));
+ return b;
+}
+
+
+bool
+Slur::has_interface (Score_element*me)
+{
+ return me->has_interface (ly_symbol2scm ("slur-interface"));