]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-signature-interface.cc
lilypond-manuals.css: edit color scheme and some spacing
[lilypond.git] / lily / key-signature-interface.cc
index 52fbcffb6f206bef3578fb4e6747a1d0cfb91368..79e2bd99482d25b8e5eb1fb10e9fb1ce2255cae7 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   keyplacement by Mats Bengtsson
 
 #include "output-def.hh"
 #include "staff-symbol-referencer.hh"
 #include "rational.hh"
+#include "lily-imports.hh"
 
 struct Key_signature_interface
 {
   DECLARE_SCHEME_CALLBACK (print, (SCM));
-  DECLARE_GROB_INTERFACE ();
 };
 
 /*
@@ -42,7 +42,7 @@ MAKE_SCHEME_CALLBACK (Key_signature_interface, print, 1);
 SCM
 Key_signature_interface::print (SCM smob)
 {
-  Item *me = dynamic_cast<Item *> (unsmob_grob (smob));
+  Item *me = unsmob<Item> (smob);
 
   Real inter = Staff_symbol_referencer::staff_space (me) / 2.0;
 
@@ -58,7 +58,7 @@ Key_signature_interface::print (SCM smob)
     the cancellation signature.
   */
 
-  int last_pos = -1000;
+  Slice pos, overlapping_pos;
   SCM last_glyph_name = SCM_BOOL_F;
   SCM padding_pairs = me->get_property ("padding-pairs");
 
@@ -87,13 +87,16 @@ Key_signature_interface::print (SCM smob)
         me->warning (_ ("alteration not found"));
       else
         {
-          SCM what = scm_caar (s);
-
-          SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-position");
-
-          int pos = scm_to_int (scm_call_3 (proc, what, scm_cdar (s), c0s));
-          acc.translate_axis (pos * inter, Y_AXIS);
-
+          pos.set_empty ();
+          Stencil column;
+          for (SCM pos_list = Lily::key_signature_interface_alteration_positions
+                 (scm_car (s), c0s, smob);
+               scm_is_pair (pos_list); pos_list = scm_cdr (pos_list))
+            {
+              int p = scm_to_int (scm_car (pos_list));
+              pos.add_point (p);
+              column.add_stencil (acc.translated (Offset (0, p * inter)));
+            }
           /*
             The natural sign (unlike flat & sharp)
             has vertical edges on both sides. A little padding is
@@ -106,13 +109,13 @@ Key_signature_interface::print (SCM smob)
           if (scm_is_pair (handle))
             padding = robust_scm2double (scm_cdr (handle), 0.0);
           else if (glyph_name == "accidentals.natural"
-                   && last_pos < pos + 2
-                   && last_pos > pos - 6)
+                   && !intersection (overlapping_pos, pos).is_empty ())
             padding += 0.3;
 
-          mol.add_at_edge (X_AXIS, LEFT, acc, padding);
+          mol.add_at_edge (X_AXIS, LEFT, column, padding);
 
-          last_pos = pos;
+          pos.widen (4);
+          overlapping_pos = pos + 2;
           last_glyph_name = glyph_name_scm;
         }
     }
@@ -129,6 +132,9 @@ ADD_INTERFACE (Key_signature_interface,
                "alteration-alist "
                "c0-position "
                "glyph-name-alist "
+               "flat-positions "
+               "sharp-positions "
                "padding "
                "padding-pairs "
+               "non-default "
               );