]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/drum-note-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / drum-note-engraver.cc
index cf61692baad7d794ee15c5679a8a4fbc587f525b..1d1b8d2331c226a0845850cfd9b9e0d2fa18d74b 100644 (file)
@@ -1,10 +1,11 @@
 /*
   drum-note-engraver.cc
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include <cctype>
+using namespace std;
 
 #include "rhythmic-head.hh"
 #include "engraver.hh"
 
 class Drum_notes_engraver : public Engraver
 {
-  Link_array<Item> notes_;
-  Link_array<Item> dots_;
-  Link_array<Item> scripts_;
-  Link_array<Music> events_;
+  vector<Item*> notes_;
+  vector<Item*> dots_;
+  vector<Item*> scripts_;
+  vector<Music*> events_;
 
 public:
   TRANSLATOR_DECLARATIONS (Drum_notes_engraver);
 
 protected:
   virtual bool try_music (Music *ev);
-  PRECOMPUTED_VIRTUAL void process_music ();
-  DECLARE_ACKNOWLEDGER(stem);
-  DECLARE_ACKNOWLEDGER(note_column);
-  PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+  void process_music ();
+  DECLARE_ACKNOWLEDGER (stem);
+  DECLARE_ACKNOWLEDGER (note_column);
+  void stop_translation_timestep ();
 };
 
 Drum_notes_engraver::Drum_notes_engraver ()
@@ -42,7 +43,7 @@ Drum_notes_engraver::try_music (Music *m)
 {
   if (m->is_mus_type ("note-event"))
     {
-      events_.push (m);
+      events_.push_back (m);
       return true;
     }
   else if (m->is_mus_type ("busy-playing-event"))
@@ -55,7 +56,7 @@ void
 Drum_notes_engraver::process_music ()
 {
   SCM tab = 0;
-  for (int i = 0; i < events_.size (); i++)
+  for (vsize i = 0; i < events_.size (); i++)
     {
       if (!tab)
        tab = get_property ("drumStyleTable");
@@ -65,7 +66,7 @@ Drum_notes_engraver::process_music ()
 
       Duration dur = *unsmob_duration (ev->get_property ("duration"));
 
-      note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
+      note->set_property ("duration-log", scm_from_int (dur.duration_log ()));
 
       if (dur.dot_count ())
        {
@@ -74,11 +75,11 @@ Drum_notes_engraver::process_music ()
 
          if (dur.dot_count ()
              != robust_scm2int (d->get_property ("dot-count"), 0))
-           d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
+           d->set_property ("dot-count", scm_from_int (dur.dot_count ()));
 
          d->set_parent (note, Y_AXIS);
 
-         dots_.push (d);
+         dots_.push_back (d);
        }
 
       SCM drum_type = ev->get_property ("drum-type");
@@ -102,53 +103,43 @@ Drum_notes_engraver::process_music ()
          if (scm_is_string (script))
            {
              Item *p = make_item ("Script", ev->self_scm ());
-             bool follow;
-             make_script_from_event (p, &follow,
-                                     context (), script,
+             make_script_from_event (p, context (), script,
                                      0);
 
-             if (p->get_property ("follow-into-staff"))
-               p->set_property ("staff-padding", SCM_EOL);
-
              p->set_parent (note, Y_AXIS);
              Side_position_interface::add_support (p, note);
-             scripts_.push (p);
+             scripts_.push_back (p);
            }
        }
 
-      notes_.push (note);
+      notes_.push_back (note);
     }
 }
 
 void
 Drum_notes_engraver::acknowledge_stem (Grob_info inf)
 {
-  for (int i = 0; i < scripts_.size (); i++)
+  for (vsize i = 0; i < scripts_.size (); i++)
     {
       Grob *e = scripts_[i];
 
       if (to_dir (e->get_property ("side-relative-direction")))
        e->set_object ("direction-source", inf.grob ()->self_scm ());
 
-      /*
-       add dep ?
-      */
-      e->add_dependency (inf.grob ());
       Side_position_interface::add_support (e, inf.grob ());
     }
 }
+
 void
 Drum_notes_engraver::acknowledge_note_column (Grob_info inf)
 {
-  for (int i = 0; i < scripts_.size (); i++)
+  for (vsize i = 0; i < scripts_.size (); i++)
     {
       Grob *e = scripts_[i];
 
       if (!e->get_parent (X_AXIS)
          && Side_position_interface::get_axis (e) == Y_AXIS)
-       {
-         e->set_parent (inf.grob (), X_AXIS);
-       }
+       e->set_parent (inf.grob (), X_AXIS);
     }
 }
 
@@ -164,13 +155,12 @@ Drum_notes_engraver::stop_translation_timestep ()
 
 #include "translator.icc"
 
-ADD_ACKNOWLEDGER(Drum_notes_engraver, stem);
-ADD_ACKNOWLEDGER(Drum_notes_engraver,note_column);
+ADD_ACKNOWLEDGER (Drum_notes_engraver, stem);
+ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column);
 ADD_TRANSLATOR (Drum_notes_engraver,
-               /* descr */ "Generate noteheads.",
-               /* creats*/ "NoteHead Dots Script",
-               /* accepts */ "note-event busy-playing-event",
-               /* acks  */ "",
-               /* reads */ "drumStyleTable",
+               /* doc */ "Generate noteheads.",
+               /* create */ "NoteHead Dots Script",
+               /* accept */ "note-event busy-playing-event",
+               /* read */ "drumStyleTable",
                /* write */ "");