]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/accidental.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / accidental.cc
index cbbbec7f2cade6daac4ffec37380a1d977f81d0a..8c27bd2b2ee541dd96c0e1e56515327e68f3cd8c 100644 (file)
@@ -1,7 +1,15 @@
+/*
+  accidental.cc -- implement Accidental_interface
+
+  (c) 2001--2004 Han-Wen Nienhuys
+  
+ */
 #include "font-interface.hh"
 #include "item.hh"
-#include "molecule.hh"
+#include "stencil.hh"
 #include "accidental-interface.hh"
+#include "paper-def.hh"
+#include "pitch.hh"
 
 /*
   TODO: insert support for smaller cautionaries, tie-break-reminders.
 */
 
 
-Molecule
-parenthesize (Grob*me, Molecule m)
+Stencil
+parenthesize (Grob*me, Stencil m)
 {
-  Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-leftparen"));
-  Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-rightparen"));
-  m.add_at_edge (X_AXIS, LEFT, Molecule (open), 0,0);
-  m.add_at_edge (X_AXIS, RIGHT, Molecule (close), 0,0);
+  Stencil open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-leftparen"));
+  Stencil close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-rightparen"));
+  m.add_at_edge (X_AXIS, LEFT, Stencil (open), 0,0);
+  m.add_at_edge (X_AXIS, RIGHT, Stencil (close), 0,0);
 
   return m;
 }
@@ -62,7 +70,7 @@ Accidental_interface::accurate_boxes (Grob *a,Grob**common)
       && !parens
       && scm_ilength (accs) == 1)
     {
-      if (gh_scm2int (gh_car (accs)) == -1)
+      if (gh_scm2int (gh_car (accs)) == FLAT)
        {
          Box stem = b;
          Box bulb = b;
@@ -77,6 +85,7 @@ Accidental_interface::accurate_boxes (Grob *a,Grob**common)
          boxes.push (bulb);
          boxes.push (stem);
        }
+      
       /*
        TODO: add support for natural, double flat.
        */
@@ -100,45 +109,48 @@ Accidental_interface::accurate_boxes (Grob *a,Grob**common)
  * is currently no sharp accidental in vaticana style.  In these cases
  * this function falls back to one of the other styles.
  */
+
+/*
+  todo: this sort of stuff in Scheme. --hwn.
+ */
 String
-Accidental_interface::get_fontcharname(String style, int alteration)
+Accidental_interface::get_fontcharname (String style, int alteration)
 {
+  if (alteration == DOUBLE_FLAT
+      || alteration == DOUBLE_SHARP)
+    {
+      return to_string (alteration);
+    }
+  
   if (style == "hufnagel")
     switch (alteration)
       {
-      case -2: return "-2";
-      case -1: return "hufnagel-1";
+      case FLAT: return "hufnagel-1";
       case 0: return "vaticana0";
-      case 1: return "mensural1";
-      case 2: return "2";
+      case SHARP: return "mensural1";
       }
   if (style == "medicaea")
     switch (alteration)
       {
-      case -2: return "-2";
-      case -1: return "medicaea-1";
+      case FLAT: return "medicaea-1";
       case 0: return "vaticana0";
-      case 1: return "mensural1";
-      case 2: return "2";
+      case SHARP: return "mensural1";
       }
   if (style == "vaticana")
     switch (alteration)
       {
-      case -2: return "-2";
-      case -1: return "vaticana-1";
+      case FLAT: return "vaticana-1";
       case 0: return "vaticana0";
-      case 1: return "mensural1";
-      case 2: return "2";
+      case SHARP: return "mensural1";
       }
   if (style == "mensural")
     switch (alteration)
       {
-      case -2: return "-2";
-      case -1: return "mensural-1";
+      case FLAT: return "mensural-1";
       case 0: return "vaticana0";
-      case 1: return "mensural1";
-      case 2: return "2";
+      case SHARP: return "mensural1";
       }
+  
   if (style == "neo_mensural")
     style = ""; // currently same as default
   if (style == "default")
@@ -146,9 +158,9 @@ Accidental_interface::get_fontcharname(String style, int alteration)
   return style + to_string (alteration);
 }
 
-MAKE_SCHEME_CALLBACK (Accidental_interface,brew_molecule,1);
+MAKE_SCHEME_CALLBACK (Accidental_interface,print,1);
 SCM
-Accidental_interface::brew_molecule (SCM smob)
+Accidental_interface::print (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   bool smaller = false;
@@ -184,20 +196,20 @@ Accidental_interface::brew_molecule (SCM smob)
                             (ly_symbol2scm ("font-relative-size"),
                              scm_int2num (-1)), SCM_EOL),
                    ac);
-      fm = Font_interface::get_font (me, ac);
+      fm = select_font (me->get_paper (), ac);
     }
   else
     fm = Font_interface::get_default_font (me);
 
-  Molecule mol;
+  Stencil mol;
   for (SCM s = me->get_grob_property ("accidentals");
        gh_pair_p (s); s = gh_cdr (s))
     {
       int alteration = gh_scm2int (gh_car (s));
       String font_char = get_fontcharname (style, alteration);
-      Molecule acc (fm->find_by_name ("accidentals-" + font_char));
+      Stencil acc (fm->find_by_name ("accidentals-" + font_char));
 
-      if (acc.empty_b())
+      if (acc.is_empty ())
        {
          me->warning (_f ("accidental `%s' not found", font_char));
        }