2 hyphen-spanner.cc -- implement Hyphen_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Glen Prideaux <glenprideaux@iname.com>
8 (adapted from extender-spanner)
15 #include "molecule.hh"
16 #include "paper-def.hh"
17 #include "hyphen-spanner.hh"
21 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Hyphen_spanner,brew_molecule)
24 Hyphen_spanner::brew_molecule (SCM smob)
26 Spanner * sp =dynamic_cast<Spanner*> (unsmob_element (smob));
29 Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length ();
31 Real ss = sp->paper_l ()->get_var ("staffspace");
32 Real lt = sp->paper_l ()->get_var ("stafflinethickness");
33 Real th = gh_scm2double (sp->get_elt_property ("thickness")) * lt ;
34 Real h = gh_scm2double (sp->get_elt_property ("height")) * ss;
35 Real l = gh_scm2double (sp->get_elt_property ("minimum-length")) * ss;
36 Real w = sp->spanner_length () - leftext - ss/2;
39 /* First try: just make the hyphen take 1/3 of the available space
40 for length, use a geometric mean of the available space and some minimum
45 Box b (Interval ( (w-l)/2, (w+l)/2), Interval (h,h+th));
46 mol.add_molecule (sp->lookup_l ()->filledbox (b));
47 mol.translate_axis(leftext, X_AXIS);
48 return mol.create_scheme ();
52 Hyphen_spanner::set_textitem (Direction d, Item* textitem_l)
54 elt_l_->set_bound (d, textitem_l);
55 elt_l_->add_dependency (textitem_l);
58 Hyphen_spanner::Hyphen_spanner (Spanner*s)