CVSROOT: /cvsroot/lilypond Module name: lilypond Branch: Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/08/05 10:59:28
Modified files: lily : key-engraver.cc key-signature-interface.cc Log message: CVSWeb URLs: http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/key-engraver.cc.diff?tr1=1.118&tr2=1.119&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/key-signature-interface.cc.diff?tr1=1.36&tr2=1.37&r1=text&r2=text Patches: Index: lilypond/lily/key-engraver.cc diff -u lilypond/lily/key-engraver.cc:1.118 lilypond/lily/key-engraver.cc:1.119 --- lilypond/lily/key-engraver.cc:1.118 Tue Jul 26 22:24:30 2005 +++ lilypond/lily/key-engraver.cc Fri Aug 5 10:59:28 2005 @@ -15,6 +15,8 @@ #include "clef.hh" #include "pitch.hh" +#include "translator.icc" + /* TODO: The representation of key sigs is all fucked. */ @@ -25,9 +27,9 @@ class Key_engraver : public Engraver { void create_key (bool); - void read_ev (Music const *r); + void read_event (Music const *r); - Music *key_ev_; + Music *key_event_; Item *item_; Item *cancellation_; public: @@ -36,7 +38,7 @@ protected: virtual void initialize (); virtual void finalize (); - virtual bool try_music (Music *ev); + virtual bool try_music (Music *event); void stop_translation_timestep (); void process_music (); @@ -52,17 +54,17 @@ Key_engraver::Key_engraver () { - key_ev_ = 0; + key_event_ = 0; item_ = 0; cancellation_ = 0; } void -Key_engraver::create_key (bool def) +Key_engraver::create_key (bool is_default) { if (!item_) { - item_ = make_item ("KeySignature", key_ev_ ? key_ev_->self_scm () : SCM_EOL); + item_ = make_item ("KeySignature", key_event_ ? key_event_->self_scm () : SCM_EOL); item_->set_property ("c0-position", get_property ("middleCPosition")); @@ -72,32 +74,31 @@ if (to_boolean (get_property ("printKeyCancellation")) && !scm_is_eq (last, key)) { - cancellation_ = make_item ("KeyCancellation", key_ev_ ? key_ev_->self_scm () : SCM_EOL); - cancellation_->set_property ("old-accidentals", last); + cancellation_ = make_item ("KeyCancellation", key_event_ ? key_event_->self_scm () : SCM_EOL); + cancellation_->set_property ("accidentals", last); cancellation_->set_property ("c0-position", get_property ("middleCPosition")); } - item_->set_property ("new-accidentals", key); + item_->set_property ("accidentals", key); } - if (!def) + if (!is_default) { - SCM vis = get_property ("explicitKeySignatureVisibility"); - if (ly_is_procedure (vis)) - item_->set_property ("break-visibility", vis); + SCM visibility = get_property ("explicitKeySignatureVisibility"); + item_->set_property ("break-visibility", visibility); } } bool -Key_engraver::try_music (Music *ev) +Key_engraver::try_music (Music *event) { - if (ev->is_mus_type ("key-change-event")) + if (event->is_mus_type ("key-change-event")) { /* do this only once, just to be on the safe side. */ - if (!key_ev_) + if (!key_event_) { - key_ev_ = ev; - read_ev (key_ev_); + key_event_ = event; + read_event (key_event_); } return true; } @@ -128,7 +129,7 @@ void Key_engraver::process_music () { - if (key_ev_ + if (key_event_ || get_property ("lastKeySignature") != get_property ("keySignature")) create_key (false); } @@ -139,11 +140,11 @@ item_ = 0; context ()->set_property ("lastKeySignature", get_property ("keySignature")); cancellation_ = 0; - key_ev_ = 0; + key_event_ = 0; } void -Key_engraver::read_ev (Music const *r) +Key_engraver::read_event (Music const *r) { SCM p = r->get_property ("pitch-alist"); if (!scm_is_pair (p)) @@ -180,10 +181,10 @@ context ()->set_property ("tonic", p.smobbed_copy ()); } -#include "translator.icc" ADD_ACKNOWLEDGER (Key_engraver,clef); ADD_ACKNOWLEDGER (Key_engraver,bar_line); + ADD_TRANSLATOR (Key_engraver, /* descr */ "", /* creats*/ "KeySignature", Index: lilypond/lily/key-signature-interface.cc diff -u lilypond/lily/key-signature-interface.cc:1.36 lilypond/lily/key-signature-interface.cc:1.37 --- lilypond/lily/key-signature-interface.cc:1.36 Wed Mar 16 19:19:15 2005 +++ lilypond/lily/key-signature-interface.cc Fri Aug 5 10:59:28 2005 @@ -51,8 +51,8 @@ // Find the c in the range -4 through 2 int from_bottom_pos = c0p + 4; - from_bottom_pos = from_bottom_pos%7; - from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive. + from_bottom_pos = from_bottom_pos % 7; + from_bottom_pos = (from_bottom_pos + 7) % 7; // Precaution to get positive. int c0 = from_bottom_pos - 4; if ((alter < 0 && ((p > FLAT_TOP_PITCH) || (p + c0 > 4)) && (p + c0 > 1)) @@ -86,7 +86,7 @@ SCM Key_signature_interface::print (SCM smob) { - Grob *me = unsmob_grob (smob); + Item *me = dynamic_cast<Item*> (unsmob_grob (smob)); Real inter = Staff_symbol_referencer::staff_space (me) / 2.0; @@ -101,7 +101,7 @@ style = ""; } - SCM newas = me->get_property ("new-accidentals"); + SCM newas = me->get_property ("accidentals"); Stencil mol; SCM c0s = me->get_property ("c0-position"); @@ -114,6 +114,7 @@ the cancellation signature. */ + int last_pos = -1000; Font_metric *fm = Font_interface::get_default_font (me); for (SCM s = newas; scm_is_pair (s); s = scm_cdr (s)) { @@ -131,47 +132,21 @@ SCM what = scm_caar (s); int pos = alteration_pos (what, alteration, c0p); acc.translate_axis (pos * inter, Y_AXIS); - mol.add_at_edge (X_AXIS, LEFT, acc, 0, 0); - } - } - - Item *it = dynamic_cast<Item *> (me); - if (it->break_status_dir () != RIGHT) - { - SCM old = me->get_property ("old-accidentals"); - - Stencil natural; - if (scm_is_pair (old)) - natural = Font_interface::get_default_font (me)-> - find_by_name (String ("accidentals.") + style + String ("0")); - - int last_pos = -100; - for (; scm_is_pair (old); old = scm_cdr (old)) - { - SCM found = scm_assoc (scm_caar (old), newas); - if (found == SCM_BOOL_F - || scm_cdr (found) != scm_cdar (old)) - { - SCM what = scm_caar (old); - int alteration = 0; - int pos = alteration_pos (what, alteration, c0p); - Stencil m = natural; - m.translate_axis (pos * inter, Y_AXIS); /* The natural sign (unlike flat & sharp) has vertical edges on both sides. A little padding is needed to prevent collisions. */ - Real padding = 0.0; - if (last_pos < pos + 2 - && last_pos > pos - 6) - padding = 0.3; - - mol.add_at_edge (X_AXIS, LEFT, m, padding, 0); - last_pos = pos; - } + Real padding = 0.0; + if (alteration == 0 + && last_pos < pos + 2 + && last_pos > pos - 6) + padding = 0.3; + + mol.add_at_edge (X_AXIS, LEFT, acc, padding, 0); + last_pos = pos; } } @@ -182,4 +157,4 @@ ADD_INTERFACE (Key_signature_interface, "key-signature-interface", "A group of accidentals, to be printed as signature sign.", - "style c0-position old-accidentals new-accidentals"); + "style c0-position accidentals"); _______________________________________________ Lilypond-cvs mailing list Lilypond-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-cvs