]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/volta-engraver.cc
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / volta-engraver.cc
index 91d0f87bf1a1baa7119fee399296edd5dc5da639..604c53c573493721796b068f66db084b4ae0c5ba 100644 (file)
@@ -3,21 +3,27 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2007 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 "item.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 +31,15 @@ public:
   TRANSLATOR_DECLARATIONS (Volta_engraver);
 protected:
 
-  virtual void acknowledge_grob (Grob_info);
+  DECLARE_END_ACKNOWLEDGER (staff_symbol);
+  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 +50,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 +77,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;
@@ -124,7 +141,7 @@ Volta_engraver::process_music ()
 
   if (end && !volta_span_)
     /* fixme: be more verbose.  */
-    warning (_ ("can't end volta spanner"));
+    warning (_ ("cannot end volta spanner"));
   else if (end)
     {
       end_volta_span_ = volta_span_;
@@ -148,7 +165,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,36 +176,42 @@ 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_end_staff_symbol (Grob_info i)
+{
+  if (i.grob ()->self_scm () == staff_)
+    staff_ = SCM_EOL;
+}
+
+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
 Volta_engraver::finalize ()
 {
@@ -230,11 +253,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_END_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",
+               /* read */ "repeatCommands voltaSpannerDuration stavesFound",
                /* write */ "");