]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/percent-repeat-engraver.cc
* lily/note-column.cc: reformat.
[lilypond.git] / lily / percent-repeat-engraver.cc
index e76bbaeb086c017c8c7b13ac8da8477e70e029ea..a27eef826b9163f94168cec7e6ea92d630adc49e 100644 (file)
@@ -14,6 +14,7 @@
 #include "international.hh"
 #include "item.hh"
 #include "misc.hh"
+#include "percent-repeat-iterator.hh"
 #include "repeated-music.hh"
 #include "side-position-interface.hh"
 #include "spanner.hh"
@@ -51,10 +52,6 @@ protected:
   Spanner *percent_;
   Spanner *percent_counter_;
 
-  
-  Grob *first_command_column_;
-  Moment command_moment_;
-  
 protected:
   virtual void finalize ();
   DECLARE_TRANSLATOR_LISTENER (percent);
@@ -68,28 +65,8 @@ Percent_repeat_engraver::Percent_repeat_engraver ()
 {
   percent_ = 0;
   percent_counter_ = 0;
-  percent_event_ = 0;
-
-  first_command_column_ = 0;
-  command_moment_ = Moment (-1);
-}
-
-void
-Percent_repeat_engraver::start_translation_timestep ()
-{
-  if (now_mom ().main_part_ != command_moment_.main_part_)
-    {
-      first_command_column_ = unsmob_grob (get_property ("currentCommandColumn"));
-      command_moment_ = now_mom ();
-    }
 
-  if (stop_mom_.main_part_ == now_mom ().main_part_)
-    {
-      if (percent_)
-       typeset_perc ();
-      percent_event_ = 0;
-      repeat_sign_type_ = UNKNOWN;
-    }
+  percent_event_ = 0;
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Percent_repeat_engraver, percent);
@@ -101,34 +78,26 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev)
       Moment body_length = get_event_length (ev);
       Moment meas_len (robust_scm2moment (get_property ("measureLength"),
                                          Moment (1)));
+
       if (meas_len == body_length)
-       {
-         repeat_sign_type_ = MEASURE;
-         start_mom_ = now_mom ();
-         stop_mom_ = now_mom () + body_length;
-         get_global_context ()->add_moment_to_process (stop_mom_);
-       }
+      {
+       repeat_sign_type_ = MEASURE;
+       start_mom_ = now_mom ();
+       stop_mom_ = now_mom () + body_length;
+       get_global_context ()->add_moment_to_process (stop_mom_);
+      }
       else if (Moment (2) * meas_len == body_length)
-       {
-         repeat_sign_type_ = DOUBLE_MEASURE;
-         start_mom_ = now_mom () + meas_len;
-         stop_mom_ = now_mom () + body_length; /* never used */
-         get_global_context ()->add_moment_to_process (start_mom_);
-       }
+      {
+       repeat_sign_type_ = DOUBLE_MEASURE;
+       start_mom_ = now_mom () + meas_len;
+       stop_mom_ = now_mom () + body_length; /* never used */
+       get_global_context ()->add_moment_to_process (start_mom_);
+      }
       else
-       {
-         /*
-           don't warn about percent repeats: slash repeats are not
-           exactly 1 or 2 measures long.
-          */
-         return;
-       }
+       return;
+
       percent_event_ = ev;
     }
-  else
-    /* print a warning: no assignment happens because
-       percent_event_ != 0 */
-    ASSIGN_EVENT_ONCE (percent_event_, ev);
 }
 
 void
@@ -140,10 +109,9 @@ Percent_repeat_engraver::process_music ()
        {
          if (percent_)
            typeset_perc ();
-         
          percent_ = make_spanner ("PercentRepeat", percent_event_->self_scm ());
 
-         Grob *col = first_command_column_;
+         Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
          percent_->set_bound (LEFT, col);
 
          SCM count = percent_event_->get_property ("repeat-count");
@@ -208,7 +176,7 @@ Percent_repeat_engraver::typeset_perc ()
 {
   if (percent_)
     {
-      Grob *col = first_command_column_;
+      Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
 
       percent_->set_bound (RIGHT, col);
       percent_ = 0;
@@ -219,7 +187,17 @@ Percent_repeat_engraver::typeset_perc ()
     }
 }
 
-
+void
+Percent_repeat_engraver::start_translation_timestep ()
+{
+  if (stop_mom_.main_part_ == now_mom ().main_part_)
+    {
+      if (percent_)
+       typeset_perc ();
+      percent_event_ = 0;
+      repeat_sign_type_ = UNKNOWN;
+    }
+}
 
 void
 Percent_repeat_engraver::stop_translation_timestep ()