]> git.donarmstrong.com Git - lilypond.git/commitdiff
Padding for key-signature-interface; more accurate outline for mirroredflat.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 1 Feb 2007 10:19:29 +0000 (11:19 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 1 Feb 2007 10:19:29 +0000 (11:19 +0100)
lily/accidental.cc
lily/key-signature-interface.cc

index 571c33cbea497e5c8db3cf9eaa305c5b154dc952..3e5d0475f7afa671f23187b9616e8f81ef70df0a 100644 (file)
@@ -72,9 +72,13 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common)
   if (!to_boolean (me->get_property ("restore-first"))
       && !parens)
     {
-      Rational alteration
-       = robust_scm2rational (me->get_property ("alteration"), 0);
-      if (alteration == FLAT_ALTERATION)
+      SCM alist = me->get_property ("glyph-name-alist");
+      SCM alt = me->get_property ("alteration");
+      string glyph_name = robust_scm2string (ly_assoc_get (alt, alist, SCM_BOOL_F),
+                                            "");
+      
+      if (glyph_name == "accidentals.flat"
+         || glyph_name == "accidentals.mirroredflat")
        {
          Box stem = b;
          Box bulb = b;
@@ -83,7 +87,9 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common)
            we could make the stem thinner, but that places the flats
            really close.
          */
-         stem[X_AXIS][RIGHT] *= .5;
+         Direction bulb_dir =
+           glyph_name=="accidentals.mirroredflat" ? LEFT : RIGHT;
+         stem[X_AXIS][bulb_dir] = stem[X_AXIS].center ();
 
          /*
            To prevent vertical alignment for 6ths
@@ -94,7 +100,7 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common)
          boxes.push_back (bulb);
          boxes.push_back (stem);
        }
-      else if (alteration == NATURAL_ALTERATION)
+      else if (glyph_name ==  "accidentals.natural")
        {
          Box lstem = b;
          Box rstem = b;
index d4ddb075e837fcf963f04dae4e5de0b9729140ac..1e673319612bb8fe3a428c5aed7fdf1ca2dbcf17 100644 (file)
@@ -65,15 +65,17 @@ Key_signature_interface::print (SCM smob)
        ? scm_from_int (0)
        : scm_cdar (s);
 
-      SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F);
-      if (!scm_is_string (glyph_name))
+      SCM glyph_name_scm = ly_assoc_get (alt, alist, SCM_BOOL_F);
+      if (!scm_is_string (glyph_name_scm))
        {
          me->warning (_f ("No glyph found for alteration: %s",
                           ly_scm2rational (alt).to_string ().c_str ()));
          continue;
        }
-      
-      Stencil acc (fm->find_by_name (ly_scm2string (glyph_name)));
+
+      string glyph_name = ly_scm2string (glyph_name_scm);
+
+      Stencil acc (fm->find_by_name (glyph_name));
 
       if (acc.is_empty ())
        me->warning (_ ("alteration not found"));
@@ -91,11 +93,12 @@ Key_signature_interface::print (SCM smob)
            has vertical edges on both sides. A little padding is
            needed to prevent collisions.
          */
-         Real padding = 0.0;
-         if (is_cancellation
+         Real padding = robust_scm2double (me->get_property ("padding"),
+                                           0.0);
+         if (glyph_name ==  "accidentals.natural"
              && last_pos < pos + 2
              && last_pos > pos - 6)
-           padding = 0.3;
+           padding += 0.3;
 
          mol.add_at_edge (X_AXIS, LEFT, acc, padding);
          last_pos = pos;
@@ -113,5 +116,6 @@ ADD_INTERFACE (Key_signature_interface,
               "alteration-alist "
               "c0-position "
               "glyph-name-alist "
+              "padding "
               "style "
               );