From: fred Date: Tue, 26 Mar 2002 23:23:34 +0000 (+0000) Subject: lilypond-1.3.64 X-Git-Tag: release/1.5.59~1547 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cac331ada2705feb6c2fe8d8232061bbd8124b1d;p=lilypond.git lilypond-1.3.64 --- diff --git a/lily/hyphen-spanner.cc b/lily/hyphen-spanner.cc index 624f682be2..af618e87ca 100644 --- a/lily/hyphen-spanner.cc +++ b/lily/hyphen-spanner.cc @@ -5,7 +5,7 @@ (c) 1999 Glen Prideaux - (adapted from extender-spanner) + (adapted from lyric-extender) */ #include @@ -23,36 +23,52 @@ MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Hyphen_spanner,brew_molecule) SCM Hyphen_spanner::brew_molecule (SCM smob) { - Spanner * sp =dynamic_cast (unsmob_element (smob)); - Molecule mol; + Spanner * sp = dynamic_cast (unsmob_element (smob)); - Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length (); + Score_element * common = sp; + Direction d = LEFT; + do + { + common = common->common_refpoint( sp->get_bound (d), X_AXIS); + } + while (flip (&d) != LEFT); + Interval bounds; + + do + { + Real x = sp->get_bound (d)->relative_coordinate (common, X_AXIS); + Interval ext = sp->get_bound (d)->extent (X_AXIS); + bounds[d] = (x + ext[-d]); + } + while (flip (&d) != LEFT); + + Real ss = sp->paper_l ()->get_var ("staffspace"); Real lt = sp->paper_l ()->get_var ("stafflinethickness"); Real th = gh_scm2double (sp->get_elt_property ("thickness")) * lt ; Real h = gh_scm2double (sp->get_elt_property ("height")) * ss; Real l = gh_scm2double (sp->get_elt_property ("minimum-length")) * ss; - Real w = sp->spanner_length () - leftext - ss/2; - - + Real w = bounds.length (); /* First try: just make the hyphen take 1/3 of the available space for length, use a geometric mean of the available space and some minimum */ if(l < w) l = sqrt(l*w); - Box b (Interval ( (w-l)/2, (w+l)/2), Interval (h,h+th)); - mol.add_molecule (sp->lookup_l ()->filledbox (b)); - mol.translate_axis(leftext, X_AXIS); + Box b (Interval (-l/2,l/2), Interval (h,h+th)); + Molecule mol (sp->lookup_l ()->filledbox (b)); + mol.translate_axis (bounds.center () + -sp->relative_coordinate (common, X_AXIS), + X_AXIS); return mol.create_scheme (); } void -Hyphen_spanner::set_textitem (Direction d, Item* textitem_l) +Hyphen_spanner::set_textitem (Direction d, Score_element* b) { - elt_l_->set_bound (d, textitem_l); - elt_l_->add_dependency (textitem_l); + elt_l_->set_bound (d, b); + elt_l_->add_dependency (b); } Hyphen_spanner::Hyphen_spanner (Spanner*s)