Bugfix bug 94. Now key signature naturals are placed at the same
location as the accidental that they cancels.
Added support for extraNatural in key engraver.
-Rune
--- ../lilypond-2.11.2/lily/key-engraver.cc 2006-11-14 21:28:39.000000000 +0100
+++ lily/key-engraver.cc 2006-12-18 17:31:11.000000000 +0100
@@ -72,6 +72,7 @@
SCM last = get_property ("lastKeySignature");
SCM key = get_property ("keySignature");
+ bool extranatural = to_boolean(get_property("extraNatural"));
if ((to_boolean (get_property ("printKeyCancellation"))
|| key == SCM_EOL)
@@ -81,10 +82,13 @@
SCM *tail = &restore;
for (SCM s = last; scm_is_pair (s); s = scm_cdr (s))
{
- if (scm_assoc (scm_caar (s), key) == SCM_BOOL_F)
+ SCM new_alter_pair = scm_assoc (scm_caar (s), key);
+ int old_alter = scm_to_int (scm_cdar (s));
+ if (new_alter_pair == SCM_BOOL_F
+ || extranatural
+ && (scm_to_int(scm_cdr(new_alter_pair))-old_alter)*old_alter < 0)
{
- *tail = scm_acons (scm_caar (s),
- scm_from_int (0), *tail);
+ *tail = scm_cons (scm_car (s), *tail);
tail = SCM_CDRLOC (*tail);
}
}
@@ -94,7 +98,7 @@
cancellation_ = make_item ("KeyCancellation",
key_event_
? key_event_->self_scm () : SCM_EOL);
-
+
cancellation_->set_property ("alteration-alist", restore);
cancellation_->set_property ("c0-position",
get_property ("middleCPosition"));
@@ -203,6 +207,7 @@
/* read */
"createKeyOnClefChange "
"explicitKeySignatureVisibility "
+ "extraNatural "
"keyAlterationOrder "
"keySignature "
"keySignature "
--- ../lilypond-2.11.2/lily/key-signature-interface.cc 2006-12-03 19:55:58.000000000 +0100
+++ lily/key-signature-interface.cc 2006-12-18 17:26:56.000000000 +0100
@@ -31,6 +31,9 @@
/*
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;
@@ -106,6 +109,9 @@
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.
@@ -117,7 +123,10 @@
{
int alteration = scm_to_int (scm_cdar (s));
string font_char
- = Accidental_interface::get_fontcharname (style, alteration);
+ = Accidental_interface::get_fontcharname (style,
+ is_cancellation
+ ? 0
+ : alteration);
Stencil acc (fm->find_by_name ("accidentals." + font_char));
if (acc.is_empty ())
@@ -134,7 +143,7 @@
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;
\header {
texidoc = "If @code{extraNatural} is set then keys that are not altered
father away (i.e. from \# to X or from b to bb) are cancelled. Otherwise only
keys that does not accur in the new key signature are cancelled."
}
\version "2.11.2"
\paper {
indent = 0
}
{
\set Staff.extraNatural = ##f
\key fes \major r1^"extraNatural = ##f"
\key as \major r1
\key b \major r1^"extraNatural = ##t" \bar "||"
\set Staff.extraNatural = ##t
\key as \major r1
\key b \major r1
\key gis \major r1
\key b \major r1
}
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel