source file of the GNU LilyPond music typesetter
- (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "bar-line.hh"
#include "translator.icc"
-/*
- TODO: The representation of key sigs is all fucked.
-*/
-
-/**
- Make the key signature.
-*/
class Key_engraver : public Engraver
{
void create_key (bool);
cancellation_ = 0;
}
+
void
Key_engraver::create_key (bool is_default)
{
for (SCM s = last; scm_is_pair (s); s = scm_cdr (s))
{
SCM new_alter_pair = scm_assoc (scm_caar (s), key);
- int old_alter = scm_to_int (scm_cdar (s));
+ Rational old_alter = robust_scm2rational (scm_cdar (s), 0);
if (new_alter_pair == SCM_BOOL_F
|| extranatural
- && (scm_to_int(scm_cdr(new_alter_pair))-old_alter)*old_alter < 0)
+ && (ly_scm2rational (scm_cdr (new_alter_pair)) - old_alter)*old_alter < Rational (0))
{
*tail = scm_cons (scm_car (s), *tail);
tail = SCM_CDRLOC (*tail);
get_property ("middleCPosition"));
}
}
+
item_->set_property ("alteration-alist", key);
}
{
SCM visibility = get_property ("explicitKeySignatureVisibility");
item_->set_property ("break-visibility", visibility);
- if (cancellation_)
- cancellation_->set_property ("break-visibility", visibility);
}
}
if (!scm_is_pair (p))
return;
- SCM n = scm_list_copy (p);
SCM accs = SCM_EOL;
- for (SCM s = get_property ("keyAlterationOrder");
- scm_is_pair (s); s = scm_cdr (s))
+
+ SCM alist = scm_list_copy (p);
+ SCM order = get_property ("keyAlterationOrder");
+ for (SCM s = order;
+ scm_is_pair (s) && scm_is_pair (alist); s = scm_cdr (s))
{
- if (scm_is_pair (scm_member (scm_car (s), n)))
+ SCM head = scm_member (scm_car (s), alist);
+
+ if (scm_is_pair (head))
{
- accs = scm_cons (scm_car (s), accs);
- n = scm_delete_x (scm_car (s), n);
+ accs = scm_cons (scm_car (head), accs);
+ alist = scm_delete_x (scm_car (head), alist);
}
}
- for (SCM s = n; scm_is_pair (s); s = scm_cdr (s))
- if (scm_to_int (scm_cdar (s)))
- accs = scm_cons (scm_car (s), accs);
-
+ if (scm_is_pair (alist))
+ {
+ bool warn = false;
+ for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
+ if (ly_scm2rational (scm_cdar (s)))
+ {
+ warn = true;
+ accs = scm_cons (scm_car (s), accs);
+ }
+
+ if (warn)
+ r->origin ()->warning ("No ordering for key signature alterations");
+ }
+
context ()->set_property ("keySignature", accs);
context ()->set_property ("tonic",
r->get_property ("tonic"));
"extraNatural "
"keyAlterationOrder "
"keySignature "
- "keySignature "
"lastKeySignature "
"printKeyCancellation "
,