]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Aug 2005 10:59:28 +0000 (10:59 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Aug 2005 10:59:28 +0000 (10:59 +0000)
lily/key-engraver.cc
lily/key-signature-interface.cc

index 13c6ff50d04a0f0851d48d8f0e2775eb8b8f8fae..3a4e848907bb550fb1bbd44736f2e507d2e28038 100644 (file)
@@ -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 @@ public:
 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::finalize ()
 
 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 @@ Key_engraver::create_key (bool def)
       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 @@ Key_engraver::acknowledge_bar_line (Grob_info info)
 void
 Key_engraver::process_music ()
 {
-  if (key_ev_
+  if (key_event_
       || get_property ("lastKeySignature") != get_property ("keySignature"))
     create_key (false);
 }
@@ -139,11 +140,11 @@ Key_engraver::stop_translation_timestep ()
   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 @@ Key_engraver::initialize ()
   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 375bac59b323a982f55c12b79d8a61395e28c285..6215e03fef46f3be4d681dbc1aa9189aaf69bde5 100644 (file)
@@ -51,8 +51,8 @@ alteration_pos (SCM what, int alter, int c0p)
 
   // 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 @@ MAKE_SCHEME_CALLBACK (Key_signature_interface, print, 1);
 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 @@ Key_signature_interface::print (SCM smob)
       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 @@ Key_signature_interface::print (SCM smob)
     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 @@ Key_signature_interface::print (SCM smob)
          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 @@ Key_signature_interface::print (SCM smob)
 
 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");