]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-arpeggio-engraver.cc
Run grand replace for 2015.
[lilypond.git] / lily / span-arpeggio-engraver.cc
index 121b50d97c4a6a02699818a2d0a05313d266dc6d..e81dcfe258235f2842b73c92b4072d57d24680f2 100644 (file)
@@ -1,59 +1,73 @@
 /*
-  span-arpeggio-engraver.cc -- implement Span_arpeggio_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
-
-  (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 2000--2015 Jan Nieuwenhuizen <janneke@gnu.org>
 
   Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "engraver.hh"
-#include "lily-guile.hh"
-#include "item.hh"
 #include "arpeggio.hh"
-#include "group-interface.hh"
+#include "item.hh"
+#include "pointer-group-interface.hh"
+#include "separation-item.hh"
 #include "side-position-interface.hh"
 #include "staff-symbol-referencer.hh"
 
-
-/** 
-  Make arpeggios that span multiple staves.  Catch arpeggios, and span a
-  Span_arpeggio over them if we find more than two arpeggios.
-  */
+/**
+   Make arpeggios that span multiple staves.  Catch arpeggios, and span a
+   Span_arpeggio over them if we find more than two arpeggios.
+*/
 class Span_arpeggio_engraver : public Engraver
 {
 public:
-  TRANSLATOR_DECLARATIONS(Span_arpeggio_engraver);
-  
+  TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
+  DECLARE_ACKNOWLEDGER (arpeggio);
+  DECLARE_ACKNOWLEDGER (note_column);
+
 protected:
-  virtual void acknowledge_grob (Grob_info);
-  virtual void process_acknowledged_grobs ();
-  virtual void stop_translation_timestep ();
+  void process_acknowledged ();
+  void stop_translation_timestep ();
 
 private:
   Item *span_arpeggio_;
-  Link_array<Grob> arpeggios_;
+  vector<Grob *> arpeggios_;
+  vector<Grob *> note_columns_;
 };
 
-
 Span_arpeggio_engraver::Span_arpeggio_engraver ()
 {
   span_arpeggio_ = 0;
 }
 
 void
-Span_arpeggio_engraver::acknowledge_grob (Grob_info info)
+Span_arpeggio_engraver::acknowledge_arpeggio (Grob_info info)
 {
-    if (info.origin_transes (this).size ()
-        && Arpeggio::has_interface (info.grob_))
-    {
-      arpeggios_.push (info.grob_);
-    }
+  if (info.origin_contexts (this).size ()) // huh? what's this test for?
+    arpeggios_.push_back (info.grob ());
+}
+
+void
+Span_arpeggio_engraver::acknowledge_note_column (Grob_info info)
+{
+  note_columns_.push_back (info.grob ());
 }
 
 void
-Span_arpeggio_engraver::process_acknowledged_grobs ()
+Span_arpeggio_engraver::process_acknowledged ()
 {
   /*
     connectArpeggios is slightly brusque; we should really read a grob
@@ -64,49 +78,65 @@ Span_arpeggio_engraver::process_acknowledged_grobs ()
   */
   if (!span_arpeggio_ && arpeggios_.size () > 1
       && to_boolean (get_property ("connectArpeggios")))
+    span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
+
+  if (span_arpeggio_)
     {
-      span_arpeggio_ = make_item ("Arpeggio");
-      announce_grob(span_arpeggio_, SCM_EOL);      
+      for (vsize i = 0; i < note_columns_.size (); i++)
+        Separation_item::add_conditional_item (note_columns_[i], span_arpeggio_);
+      note_columns_.clear ();
     }
 }
 
 void
 Span_arpeggio_engraver::stop_translation_timestep ()
 {
-  if (span_arpeggio_) 
+  if (span_arpeggio_)
     {
       /*
-       we do this very late, to make sure we also catch `extra'
-       side-pos support like accidentals.
-       */
-      for (int i=0; i < arpeggios_.size (); i ++)
-       {
-         for (SCM s = arpeggios_[i]->get_grob_property ("stems");
-              gh_pair_p (s); s = ly_cdr (s))
-           Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("stems"), ly_car (s));
-         for (SCM s = arpeggios_[i]->get_grob_property ("side-support-elements");
-              gh_pair_p (s); s = ly_cdr (s))
-           Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("side-support-elements"), ly_car (s));
-
-         /*
-           we can't kill the children, since we don't want to the
-           previous note to bump into the span arpeggio; so we make
-           it transparent.  */
-         arpeggios_[i]->set_grob_property ("molecule-callback", SCM_EOL);
-       }
-      
-      typeset_grob (span_arpeggio_);
+        we do this very late, to make sure we also catch `extra'
+        side-pos support like accidentals.
+      */
+      for (vsize j = 0; j < arpeggios_.size (); j++)
+        {
+          extract_grob_set (arpeggios_[j], "stems", stems);
+          for (vsize i = 0; i < stems.size (); i++)
+            Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"),
+                                               stems[i]);
+
+          extract_grob_set (arpeggios_[j], "side-support-elements", sses);
+          for (vsize i = 0; i < sses.size (); i++)
+            Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"),
+                                               sses[i]);
+
+          /*
+            we can't kill the children, since we don't want to the
+            previous note to bump into the span arpeggio; so we make
+            it transparent.  */
+          arpeggios_[j]->set_property ("transparent", SCM_BOOL_T);
+        }
+
+      span_arpeggio_->set_parent (arpeggios_[0]->get_parent (Y_AXIS), Y_AXIS);
       span_arpeggio_ = 0;
     }
   arpeggios_.clear ();
+  note_columns_.clear ();
 }
 
+#include "translator.icc"
+
+ADD_ACKNOWLEDGER (Span_arpeggio_engraver, arpeggio);
+ADD_ACKNOWLEDGER (Span_arpeggio_engraver, note_column);
+ADD_TRANSLATOR (Span_arpeggio_engraver,
+                /* doc */
+                "Make arpeggios that span multiple staves.",
+
+                /* create */
+                "Arpeggio ",
 
+                /* read */
+                "connectArpeggios ",
 
-ENTER_DESCRIPTION(Span_arpeggio_engraver,
-/* descr */       "",
-/* creats*/       "Arpeggio",
-/* accepts */     "",
-/* acks  */      "arpeggio-interface",
-/* reads */       "connectArpeggios",
-/* write */       "");
+                /* write */
+                ""
+               );