X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkey-signature-interface.cc;h=58f0abd95f479d2a71f5ab3b416fce6ffc280699;hb=e434a44b5d693cba78b5debb929a76da4c744981;hp=8351696f30ab0fe4f19709bc19ace50123f8138e;hpb=9dad21216e9f843ae1cfe9ffae916e6ee379e1a6;p=lilypond.git diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 8351696f30..58f0abd95f 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996--2006 Han-Wen Nienhuys + (c) 1996--2009 Han-Wen Nienhuys keyplacement by Mats Bengtsson */ @@ -15,12 +15,12 @@ #include "lookup.hh" #include "output-def.hh" #include "staff-symbol-referencer.hh" +#include "rational.hh" struct Key_signature_interface { DECLARE_SCHEME_CALLBACK (print, (SCM)); - - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; @@ -56,17 +56,29 @@ Key_signature_interface::print (SCM smob) */ int last_pos = -1000; + SCM last_glyph_name = SCM_BOOL_F; + SCM padding_pairs = me->get_property ("padding-pairs"); + Font_metric *fm = Font_interface::get_default_font (me); SCM alist = me->get_property ("glyph-name-alist"); for (SCM s = me->get_property ("alteration-alist"); scm_is_pair (s); s = scm_cdr (s)) { SCM alt = is_cancellation - ? scm_from_int (0) + ? scm_from_int (0) : scm_cdar (s); - SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F); - Stencil acc (fm->find_by_name (ly_scm2string (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; + } + + 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")); @@ -84,14 +96,21 @@ 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); + SCM handle = scm_assoc (scm_cons (glyph_name_scm, last_glyph_name), + padding_pairs); + 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) - padding = 0.3; + padding += 0.3; - mol.add_at_edge (X_AXIS, LEFT, acc, padding, 0); + mol.add_at_edge (X_AXIS, LEFT, acc, padding); + last_pos = pos; + last_glyph_name = glyph_name_scm; } } @@ -103,8 +122,11 @@ Key_signature_interface::print (SCM smob) ADD_INTERFACE (Key_signature_interface, "A group of accidentals, to be printed as signature sign.", + /* properties */ "alteration-alist " "c0-position " "glyph-name-alist " + "padding " + "padding-pairs " "style " );