]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slash-repeat-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / slash-repeat-engraver.cc
index 16d5c4ba5f89558d6c2f4321bf3968f38662521f..aa5b52c405ccc72ec952aa9fed23a580711b59fd 100644 (file)
@@ -3,22 +3,18 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>, Erik Sandberg
-  <mandolaerik@gmail.com>
+  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>, Erik Sandberg <mandolaerik@gmail.com>
 */
 
-#include "bar-line.hh"
+#include "repeated-music.hh"
 #include "global-context.hh"
-#include "international.hh"
-#include "item.hh"
+#include "warn.hh"
 #include "misc.hh"
-#include "repeated-music.hh"
-#include "score-engraver.hh"
 #include "spanner.hh"
-#include "stream-event.hh"
-#include "warn.hh"
-
-#include "translator.icc"
+#include "item.hh"
+#include "percent-repeat-iterator.hh"
+#include "bar-line.hh"
+#include "score-engraver.hh"
 
 /**
    This acknowledges repeated music with "percent" style.  It typesets
@@ -29,9 +25,9 @@ class Slash_repeat_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
 protected:
-  Stream_event *slash_;
+  Music *slash_;
 protected:
-  DECLARE_TRANSLATOR_LISTENER (percent);
+  virtual bool try_music (Music *);
   void process_music ();
 };
 
@@ -40,21 +36,24 @@ Slash_repeat_engraver::Slash_repeat_engraver ()
   slash_ = 0;
 }
 
-IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, percent);
-void
-Slash_repeat_engraver::listen_percent (Stream_event *ev)
+bool
+Slash_repeat_engraver::try_music (Music *m)
 {
   /*todo: separate events for percent and slash */
-  Moment meas_length
-    = robust_scm2moment (get_property ("measureLength"), Moment (0));
-  
-  if (get_event_length (ev) < meas_length)
-    ASSIGN_EVENT_ONCE (slash_, ev);
+  if (m->is_mus_type ("percent-event"))
+    {
+      Moment meas_length
+        = robust_scm2moment (get_property ("measureLength"), Moment (0));
+
+      if (m->get_length () < meas_length)
+       slash_ = m;
+      else
+       return false;
 
-  /*
-    don't warn if nothing happens: this can happen if there are whole
-    measure repeats.
-   */
+      return true;
+    }
+
+  return false;
 }
 
 void
@@ -67,6 +66,8 @@ Slash_repeat_engraver::process_music ()
     }
 }
 
+#include "translator.icc"
+
 ADD_TRANSLATOR (Slash_repeat_engraver,
                /* doc */ "Make beat repeats.",
                /* create */ "RepeatSlash",