]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 355: \repeat bar lines get messed up
authorDavid Kastrup <dak@gnu.org>
Sun, 3 Nov 2013 14:01:10 +0000 (15:01 +0100)
committerDavid Kastrup <dak@gnu.org>
Sun, 10 Nov 2013 14:59:15 +0000 (15:59 +0100)
% the second repeat should start at the beginning of a bar, not
% continue from the incomplete bar in the first ending.

\version "2.17.30"
\new Staff \relative {
  \partial 4
  \repeat volta 4 { e' | c2 d2 | e2 f2 | }
  \alternative { { g4 g g } { a a a a } }
  a b2.
}

lily/volta-repeat-iterator.cc
ly/engraver-init.ly
scm/define-context-properties.scm

index 2e386e6fd18bba885a63cd6e3c1426fe29db2e29..3e6f58efda470ed86866d0873282a51604cc6d03 100644 (file)
@@ -33,17 +33,26 @@ protected:
   virtual void next_element (bool);
   virtual void construct_children ();
   virtual void process (Moment);
+  virtual void derived_mark () const;
 
   bool first_time_;
   int alt_count_;
   int rep_count_;
   int done_count_;
+  SCM alt_restores_;
 };
 
 Volta_repeat_iterator::Volta_repeat_iterator ()
 {
   done_count_ = alt_count_ = rep_count_ = 0;
   first_time_ = true;
+  alt_restores_ = SCM_EOL;
+}
+
+void
+Volta_repeat_iterator::derived_mark () const
+{
+  scm_gc_mark (alt_restores_);
 }
 
 SCM
@@ -95,12 +104,41 @@ Volta_repeat_iterator::next_element (bool side_effect)
       if (alt_count_)
         {
           string repstr = to_string (rep_count_ - alt_count_ + done_count_) + ".";
-          if (done_count_ > 1)
+          if (done_count_ <= 1)
             {
+              alt_restores_ = SCM_EOL;
+              if (to_boolean (get_outlet ()->get_property ("timing")))
+                {
+                  for (SCM lst = get_outlet ()->get_property ("alternativeRestores");
+                       scm_is_pair (lst);
+                       lst = scm_cdr (lst))
+                    {
+                      SCM res = SCM_EOL;
+                      Context *t = get_outlet ()->where_defined (scm_car (lst),
+                                                                 &res);
+                      if (t)
+                        {
+                          alt_restores_ = scm_cons
+                            (scm_list_3 (t->self_scm (), scm_car (lst), res),
+                             alt_restores_);
+                        }
+                    }
+                }
+            }
+          else
+            {
+
               add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED));
 
               if (done_count_ - 1 < alt_count_)
                 add_repeat_command (ly_symbol2scm ("end-repeat"));
+
+              if (to_boolean (get_outlet ()->get_property ("timing")))
+                {
+                  for (SCM p = alt_restores_; scm_is_pair (p); p = scm_cdr (p))
+                    scm_apply_0 (ly_lily_module_constant ("ly:context-set-property!"),
+                                 scm_car (p));
+                }
             }
 
           if (done_count_ == 1 && alt_count_ < rep_count_)
index 9c8547dd7d024f8e6b0f6b07d9683e7ede62dd94..9ff53bed6c80b93734dabfb0c7cee0278b74cd43 100644 (file)
@@ -609,6 +609,7 @@ automatically when an output definition (a @code{\\score} or
   doubleRepeatType = #":..:"
   startRepeatType = #".|:"
   endRepeatType = #":|."
+  alternativeRestores = #'(measurePosition measureLength)
   barNumberVisibility = #first-bar-number-invisible-and-no-parenthesized-bar-numbers
   barNumberFormatter = #robust-bar-number-function
   clefTranspositionFormatter = #clef-transposition-markup
index 20d77ea72f5d100dbc5705f64b27a5023e74e057..073c71409743cc7737c27cf440a5f8619663ccc4 100644 (file)
@@ -60,6 +60,9 @@ vertical alignment.")
 numbers.  Can be @code{numbers} for going back to the same number or
 @code{numbers-with-letters} for going back to the same number with letter
 suffixes.  No setting will not go back in measure-number time.")
+     (alternativeRestores ,symbol-list? "Timing variables that are
+restored to their value at the end of the first alternative in
+subsequent alternatives.")
      (associatedVoice ,string? "Name of the @code{Voice} that has the
 melody for this @code{Lyrics} line.")
      (autoAccidentals ,list? "List of different ways to typeset an