]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/hyphen-spanner.cc (set_spacing_rods): new function: take
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Jul 2003 15:20:44 +0000 (15:20 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Jul 2003 15:20:44 +0000 (15:20 +0000)
syllables widths into account for minimum-length.

* scm/define-grobs.scm (all-grob-descriptions): default to ramp.

ChangeLog
lily/hyphen-spanner.cc
lily/include/hyphen-spanner.hh
scm/define-grobs.scm

index 5a53f5dd0ba4fde417c729473c1d67e09eb51f72..122f5e9417e4b653a2cc662694b750a030763997 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-07-17  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * 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
index 09986ee206890d3e3a30753f8e2aa33a539b56d5..2d582818feb06e430af59f5aae05e6da046bf2c6 100644 (file)
 #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<Spanner*> (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.
index 8d7243f3a021746375fa86535e9792c661d64bf3..68c3e1636081f456c4756dd4e5059b4a2ec8de80 100644 (file)
@@ -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*);
index 08a37a0f7778e3a2b163348feb46fed7c7cd7071..066d83637870f5d14558211a026148ebe944b746 100644 (file)
        (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))))