]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-signature-interface.cc
initial.
[lilypond.git] / lily / key-signature-interface.cc
index d374c59b2a3a0d88a6beff90ccc9b815502e680e..37f985697ea85844ec17ed41ea3ad01cb919f9f7 100644 (file)
@@ -3,23 +3,24 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   keyplacement by Mats Bengtsson
 */
 
+#include "accidental-interface.hh"
+#include "font-interface.hh"
+#include "international.hh"
 #include "item.hh"
+#include "lookup.hh"
 #include "output-def.hh"
-#include "font-interface.hh"
 #include "staff-symbol-referencer.hh"
-#include "lookup.hh"
-#include "accidental-interface.hh"
 
 struct Key_signature_interface
 {
   DECLARE_SCHEME_CALLBACK (print, (SCM));
 
-  static bool has_interface (Grob *);
+  DECLARE_GROB_INTERFACE();
 };
 
 /*
@@ -30,6 +31,9 @@ const int SHARP_TOP_PITCH = 4; /*  ais and bis typeset in lower octave */
 
 /*
   TODO: look this up. I'm not sure where the naturals ought to go.
+
+  COMMENT: Current implementation does not use the NATURAL_TOP_PITCH for anything,
+           always typesets naturals in the same place as the thing they cancel. -rz
 */
 const int NATURAL_TOP_PITCH = 4;
 
@@ -91,7 +95,7 @@ Key_signature_interface::print (SCM smob)
   Real inter = Staff_symbol_referencer::staff_space (me) / 2.0;
 
   SCM scm_style = me->get_property ("style");
-  String style;
+  string style;
   if (scm_is_symbol (scm_style))
     style = ly_symbol2string (scm_style);
   else
@@ -105,6 +109,9 @@ Key_signature_interface::print (SCM smob)
   if (scm_is_number (c0s))
     c0p = scm_to_int (c0s);
 
+  /* Is this the correct way to determine this? -rz */
+  bool is_cancellation = me->name()=="KeyCancellation";
+
   /*
     SCM lists are stacks, so we work from right to left, ending with
     the cancellation signature.
@@ -115,8 +122,11 @@ Key_signature_interface::print (SCM smob)
   for (SCM s = newas; scm_is_pair (s); s = scm_cdr (s))
     {
       int alteration = scm_to_int (scm_cdar (s));
-      String font_char
-       = Accidental_interface::get_fontcharname (style, alteration);
+      string font_char
+       = Accidental_interface::get_fontcharname (style,
+                                                 is_cancellation
+                                                 ? 0
+                                                 : alteration);
       Stencil acc (fm->find_by_name ("accidentals." + font_char));
 
       if (acc.is_empty ())
@@ -133,7 +143,7 @@ Key_signature_interface::print (SCM smob)
            needed to prevent collisions.
          */
          Real padding = 0.0;
-         if (alteration == 0
+         if (is_cancellation
              && last_pos < pos + 2
              && last_pos > pos - 6)
            padding = 0.3;
@@ -148,6 +158,6 @@ Key_signature_interface::print (SCM smob)
   return mol.smobbed_copy ();
 }
 
-ADD_INTERFACE (Key_signature_interface, "key-signature-interface",
+ADD_INTERFACE (Key_signature_interface,
               "A group of accidentals, to be printed as signature sign.",
               "style c0-position alteration-alist");