]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/volta-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / volta-engraver.cc
index 03e940650d32e43ac20ee09c4758b4a255b9e60b..fefc68e7f3ef460887c5cb7aa21e2fa0e083ae32 100644 (file)
@@ -3,21 +3,26 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "engraver.hh"
+
+#include "bar-line.hh"
 #include "context.hh"
-#include "volta-bracket.hh"
+#include "international.hh"
 #include "note-column.hh"
-#include "bar-line.hh"
 #include "side-position-interface.hh"
-#include "warn.hh"
 #include "staff-symbol.hh"
+#include "text-interface.hh"
+#include "volta-bracket.hh"
+#include "warn.hh"
+
+#include "translator.icc"
 
 /*
   Create Volta spanners, by reading repeatCommands  property, usually
-  set by Unfolded_repeat_iterator.
+  set by Volta_repeat_iterator.
 */
 class Volta_engraver : public Engraver
 {
@@ -25,10 +30,14 @@ public:
   TRANSLATOR_DECLARATIONS (Volta_engraver);
 protected:
 
-  virtual void acknowledge_grob (Grob_info);
+  DECLARE_ACKNOWLEDGER (staff_symbol);
+  DECLARE_ACKNOWLEDGER (note_column);
+  DECLARE_ACKNOWLEDGER (bar_line);
+
   virtual void finalize ();
-  virtual void stop_translation_timestep ();
-  virtual void process_music ();
+  virtual void derived_mark () const;
+  void stop_translation_timestep ();
+  void process_music ();
 
   Moment started_mom_;
   Spanner *volta_span_;
@@ -39,9 +48,17 @@ protected:
   bool staff_eligible ();
 };
 
+void
+Volta_engraver::derived_mark () const
+{
+  scm_gc_mark (staff_);
+  scm_gc_mark (start_string_);
+}
+
 Volta_engraver::Volta_engraver ()
 {
   staff_ = SCM_EOL;
+  start_string_ = SCM_EOL;
   volta_span_ = 0;
   end_volta_span_ = 0;
 }
@@ -58,9 +75,7 @@ Volta_engraver::staff_eligible ()
 {
   SCM doit = get_property ("voltaOnThisStaff");
   if (scm_is_bool (doit))
-    {
-      return to_boolean (doit);
-    }
+    return to_boolean (doit);
 
   if (!unsmob_grob (staff_))
     return false;
@@ -148,7 +163,7 @@ Volta_engraver::process_music ()
     }
 
   if (!volta_span_
-      && (scm_is_string (start_string_) || scm_is_pair (start_string_)))
+      && Text_interface::is_markup (start_string_))
     {
       started_mom_ = now_mom ();
 
@@ -159,34 +174,32 @@ Volta_engraver::process_music ()
 }
 
 void
-Volta_engraver::acknowledge_grob (Grob_info i)
+Volta_engraver::acknowledge_note_column (Grob_info i)
 {
-  if (Item *item = dynamic_cast<Item *> (i.grob ()))
-    {
-      if (Note_column::has_interface (item))
-       {
-         if (volta_span_)
-           Volta_bracket_interface::add_column (volta_span_, item);
-       }
-      if (Bar_line::has_interface (item))
-       {
-         if (volta_span_)
-           Volta_bracket_interface::add_bar (volta_span_, item);
-         if (end_volta_span_)
-           Volta_bracket_interface::add_bar (end_volta_span_, item);
-       }
-    }
-  else if (Staff_symbol::has_interface (i.grob ()))
-    {
-      /*
-       We only want to know about a single staff: then we add to the
-       support.  */
-      if (staff_ != SCM_EOL)
-       staff_ = SCM_UNDEFINED;
+  if (volta_span_)
+    Volta_bracket_interface::add_column (volta_span_, i.grob ());
+}
 
-      if (staff_ != SCM_UNDEFINED)
-       staff_ = i.grob ()->self_scm ();
-    }
+void
+Volta_engraver::acknowledge_bar_line (Grob_info i)
+{
+  if (volta_span_)
+    Volta_bracket_interface::add_bar (volta_span_, i.item ());
+  if (end_volta_span_)
+    Volta_bracket_interface::add_bar (end_volta_span_, i.item ());
+}
+
+void
+Volta_engraver::acknowledge_staff_symbol (Grob_info i)
+{
+  /*
+    We only want to know about a single staff: then we add to the
+    support.  */
+  if (staff_ != SCM_EOL)
+    staff_ = SCM_UNDEFINED;
+
+  if (staff_ != SCM_UNDEFINED)
+    staff_ = i.grob ()->self_scm ();
 }
 
 void
@@ -230,11 +243,12 @@ Volta_engraver::stop_translation_timestep ()
 /*
   TODO: should attach volta to paper-column if no bar is found.
 */
-
+ADD_ACKNOWLEDGER (Volta_engraver, staff_symbol);
+ADD_ACKNOWLEDGER (Volta_engraver, note_column);
+ADD_ACKNOWLEDGER (Volta_engraver, bar_line);
 ADD_TRANSLATOR (Volta_engraver,
-               /* descr */ "Make volta brackets.",
-               /* creats*/ "VoltaBracket",
-               /* accepts */ "",
-               /* acks  */ "bar-line-interface staff-symbol-interface note-column-interface",
-               /* reads */ "repeatCommands voltaSpannerDuration stavesFound",
+               /* doc */ "Make volta brackets.",
+               /* create */ "VoltaBracket",
+               /* accept */ "",
+               /* read */ "repeatCommands voltaSpannerDuration stavesFound",
                /* write */ "");