+static SCM
+zigzag_atom (Grob* me, Real thick, Real dx, Real dy)
+{
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+ SCM ws = me->get_grob_property ("zigzag-width");
+ SCM ls = me->get_grob_property ("zigzag-length");
+ double w = (gh_number_p(ws) ? gh_scm2double(ws) : 1)*staff_space;
+ double l = (gh_number_p(ls) ? gh_scm2double(ls) : 1)*w;
+ double h = l>w/2 ? sqrt(l*l-w*w/4) : 0;
+
+ SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"),
+ gh_bool2scm (true),
+ gh_double2scm (w),
+ gh_double2scm (h),
+ gh_double2scm (thick),
+ gh_double2scm (dx),
+ gh_double2scm (dy),
+ SCM_UNDEFINED);
+
+ return list;
+}
+
+
+
+Molecule
+Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
+{
+ Molecule mol;
+ SCM type = me->get_grob_property ("type");
+ if (gh_symbol_p (type)
+ && (type == ly_symbol2scm ("line")
+ || type == ly_symbol2scm ("dashed-line")
+ || type == ly_symbol2scm ("dotted-line")
+ || (type == ly_symbol2scm ("trill") && dy != 0)))
+ {
+ Box b (Interval (-0.5* thick + (0 <? dx) ,0.5* thick+ (0 >? dx)),
+ Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
+ mol = Molecule (b, line_atom (me, thick, dx, dy));
+ }
+ else if (gh_symbol_p (type)
+ && type == ly_symbol2scm ("zigzag"))
+ {
+ // TODO:
+ Box b (Interval (-0.5* thick + (0 <? dx) ,0.5* thick+ (0 >? dx)),
+ Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
+ mol = Molecule (b, zigzag_atom (me, thick, dx, dy));
+
+ }
+ else if (gh_symbol_p (type)
+ && type == ly_symbol2scm ("trill"))
+ {
+ SCM alist_chain = Font_interface::font_alist_chain (me);
+ SCM style_chain = scm_list_n (gh_cons (ly_symbol2scm ("font-family"),
+ ly_symbol2scm ("music")),
+ SCM_UNDEFINED);
+
+ Font_metric *fm = Font_interface::get_font (me,
+ scm_list_n (style_chain,
+ alist_chain,
+ SCM_UNDEFINED));
+ Molecule m = fm->find_by_name ("scripts-trill-element");
+ do
+ mol.add_at_edge (X_AXIS, RIGHT, m, 0,0);
+ while (m.extent (X_AXIS).length ()
+ && mol.extent (X_AXIS).length ()
+ + m.extent (X_AXIS).length () < dx);
+
+ /*
+ FIXME: should center element on x/y
+ */
+ mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
+ mol.translate_axis (-(mol.extent (Y_AXIS)[DOWN]
+ + mol.extent (Y_AXIS).length ())/2, Y_AXIS);
+ }
+ return mol;
+}
+