]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/axis-group-engraver.cc (acknowledge_grob): also take
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 5 Feb 2004 14:12:38 +0000 (14:12 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 5 Feb 2004 14:12:38 +0000 (14:12 +0000)
lyric-interface; this prevents lines with only extender lines from
being junked.

* scm/define-grob-interfaces.scm (lyric-interface): new interface

* lily/lyric-extender.cc (brew_molecule): get line breaking and
extenders right, for once and for all (hopefully).

* lily/break-substitution.cc (substitute_one_mutable_property):
clear old 'all-elements for System grobs.

15 files changed:
ChangeLog
input/regression/lyric-extender-broken.ly
lily/axis-group-engraver.cc
lily/break-substitution.cc
lily/cluster.cc
lily/grob-property.cc
lily/grob.cc
lily/include/lyric-extender.hh
lily/include/spanner.hh
lily/lyric-extender.cc
lily/spanner.cc
lily/system.cc
ly/english.ly
scm/define-grob-interfaces.scm
scm/define-grobs.scm

index 9320bdcd618912b1c142c25769bfb42595ad89a8..1bc89e70aa6af180e15119a1d7f0fdb0deaea0b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2004-02-05  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/axis-group-engraver.cc (acknowledge_grob): also take
+       lyric-interface; this prevents lines with only extender lines from
+       being junked.
+       * scm/define-grob-interfaces.scm (lyric-interface): new interface
+
+       * lily/lyric-extender.cc (brew_molecule): get line breaking and
+       extenders right, for once and for all (hopefully).
+       
+       * lily/break-substitution.cc (substitute_one_mutable_property):
+       clear old 'all-elements for System grobs.
+
        * lily/new-lyric-combine-music-iterator.cc (find_voice): make sure
        that associatedVoiceContext is always assigned when music & lyrics
        are found. 
index 392d5945fe254937b61cde6142805814fd0891b2..e9ec0cd28dbd7f3f2cbdbbe0de6765acfec6bd12 100644 (file)
@@ -1,27 +1,23 @@
-\version "2.1.10"
-\header{
-    texidoc =
+\version "2.1.19"
+\header
+{
 
-    "Extenders that end a staff should not extend past the staff."
+    texidoc = "Lyric extenders run to the end of the line if it
+continues the next line. Otherwise, it should run to the last note
+of the melisma."
 
 }
 
-sopran = \notes \relative c'' {
-\time 3/4 a2.( | \break
- g2) g4
-}
-
-text = \lyrics {
-Aaaaa __ aaaaaah
-}
-
 \score {
-<<
-    
-  \context Voice = "foo" \sopran
-  \context LyricsVoice \lyricsto foo \text
->>
-\paper { linewidth = 5.0\cm
-}
+    << 
+       \context Voice=A \notes {
+           a1 ( a1 \break
+           a) a2( b) \break
+           a2 
+       }
+       \lyricsto A \context LyricsVoice \lyrics { a __ a __ ha }
+    >>
+    \paper {
+       raggedright = ##t
+    }
 }
-
index dfc19dae20a92cf1b62e143213277ee7cacceb69..135409d50949d13121a29429f9a1c2fd406f491c 100644 (file)
@@ -178,7 +178,9 @@ void
 Hara_kiri_engraver::acknowledge_grob (Grob_info i)
 {
   Axis_group_engraver::acknowledge_grob (i);
-  if (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
+  if (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface"))
+      || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface"))
+      )
     {
       Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_);
     }
index d9a766ff9f0a06cca985910b087f6fc171adfd8d..8544305d2f47795f3cdd24f03016df1fe3fc93df 100644 (file)
@@ -57,15 +57,6 @@ substitute_grob (Grob *sc)
        a huge recursion in the GC routine.
        */
 
-      /*
-       This was introduced in 1.3.49 as a measure to prevent
-       programming errors. It looks rather expensive (?).
-
-       TODO:
-               
-       benchmark , document when (what kind of programming
-       errors) this happens.
-      */
       if (sc->common_refpoint (line, X_AXIS)
          && sc->common_refpoint (line, Y_AXIS))
        {
@@ -442,6 +433,12 @@ Spanner::fast_fubstitute_grob_list (SCM sym,
       }
 #endif
 
+      /*
+       see below.
+       */
+      if (sym == ly_symbol2scm ("all-elements"))
+       sc->set_grob_property ("all-elements", SCM_EOL);
+
       sc->mutable_property_alist_ = scm_acons (sym, newval,
                                               sc->mutable_property_alist_);
     }
@@ -512,8 +509,23 @@ Spanner::substitute_one_mutable_property (SCM sym,
 
        SCM newval = (type == grob_list_p)
          ? substitute_grob_list (val)
-         : do_break_substitution(val);
+         : do_break_substitution (val);
 
+       /*
+         For the substitution of a single property, we tack the result onto
+         mutable_property_alist_ ; mutable_property_alist_ is empty after
+         Grob::Grob (Grob const&), except that System has all-elements set,
+         as a side product of typeset_grob() on newly copied spanners.
+
+         Here we clear that list explicitly to free some memory and
+         counter some of the confusion I encountered while debugging
+         another problem
+
+         (hwn 4/2/04)
+       */
+       if (sym == ly_symbol2scm ("all-elements"))
+         sc->set_grob_property ("all-elements", SCM_EOL);
+       
        sc->mutable_property_alist_ = scm_cons (scm_cons (sym, newval),
                                                sc->mutable_property_alist_);
       }
index 9c1bf995fb07407ba02ab043fdeca7a6d9bd3a9f..cd2fa2d8ebb557bdeb582265f5aefd5d52d359d4 100644 (file)
@@ -188,9 +188,9 @@ Cluster::brew_molecule (SCM smob)
     {
       Spanner *orig = dynamic_cast<Spanner*> (spanner->original_);
       
-      if (spanner->break_index_ < orig->broken_intos_.size()-1)
+      if (spanner->get_break_index () < orig->broken_intos_.size()-1)
        {
-         Spanner * next = orig->broken_intos_[spanner->break_index_+1];
+         Spanner * next = orig->broken_intos_[spanner->get_break_index () + 1];
          SCM cols = next->get_grob_property ("columns");
          if (gh_pair_p (cols))
            {
index a24ee01cd95bfc9c8b91bbcf819d1e2c6da91062..8c0350e83a195784d3bae495fa3437d4170f7351 100644 (file)
@@ -97,6 +97,7 @@ Grob::internal_get_grob_property (SCM sym) const
       if (!type_check_assignment (sym, gh_cdr (s),
                                  ly_symbol2scm ("backend-type?")))
        abort ();
+
       check_interfaces_for_property (this, sym);
     }
 
@@ -106,7 +107,7 @@ Grob::internal_get_grob_property (SCM sym) const
 void
 Grob::substitute_mutable_properties (SCM crit, SCM orig)
 {
-  set_break_subsititution(crit);
+  set_break_subsititution (crit);
   mutable_property_alist_ = substitute_mutable_property_alist (orig);
 }
 
index 00a1aa24383c50827603d8f47a2799736b79b94d..aee85bcb0cbfd4cad5ef0b0bae4e510489ad3f3f 100644 (file)
@@ -125,7 +125,6 @@ Grob::Grob (Grob const&s)
   self_scm_ = SCM_EOL;
 
   immutable_property_alist_ = s.immutable_property_alist_;
-
   mutable_property_alist_ = SCM_EOL;
   
   /*
@@ -150,9 +149,6 @@ Grob::~Grob ()
 }
 
 
-
-
-
 MAKE_SCHEME_CALLBACK (Grob,molecule_extent,2);
 SCM
 Grob::molecule_extent (SCM element_smob, SCM scm_axis)
@@ -325,12 +321,16 @@ Grob::handle_broken_dependencies ()
 
   if (sp)
     {
+      /*
+       This is the original spanner. We use a special function
+       because some Spanners have enormously long lists in their
+       properties.
+       */
       for (SCM s = mutable_property_alist_; gh_pair_p(s);
           s = gh_cdr(s))
        {
          sp->substitute_one_mutable_property (gh_caar (s),
                                              gh_cdar (s));
-         
        }
     }
 
index b07ceeec5b6cd8da08b973d8aa40c8b2c85fffaa..fab137a1d55a0b465e7e2ee191137d6ce975b407 100644 (file)
@@ -28,6 +28,7 @@
 class Lyric_extender
 {
 public:
+  static bool is_visible (Grob*);
   static bool has_interface (Grob*);
   DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM ));
 };
index 4afd77cfadea6773d7cd7a12ae8a760edc9b7de4..37f6ad33936f8faef6209071e35b0ddc22c6ffec 100644 (file)
   */
 class Spanner : public  Grob {
   Drul_array<Item*> spanned_drul_;
+  int break_index_;
   
 public:
   DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
   
   Link_array<Spanner> broken_intos_;
 
-  int break_index_;
+  int get_break_index () const;
   // todo: move to somewhere else.
   Real get_broken_left_end_align () const;
   void substitute_one_mutable_property (SCM sym, SCM val)  ;
index 441d7ea602f2cb6fef4bb19481455e2d4327fa65..d875a3e326ac6924586d2269b454e8e8ba4b5183 100644 (file)
 #include "note-head.hh"
 #include "group-interface.hh"
 
+
+bool
+Lyric_extender::is_visible (Grob *gr)
+{
+  Spanner*me = dynamic_cast<Spanner*> (gr);
+
+  SCM heads = me->get_grob_property ("heads");
+  int l = scm_ilength (heads);
+  if (l == 0)
+    return false;
+  
+  return true;
+}
+
 MAKE_SCHEME_CALLBACK (Lyric_extender,brew_molecule,1)
 SCM 
 Lyric_extender::brew_molecule (SCM smob) 
@@ -56,18 +70,33 @@ Lyric_extender::brew_molecule (SCM smob)
   Real right_point
     = left_point + (robust_scm2double  (minlen,0));
 
-  if (r->break_status_dir ())
-    right_point = infinity_f;
-  else
+  Spanner *orig = dynamic_cast<Spanner*> (me->original_);
+  bool last_line = orig
+    && (me->get_break_index () == orig->broken_intos_.size() - 2)
+    && !Lyric_extender::is_visible (orig->broken_intos_.top ());
+    
+
+  if (heads.size ())
     right_point = right_point >? heads.top ()->extent (common, X_AXIS)[RIGHT];
-  
+
   Real h = sl * robust_scm2double (me->get_grob_property ("thickness"), 0);
   Real pad = 2* h;
-  right_point = right_point <? (r->extent (common, X_AXIS)[LEFT] - pad);
 
-  if (isinf (right_point))
-    return SCM_EOL;
+  if (!r->break_status_dir ())
+    right_point = right_point <? (r->extent (common, X_AXIS)[LEFT] - pad);
+  else if (!last_line)
+    {
+      /*
+       run to end of line.
+       */
+      right_point = right_point >? (r->extent (common, X_AXIS)[LEFT] - pad);
+    }
   
+  if (isinf (right_point))
+    {
+      programming_error ("Right point of extender not defined?");
+      right_point = r->relative_coordinate (common, X_AXIS);
+    }  
 
   left_point += pad;
 
index a126483203df0a264549ddcdf76b4e4aa4f2eb94..6405aefd5d8dfe3596a5645c75033ef6ce1e084d 100644 (file)
@@ -123,6 +123,12 @@ Spanner::do_break_processing ()
     broken_intos_[i]->break_index_ = i;
 }
 
+int
+Spanner::get_break_index ()const
+{
+  return break_index_;
+}
+
 void
 Spanner::set_my_columns ()
 {
@@ -202,9 +208,8 @@ Spanner::Spanner (SCM s)
   break_index_ = 0;
   spanned_drul_[LEFT]=0;
   spanned_drul_[RIGHT]=0;
+
   Group_interface::add_thing (this, ly_symbol2scm ("interfaces"), ly_symbol2scm ("spanner-interface"));
-                    
-  
 }
 
 Spanner::Spanner (Spanner const &s)
index 8c9ad1ff16e89dda86b39ba019fb5a5833f4ad3d..b91e9065e0fb72368fe406d09c89958d3dfd970c 100644 (file)
@@ -114,7 +114,7 @@ System::typeset_grob (Grob * elem)
     programming_error ("Adding element twice.");
   
   elem->pscore_ = pscore_;
-  Pointer_group_interface::add_grob (this, ly_symbol2scm ("all-elements"),elem);
+  Pointer_group_interface::add_grob (this, ly_symbol2scm ("all-elements"), elem);
   scm_gc_unprotect_object (elem->self_scm ());
 }
 
index 68449064248e4031641dd3160fbbf4f304a425c9..68dd5d07c4cebc4a401d61400da37fda6d2c4fc1 100644 (file)
@@ -85,7 +85,7 @@ pitchnamesEnglish = #`(
        (bx . ,(ly:make-pitch -1 6 DOUBLE-SHARP))
 )
 
-pitchnames = pitchnamesEnglish
+pitchnames = \pitchnamesEnglish
 
 \version "2.1.19"
 
index fbf6f2a2eb008ccff892e2bafcedfc57170d2a08..12ecacfe063f21ebc0cc76bb190367926e0ac127 100644 (file)
@@ -47,6 +47,11 @@ extents of a cluster spanner at this X position.
  "a single piece of lyrics"
  '())
 
+(ly:add-interface
+ 'lyric-interface
+ "Any object that is related to lyrics."
+ '())
+
 (ly:add-interface
  'mark-interface
  "a rehearsal mark"
index 4889b0d8766a4626ecd6ccdcbc0087c5e7946f8d..95d8bb545d12cea4305bf04b32f7a67d543c2be4 100644 (file)
        (minimum-length .  0.5) 
        (molecule-callback . ,Hyphen_spanner::brew_molecule)
        (Y-extent-callback . ,Grob::point_dimension_callback)
-       (meta . ((interfaces . (lyric-hyphen-interface spanner-interface))))
+       (meta . ((interfaces . (lyric-interface lyric-hyphen-interface
+                                               spanner-interface))))
        ))
 
     (LyricExtender
        (thickness . 0.8) ; linethickness
        (minimum-length . 1.5)
        (Y-extent-callback . ,Grob::point_dimension_callback)
-       (meta . ((interfaces . (lyric-extender-interface spanner-interface))))
+       (meta . ((interfaces . (lyric-interface
+                               lyric-extender-interface spanner-interface))))
        ))
 
     (LyricText