From: hanwen Date: Thu, 17 Jul 2003 15:20:44 +0000 (+0000) Subject: * lily/hyphen-spanner.cc (set_spacing_rods): new function: take X-Git-Tag: release/1.7.25~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e56d6a1b8acfc3acffd8cb66a5dae2502ccc0058;p=lilypond.git * lily/hyphen-spanner.cc (set_spacing_rods): new function: take syllables widths into account for minimum-length. * scm/define-grobs.scm (all-grob-descriptions): default to ramp. --- diff --git a/ChangeLog b/ChangeLog index 5a53f5dd0b..122f5e9417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-07-17 Han-Wen Nienhuys + * lily/hyphen-spanner.cc (set_spacing_rods): new function: take + syllables widths into account for minimum-length. + * input/test/staff-container.ly: update file * input/test/stem.ly: remove diff --git a/lily/hyphen-spanner.cc b/lily/hyphen-spanner.cc index 09986ee206..2d582818fe 100644 --- a/lily/hyphen-spanner.cc +++ b/lily/hyphen-spanner.cc @@ -19,8 +19,28 @@ #include "spanner.hh" #include "item.hh" -MAKE_SCHEME_CALLBACK (Hyphen_spanner,brew_molecule,1) +MAKE_SCHEME_CALLBACK (Hyphen_spanner,set_spacing_rods,1); +SCM +Hyphen_spanner::set_spacing_rods (SCM smob) +{ + Grob*me = unsmob_grob (smob); + + Rod rod; + Spanner*sp = dynamic_cast (me); + Item * l = sp->get_bound (LEFT); + Item * r = sp->get_bound (RIGHT); + rod.item_l_drul_[LEFT] = l; + rod.item_l_drul_[RIGHT] =r; + rod.distance_ = + gh_scm2double (me->get_grob_property ("minimum-length")) + + l->extent (l, X_AXIS)[RIGHT] + - r->extent (r, X_AXIS)[LEFT]; + + rod.add_to_cols (); + return SCM_UNSPECIFIED; +} +MAKE_SCHEME_CALLBACK (Hyphen_spanner,brew_molecule,1) SCM Hyphen_spanner::brew_molecule (SCM smob) { @@ -50,15 +70,23 @@ Hyphen_spanner::brew_molecule (SCM smob) Real h = gh_scm2double (sp->get_grob_property ("height")); // interval? - Real l = gh_scm2double (sp->get_grob_property ("minimum-length")); Real x = gh_scm2double (sp->get_grob_property ("maximum-length")); - // The hyphen can exist in the word space of the left lyric ... SCM space = sp->get_bound (LEFT)->get_grob_property ("word-space"); + + Real word_space = 1.0; if (gh_number_p (space)) { - bounds[LEFT] -= gh_scm2double (space); + word_space = gh_scm2double (space); } + /* + We remove word space from the distance so it doesn't look like an extender. + + */ + Real l = (gh_scm2double (sp->get_grob_property ("minimum-length")) + - word_space ) >? word_space; + + /* we should probably do something more intelligent when bounds is empty, but at least this doesn't crash. diff --git a/lily/include/hyphen-spanner.hh b/lily/include/hyphen-spanner.hh index 8d7243f3a0..68c3e16360 100644 --- a/lily/include/hyphen-spanner.hh +++ b/lily/include/hyphen-spanner.hh @@ -13,6 +13,8 @@ struct Hyphen_spanner { public: Spanner* elt_; + + DECLARE_SCHEME_CALLBACK(set_spacing_rods, (SCM)); Hyphen_spanner (Spanner*); void set_textitem (Direction, Grob*); bool has_interface (Grob*); diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 08a37a0f77..066d836378 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -471,6 +471,7 @@ (height . 0.4) (minimum-length . 0.5) (maximum-length . 100) + (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) (molecule-callback . ,Hyphen_spanner::brew_molecule) (Y-extent-callback . ,Grob::point_dimension_callback) (meta . ((interfaces . (lyric-hyphen-interface spanner-interface))))