]> git.donarmstrong.com Git - lilypond.git/commitdiff
move NoteSpacing creation from Rhythmic_column_engraver to new Note_spacing_engraver.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 20 Dec 2006 00:01:09 +0000 (01:01 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 20 Dec 2006 00:01:09 +0000 (01:01 +0100)
lily/note-spacing-engraver.cc [new file with mode: 0644]
lily/rhythmic-column-engraver.cc
ly/engraver-init.ly

diff --git a/lily/note-spacing-engraver.cc b/lily/note-spacing-engraver.cc
new file mode 100644 (file)
index 0000000..33c459c
--- /dev/null
@@ -0,0 +1,92 @@
+/* 
+  note-spacing-engraver.cc -- implement Note_spacing_engraver
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
+  
+*/
+
+#include "engraver.hh"
+
+#include "item.hh"
+#include "pointer-group-interface.hh"
+
+#include "translator.icc"
+
+class Note_spacing_engraver : public Engraver
+{
+  Grob *last_spacing_;
+  Grob *spacing_;
+
+  void add_spacing_item (Grob *);
+
+  TRANSLATOR_DECLARATIONS (Note_spacing_engraver);
+protected:
+
+  DECLARE_ACKNOWLEDGER (rhythmic_grob);
+  DECLARE_ACKNOWLEDGER (note_column);
+  void stop_translation_timestep ();
+};
+
+Note_spacing_engraver::Note_spacing_engraver ()
+{
+  last_spacing_ = 0;
+  spacing_ = 0;
+}
+
+void
+Note_spacing_engraver::add_spacing_item (Grob *g)
+{
+  if (!spacing_)
+    {
+      spacing_ = make_item ("NoteSpacing", g->self_scm ());
+    }
+  
+  
+  if (spacing_)
+    {
+      Pointer_group_interface::add_grob (spacing_,
+                                        ly_symbol2scm ("left-items"),
+                                        g);
+
+      if (last_spacing_)
+       {
+         Pointer_group_interface::add_grob (last_spacing_,
+                                            ly_symbol2scm ("right-items"),
+                                            g);
+       }
+    }
+}
+
+
+void
+Note_spacing_engraver::acknowledge_note_column (Grob_info gi)
+{
+  add_spacing_item (gi.grob ());
+}
+
+void
+Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
+{
+  add_spacing_item (gi.grob ());
+}
+
+void
+Note_spacing_engraver::stop_translation_timestep ()
+{
+  if (spacing_)
+    {
+      last_spacing_ = spacing_;
+      spacing_ = 0;
+    }
+}
+
+ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column);
+ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob);
+
+ADD_TRANSLATOR (Note_spacing_engraver,
+               /* doc */ "Generates NoteSpacing, an object linking horizontal lines for use in spacing.",
+               /* create */ "NoteSpacing",
+               /* read */ "",
+               /* write */ "");
index ec8b754873ce9af8bb0550ff07adb90eee5472cb..4d77927127a95ab5a59961f925b4c4036ea6cb46 100644 (file)
@@ -47,11 +47,6 @@ class Rhythmic_column_engraver : public Engraver
   Grob *note_column_;
   Grob *dotcol_;
 
-  Grob *last_spacing_;
-  Grob *spacing_;
-
-  void add_spacing_item (Grob *);
-
   TRANSLATOR_DECLARATIONS (Rhythmic_column_engraver);
 protected:
 
@@ -64,31 +59,13 @@ protected:
 
 Rhythmic_column_engraver::Rhythmic_column_engraver ()
 {
-  spacing_ = 0;
-  last_spacing_ = 0;
 
   stem_ = 0;
   note_column_ = 0;
   dotcol_ = 0;
 }
 
-void
-Rhythmic_column_engraver::add_spacing_item (Grob *g)
-{
-  if (spacing_)
-    {
-      Pointer_group_interface::add_grob (spacing_,
-                                        ly_symbol2scm ("left-items"),
-                                        g);
 
-      if (last_spacing_)
-       {
-         Pointer_group_interface::add_grob (last_spacing_,
-                                            ly_symbol2scm ("right-items"),
-                                            g);
-       }
-    }
-}
 void
 Rhythmic_column_engraver::process_acknowledged ()
 {
@@ -97,9 +74,6 @@ Rhythmic_column_engraver::process_acknowledged ()
       if (!note_column_)
        {
          note_column_ = make_item ("NoteColumn", rheads_[0]->self_scm ());
-
-         spacing_ = make_item ("NoteSpacing", SCM_EOL);
-         add_spacing_item (note_column_);
        }
 
       for (vsize i = 0; i < rheads_.size (); i++)
@@ -147,13 +121,6 @@ void
 Rhythmic_column_engraver::stop_translation_timestep ()
 {
   note_column_ = 0;
-
-  if (spacing_)
-    {
-      last_spacing_ = spacing_;
-      spacing_ = 0;
-    }
-
   dotcol_ = 0;
   stem_ = 0;
 }
@@ -164,6 +131,6 @@ ADD_ACKNOWLEDGER (Rhythmic_column_engraver, rhythmic_head);
 
 ADD_TRANSLATOR (Rhythmic_column_engraver,
                /* doc */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.",
-               /* create */ "NoteColumn NoteSpacing",
+               /* create */ "NoteColumn",
                /* read */ "",
                /* write */ "");
index ada3cf8bf804eefaac74be2a4309e6e35f7f9b1d..6907308aab1577977113ec9653f528c088af8f6e 100644 (file)
@@ -232,6 +232,7 @@ contained staves are not connected vertically."
   \consists "Script_engraver"
   \consists "Script_column_engraver"
   \consists "Rhythmic_column_engraver"
+  \consists "Note_spacing_engraver"
   \consists "Phrasing_slur_engraver"
   \consists "Cluster_spanner_engraver"
   \consists "Slur_engraver"
@@ -413,7 +414,7 @@ printing of a single line of lyrics.  "
   \consists "Chord_name_engraver"
   \consists "Skip_event_swallow_translator"
   \consists "Hara_kiri_engraver"
-  
+%  \consists "Note_spacing_engraver"
   voltaOnThisStaff = ##f
   \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 2.5)
   \override SeparatingGroupSpanner #'padding = #0.8