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 lyric-extender)
15 #include "molecule.hh"
16 #include "paper-def.hh"
17 #include "hyphen-spanner.hh"
21 MAKE_SCHEME_CALLBACK(Hyphen_spanner,brew_molecule)
24 Hyphen_spanner::brew_molecule (SCM smob)
26 Spanner * sp = dynamic_cast<Spanner*> (unsmob_element (smob));
28 Score_element * common = sp;
32 common = common->common_refpoint( sp->get_bound (d), X_AXIS);
34 while (flip (&d) != LEFT);
39 Real x = sp->get_bound (d)->relative_coordinate (common, X_AXIS);
40 Interval ext = sp->get_bound (d)->extent (X_AXIS);
41 bounds[d] = (x + ext[-d]);
43 while (flip (&d) != LEFT);
47 Real ss = sp->paper_l ()->get_var ("staffspace");
48 Real lt = sp->paper_l ()->get_var ("stafflinethickness");
49 Real th = gh_scm2double (sp->get_elt_property ("thickness")) * lt ;
50 Real h = gh_scm2double (sp->get_elt_property ("height")) * ss;
51 Real l = gh_scm2double (sp->get_elt_property ("minimum-length")) * ss;
52 // The hyphen can exist in the word space of the left lyric ...
53 SCM space = sp->get_bound (LEFT)->get_elt_property ("word-space");
54 if (gh_number_p (space))
56 bounds[LEFT] -= gh_scm2double (space)*ss;
58 Real w = bounds.length ();
59 /* for length, use a geometric mean of the available space and some minimum
64 Box b (Interval (-l/2,l/2), Interval (h,h+th));
65 Molecule mol (sp->lookup_l ()->filledbox (b));
66 mol.translate_axis (bounds.center ()
67 -sp->relative_coordinate (common, X_AXIS),
69 return mol.create_scheme ();
73 Hyphen_spanner::set_textitem (Direction d, Score_element* b)
75 elt_l_->set_bound (d, b);
76 elt_l_->add_dependency (b);
79 Hyphen_spanner::Hyphen_spanner (Spanner*s)