]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/arpeggio-engraver.cc
2003 -> 2004
[lilypond.git] / lily / arpeggio-engraver.cc
index f366159596ef19c4d2f19a20a489eb0b4c39fc73..cc61fb3b0f1461615345942d67caf2f9cac12961 100644 (file)
@@ -3,19 +3,18 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
  */
 
 #include "engraver.hh"
 #include "group-interface.hh"
 #include "item.hh"
-#include "musical-request.hh"
+#include "event.hh"
 #include "arpeggio.hh"
 #include "stem.hh"
-#include "local-key-item.hh"
 #include "rhythmic-head.hh"
 #include "side-position-interface.hh"
-#include "staff-symbol-referencer.hh"
+#include "note-column.hh"
 
 class Arpeggio_engraver : public Engraver
 {
@@ -23,15 +22,14 @@ public:
   TRANSLATOR_DECLARATIONS(Arpeggio_engraver); 
 protected:
   virtual void acknowledge_grob (Grob_info);
-  virtual void create_grobs ();
+  virtual void process_music ();
+
   virtual void stop_translation_timestep ();
   virtual bool try_music (Music *);
 
 private:
   Item* arpeggio_; 
-  Arpeggio_req *arpeggio_req_;
-  Link_array <Grob> stems_;
-  Link_array<Grob> supports_;
+  Music *arpeggio_req_;
 };
 
 Arpeggio_engraver::Arpeggio_engraver ()
@@ -45,53 +43,46 @@ Arpeggio_engraver::try_music (Music* m)
 {
   if (!arpeggio_req_)
     {
-      if (Arpeggio_req *a = dynamic_cast<Arpeggio_req*> (m))
-       {
-         arpeggio_req_ = a;
-         return true;
-       }
+      arpeggio_req_ = m;
     }
-  return false;
+  return true;
 }
 
 void
 Arpeggio_engraver::acknowledge_grob (Grob_info info)
 {
-  if (arpeggio_req_)
+  if (arpeggio_)
     {
-      if (Stem::has_interface (info.grob_l_))
+      if (Stem::has_interface (info.grob_))
        {
-         stems_.push (info.grob_l_);
+         if (!arpeggio_->get_parent  (Y_AXIS))
+           arpeggio_->set_parent (info.grob_, Y_AXIS);
+      
+         Pointer_group_interface::add_grob (arpeggio_, ly_symbol2scm ("stems"), info.grob_);
        }
       
       /*
        We can't catch local key items (accidentals) from Voice context,
        see Local_key_engraver
       */
-      else if (Rhythmic_head::has_interface (info.grob_l_))
+      else if (Rhythmic_head::has_interface (info.grob_))
+       {
+         Side_position_interface::add_support (arpeggio_, info.grob_);
+       }
+      else if (Note_column::has_interface (info.grob_ ))
        {
-         supports_.push (info.grob_l_);
+         info.grob_->set_grob_property ("arpeggio", arpeggio_->self_scm ());
        }
     }
 }
 
 void
-Arpeggio_engraver::create_grobs ()
+Arpeggio_engraver::process_music ()
 {
-  if (!arpeggio_ && !stems_.empty ())
+  if (arpeggio_req_)
     {
-      arpeggio_ = new Item (get_property ("Arpeggio"));
-      arpeggio_->set_parent (stems_[0], Y_AXIS);
-      
-      for (int i = 0; i < stems_.size (); i++)
-       {
-         Pointer_group_interface::add_element (arpeggio_, ly_symbol2scm ("stems"), stems_[i]);
-       }
-      for (int i = 0; i < supports_.size (); i++)
-       {
-         Side_position_interface::add_support (arpeggio_, supports_[i]);
-       }
-      announce_grob (arpeggio_, arpeggio_req_);
+      arpeggio_ = make_item ("Arpeggio");
+      announce_grob(arpeggio_, arpeggio_req_->self_scm());
     }
 }
 
@@ -104,8 +95,6 @@ Arpeggio_engraver::stop_translation_timestep ()
       arpeggio_ = 0;
     }
   arpeggio_req_ = 0;
-  stems_.clear ();
-  supports_.clear ();
 }
 
 
@@ -114,6 +103,7 @@ Arpeggio_engraver::stop_translation_timestep ()
 ENTER_DESCRIPTION(Arpeggio_engraver,
 /* descr */       "Generate an Arpeggio from a Arpeggio_req",
 /* creats*/       "Arpeggio",
-/* acks  */       "stem-interface rhythmic-head-interface",
+/* accepts */     "arpeggio-event",
+/* acks  */       "stem-interface rhythmic-head-interface note-column-interface",
 /* reads */       "",
 /* write */       "");