]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/gregorian-ligature-engraver.cc
Run `make grand-replace'.
[lilypond.git] / lily / gregorian-ligature-engraver.cc
index 26c6cac55896bd4f9dd94e152c7541d1eadda2fd..049d89d9cf9d1fdac01732705d744bf4ffe6a5da 100644 (file)
@@ -3,16 +3,22 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
+  (c) 2003--2008 Juergen Reuter <reuter@ipd.uka.de>
 */
 
 #include "gregorian-ligature-engraver.hh"
 
 #include "gregorian-ligature.hh"
-#include "warn.hh"
-#include "staff-symbol-referencer.hh"
-#include "spanner.hh"
+#include "international.hh"
 #include "paper-column.hh"
+#include "pitch.hh"
+#include "spanner.hh"
+#include "staff-symbol-referencer.hh"
+#include "stream-event.hh"
+#include "warn.hh"
+
+/* ASSIGN_EVENT_ONCE */
+#include "translator.icc"
 
 /*
  * This abstract class is the common superclass for all ligature
@@ -30,19 +36,13 @@ Gregorian_ligature_engraver::Gregorian_ligature_engraver ()
   pes_or_flexa_req_ = 0;
 }
 
-bool
-Gregorian_ligature_engraver::try_music (Music *m)
+void
+Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev)
 {
-  if (m->is_mus_type ("pes-or-flexa-event"))
-    {
-      pes_or_flexa_req_ = m;
-      return true;
-    }
-  else
-    return Ligature_engraver::try_music (m);
+  ASSIGN_EVENT_ONCE (pes_or_flexa_req_, ev);
 }
 
-void fix_prefix (char *name, int mask,
+void fix_prefix (char const *name, int mask,
                 int *current_set, int min_set, int max_set,
                 Grob *primitive)
 {
@@ -82,12 +82,12 @@ void fix_prefix_set (int *current_set, int min_set, int max_set, Grob *primitive
   fix_prefix ("pes_or_flexa", LINEA, current_set, min_set, max_set, primitive);
 }
 
-void check_and_fix_all_prefixes (Array<Grob_info> primitives)
+void check_and_fix_all_prefixes (vector<Grob_info> primitives)
 {
-  /* Check for illegal head modifier combinations */
-  for (int i = 0; i < primitives.size (); i++)
+  /* Check for invalid head modifier combinations */
+  for (vsize i = 0; i < primitives.size (); i++)
     {
-      Grob *primitive = primitives[i].grob_;
+      Grob *primitive = primitives[i].grob ();
 
       /* compute head prefix set by inspecting primitive grob properties */
       int prefix_set
@@ -121,7 +121,7 @@ void check_and_fix_all_prefixes (Array<Grob_info> primitives)
                          primitive);
        }
 
-      /* check: virga, quilisma and oriscus can not be combined with any
+      /* check: virga, quilisma and oriscus cannot be combined with any
         other prefix, but may be part of a pes or flexa */
       if (prefix_set & VIRGA)
        {
@@ -185,7 +185,7 @@ void check_and_fix_all_prefixes (Array<Grob_info> primitives)
       /* all other combinations should be valid (unless I made a
         mistake) */
 
-      primitive->set_property ("prefix-set", scm_int2num (prefix_set));
+      primitive->set_property ("prefix-set", scm_from_int (prefix_set));
     }
 }
 
@@ -193,49 +193,43 @@ void check_and_fix_all_prefixes (Array<Grob_info> primitives)
  * Marks those heads that participate in a pes or flexa.
  */
 void
-provide_context_info (Array<Grob_info> primitives)
+provide_context_info (vector<Grob_info> primitives)
 {
   Grob *prev_primitive = 0;
   int prev_prefix_set = 0;
   int prev_context_info = 0;
   int prev_pitch = 0;
-  for (int i = 0; i < primitives.size (); i++)
+  for (vsize i = 0; i < primitives.size (); i++)
     {
-      Grob *primitive = primitives[i].grob_;
-      Music *music_cause = primitives[i].music_cause ();
+      Grob *primitive = primitives[i].grob ();
+      Stream_event *event_cause = primitives[i].event_cause ();
       int context_info = 0;
-      int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
+      int pitch = unsmob_pitch (event_cause->get_property ("pitch"))->steps ();
       int prefix_set = scm_to_int (primitive->get_property ("prefix-set"));
 
       if (prefix_set & PES_OR_FLEXA)
-       if (!i) // ligature may not start with 2nd head of pes or flexa
-         {
-           primitive->warning ("may not apply `\\~' on first head of "
-                               "ligature; ignoring `\\~'");
-         }
-       else if (pitch > prev_pitch) // pes
-         {
-           prev_context_info |= PES_LOWER;
-           context_info |= PES_UPPER;
-         }
-       else if (pitch < prev_pitch) // flexa
-         {
-           prev_context_info |= FLEXA_LEFT;
-           context_info |= FLEXA_RIGHT;
-         }
-       else // (pitch == prev_pitch)
-         {
-           primitive->warning ("may not apply `\\~' on heads with "
-                               "identical pitch; ignoring `\\~'");
-         }
-      if (prev_prefix_set & DEMINUTUM)
        {
-         context_info |= AFTER_DEMINUTUM;
+         if (!i) // ligature may not start with 2nd head of pes or flexa
+           primitive->warning (_ ("cannot apply `\\~' on first head of ligature"));
+         else if (pitch > prev_pitch) // pes
+           {
+             prev_context_info |= PES_LOWER;
+             context_info |= PES_UPPER;
+           }
+         else if (pitch < prev_pitch) // flexa
+           {
+             prev_context_info |= FLEXA_LEFT;
+             context_info |= FLEXA_RIGHT;
+           }
+         else // (pitch == prev_pitch)
+           primitive->warning (_ ("cannot apply `\\~' on heads with identical pitch"));
        }
+      if (prev_prefix_set & DEMINUTUM)
+       context_info |= AFTER_DEMINUTUM;
 
       if (prev_primitive)
        prev_primitive->set_property ("context-info",
-                                     scm_int2num (prev_context_info));
+                                     scm_from_int (prev_context_info));
       prev_primitive = primitive;
       prev_prefix_set = prefix_set;
       prev_context_info = context_info;
@@ -243,20 +237,12 @@ provide_context_info (Array<Grob_info> primitives)
     }
   if (prev_primitive)
     prev_primitive->set_property ("context-info",
-                                 scm_int2num (prev_context_info));
-}
-
-void
-Gregorian_ligature_engraver::transform_heads (Spanner *, Array<Grob_info>)
-{
-  programming_error ("Gregorian_ligature_engraver::transform_heads (): "
-                    "this is an abstract method that should not be called, "
-                    "but overridden by a subclass");
+                                 scm_from_int (prev_context_info));
 }
 
 void
 Gregorian_ligature_engraver::build_ligature (Spanner *ligature,
-                                            Array<Grob_info> primitives)
+                                            vector<Grob_info> primitives)
 {
   // apply style-independent checking and transformation
   check_and_fix_all_prefixes (primitives);
@@ -274,10 +260,5 @@ Gregorian_ligature_engraver::stop_translation_timestep ()
   pes_or_flexa_req_ = 0;
 }
 
-ADD_TRANSLATOR (Gregorian_ligature_engraver,
-               /* descr */ "This is an abstract class.  Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.",
-               /* creats*/ "",
-               /* accepts */ "ligature-event",
-               /* acks  */ "note-head-interface rest-interface",
-               /* reads */ "",
-               /* write */ "");
+// no ADD_ACKNOWLEDGER / ADD_ACKNOWLEDGER / ADD_TRANSLATOR macro calls
+// since this class is abstract