]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/percent-repeat-engraver.cc
*** empty log message ***
[lilypond.git] / lily / percent-repeat-engraver.cc
index e5da150a4487a2142af48102ae14d7f50df0f188..521972ec315be8464af520c65dbfe8e3790062a2 100644 (file)
@@ -57,9 +57,9 @@ protected:
 protected:
   virtual void finalize ();
   virtual bool try_music (Music *);
-  virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
-  virtual void process_music ();
+  void stop_translation_timestep ();
+  void start_translation_timestep ();
+  void process_music ();
 };
 
 Percent_repeat_engraver::Percent_repeat_engraver ()
@@ -91,30 +91,30 @@ Percent_repeat_engraver::try_music (Music *m)
       if (meas_len == body_length_)
        repeat_sign_type_ = MEASURE;
       else if (Moment (2) * meas_len == body_length_)
-       {
-         repeat_sign_type_ = DOUBLE_MEASURE;
-         next_moment_ += meas_len;
-       }
+       repeat_sign_type_ = DOUBLE_MEASURE;
       else
        {
-         warning (_ ("Don't know how to handle a percent repeat of this length."));
+         warning (_f ("can't handle a percent repeat of length: %s",
+                      body_length_.to_string ()));
          return false;
        }
 
       repeat_ = m;
 
       Global_context *global = get_global_context ();
-      for (int i = 0; i < count; i++)
+      for (int i = 1; i < count; i++)
        {
-         global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
+         Moment m = next_moment_ + Moment (i) * body_length_;
+         global->add_moment_to_process (m);
 
-         /*
-           bars between % too.
-         */
+         /* bars between % too.  */
          if (repeat_sign_type_ == DOUBLE_MEASURE)
-           global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_);
+           global->add_moment_to_process (m - meas_len);
        }
 
+      if (repeat_sign_type_ == DOUBLE_MEASURE)
+       next_moment_ += meas_len;
+
       return true;
     }
 
@@ -137,15 +137,16 @@ Percent_repeat_engraver::process_music ()
       else if (repeat_sign_type_ == DOUBLE_MEASURE)
        {
          double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ());
+
          /*
            forbid breaks on a % line. Should forbid all breaks, really.
-         */
 
-         get_score_engraver ()->forbid_breaks ();      // guh. Use properties!      
+           Ugh. Why can't this be regular communication between
+           contexts?
+         */
+         get_score_engraver ()->forbid_breaks ();
        }
       next_moment_ = next_moment_ + body_length_;
-
-      get_global_context ()->add_moment_to_process (next_moment_);
     }
 }
 
@@ -195,10 +196,11 @@ Percent_repeat_engraver::stop_translation_timestep ()
   typeset_perc ();
 }
 
+#include "translator.icc"
+
 ADD_TRANSLATOR (Percent_repeat_engraver,
-               /* descr */ "Make whole bar and double bar repeats.",
-               /* creats*/ "PercentRepeat DoublePercentRepeat",
-               /* accepts */ "repeated-music",
-               /* acks  */ "",
-               /* reads */ "measureLength currentCommandColumn",
+               /* doc */ "Make whole bar and double bar repeats.",
+               /* create */ "PercentRepeat DoublePercentRepeat",
+               /* accept */ "repeated-music",
+               /* read */ "measureLength currentCommandColumn",
                /* write */ "");